parent
018edb596c
commit
99ff3d783b
@ -0,0 +1,53 @@
|
|||||||
|
package cn.estsh.i3plus.core.api.iservice.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.platform.bean.SysDictionary;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 字典服务接口
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @Date : 2018-10-28 23:41
|
||||||
|
* @Modify :
|
||||||
|
**/
|
||||||
|
public interface ISysDictionaryService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加字典
|
||||||
|
* @param sysDictionary
|
||||||
|
*/
|
||||||
|
void insertSysDictionary(SysDictionary sysDictionary);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id删除字典
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void deleteSysDictionaryById(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典
|
||||||
|
* @param sysDictionary
|
||||||
|
*/
|
||||||
|
void updateSysDictionary(SysDictionary sysDictionary);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有字典信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SysDictionary> listSysDictionary();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询字典信息
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SysDictionary getSysDictionaryById(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父级id查询字典信息
|
||||||
|
* @param parentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SysDictionary> findSysDictionaryByCode(String parentId);
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysDictionaryService;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.bean.Position;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.bean.SysDictionary;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.repository.SysDictionaryRepository;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 字典服务接口实现
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @Date : 2018-10-28 23:44
|
||||||
|
* @Modify :
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
public class SysDictionaryServiceImpl implements ISysDictionaryService {
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(SysDictionaryServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysDictionaryRepository sysDictionaryRDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertSysDictionary(SysDictionary sysDictionary) {
|
||||||
|
// 查询父级字典名称
|
||||||
|
if (sysDictionary.getParentId() != null && sysDictionary.getParentId() > 0) {
|
||||||
|
LOGGER.info("字典 SYS_DICTIONARY parentId:{}", sysDictionary.getParentId());
|
||||||
|
SysDictionary parentSysDictionary = sysDictionaryRDao.getById(sysDictionary.getParentId());
|
||||||
|
ValidatorBean.checkNotNull(parentSysDictionary);
|
||||||
|
|
||||||
|
sysDictionary.setRedParentName(parentSysDictionary.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.info("字典 SYS_DICTIONARY sysDictionary:{}",sysDictionary);
|
||||||
|
sysDictionaryRDao.insert(sysDictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteSysDictionaryById(String id) {
|
||||||
|
LOGGER.info("字典 SYS_DICTIONARY id:{}",id);
|
||||||
|
sysDictionaryRDao.deleteById(Long.parseLong(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSysDictionary(SysDictionary sysDictionary) {
|
||||||
|
// 查询父级字典名称
|
||||||
|
if (sysDictionary.getParentId() != null && sysDictionary.getParentId() > 0) {
|
||||||
|
LOGGER.info("字典 SYS_DICTIONARY parentId:{}", sysDictionary.getParentId());
|
||||||
|
SysDictionary parentSysDictionary = sysDictionaryRDao.getById(sysDictionary.getParentId());
|
||||||
|
ValidatorBean.checkNotNull(parentSysDictionary);
|
||||||
|
|
||||||
|
sysDictionary.setRedParentName(parentSysDictionary.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.info("字典 SYS_DICTIONARY sysDictionary:{}",sysDictionary);
|
||||||
|
sysDictionaryRDao.update(sysDictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDictionary> listSysDictionary() {
|
||||||
|
LOGGER.info("字典 SYS_DICTIONARY list");
|
||||||
|
return sysDictionaryRDao.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysDictionary getSysDictionaryById(String id) {
|
||||||
|
LOGGER.info("字典 SYS_DICTIONARY id:{}",id);
|
||||||
|
return sysDictionaryRDao.getById(Long.parseLong(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDictionary> findSysDictionaryByCode(String code) {
|
||||||
|
LOGGER.info("字典 SYS_DICTIONARY code:{}",code);
|
||||||
|
return sysDictionaryRDao.findByHql("select child from SysDictionary dic,SysDictionary child where dic.id = child.parentId and dic.dictionaryCode = '" + code + "'");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue