#update
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.maibu.enums;
|
||||
|
||||
public enum Language {
|
||||
ZH_CN("zh-CN"),
|
||||
EN("en-US"),
|
||||
DEFAULT("default");
|
||||
|
||||
private String value;
|
||||
|
||||
Language(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String matches(String language) {
|
||||
if(language.equals("zh")){
|
||||
return Language.ZH_CN.value;
|
||||
}else {
|
||||
return Language.EN.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.maibu.mapper;
|
||||
|
||||
import com.maibu.core.domain.entity.SysRegion;
|
||||
import com.maibu.mybatis.mapper.BaseMapperX;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 设备历史状态
|
||||
*/
|
||||
@Repository
|
||||
public interface SysRegionMapper extends BaseMapperX<SysRegion> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.maibu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.maibu.core.domain.entity.SysRegion;
|
||||
import com.maibu.mapper.SysRegionMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class SysRegionService {
|
||||
|
||||
@Autowired
|
||||
private SysRegionMapper sysRegionMapper;
|
||||
|
||||
|
||||
public List<SysRegion> list(SysRegion region) {
|
||||
LambdaQueryWrapper<SysRegion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (region != null && !StringUtils.isEmpty(region.getRegionName())) {
|
||||
queryWrapper.like(SysRegion::getRegionName, region.getRegionName());
|
||||
}
|
||||
return sysRegionMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
public boolean save(SysRegion org) {
|
||||
return sysRegionMapper.saveOrUpdate(org);
|
||||
}
|
||||
|
||||
public int delete(List<Long> ids) {
|
||||
return sysRegionMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
public void deleteAll(List<Long> ids) {
|
||||
List<Long> regionIds = getIdsBySiteIds(ids);
|
||||
if(!CollectionUtils.isEmpty(regionIds)){
|
||||
delete(regionIds);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Long> getIdsBySiteIds(List<Long> ids) {
|
||||
LambdaQueryWrapper<SysRegion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysRegion::getSiteId, ids);
|
||||
List<SysRegion> list = sysRegionMapper.selectList(queryWrapper);
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
return list.stream().map(SysRegion::getId).collect(Collectors.toList());
|
||||
}else{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public SysRegion selectById(Long id) {
|
||||
return sysRegionMapper.selectById(id);
|
||||
}
|
||||
|
||||
public List<SysRegion> selectBySiteId(Long id) {
|
||||
LambdaQueryWrapper<SysRegion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysRegion::getSiteId, id);
|
||||
return sysRegionMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user