| | |
| | | package com.gkhy.assess.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.assess.common.api.CommonPage; |
| | | import com.gkhy.assess.common.enums.DeleteFlagEnum; |
| | | import com.gkhy.assess.common.exception.ApiException; |
| | | import com.gkhy.assess.common.utils.PageUtil; |
| | | import com.gkhy.assess.system.domain.SysDictData; |
| | | import com.gkhy.assess.system.domain.SysDictType; |
| | | import com.gkhy.assess.system.domain.SysLaw; |
| | | import com.gkhy.assess.system.mapper.SysDictDataMapper; |
| | | import com.gkhy.assess.system.mapper.SysDictTypeMapper; |
| | | import com.gkhy.assess.system.service.SysDictTypeService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.assess.system.utils.ShiroUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @Override |
| | | public int addDictType(SysDictType dictType) { |
| | | if(!checkDictTypeUnique(dictType)){ |
| | | throw new ApiException("新增字典类型已存在"); |
| | | } |
| | | dictType.setCreateBy(ShiroUtils.getSysUser().getUsername()); |
| | | boolean b=save(dictType); |
| | | if(!b){ |
| | | throw new ApiException("新增字典类型失败"); |
| | |
| | | @Override |
| | | // @Transactional(rollbackFor = RuntimeException.class) |
| | | public int editDictType(SysDictType dict) { |
| | | if(!checkDictTypeUnique(dict)){ |
| | | throw new ApiException("字典类型已存在"); |
| | | } |
| | | SysDictType oldDict= baseMapper.getDictTypeById(dict.getId()); |
| | | dict.setDictType(oldDict.getDictType());//字典类型不能修改 |
| | | dict.setUpdateBy(ShiroUtils.getSysUser().getUsername()); |
| | | boolean b=updateById(dict); |
| | | if(!b){ |
| | | throw new ApiException("修改数据字典类型失败"); |
| | |
| | | if(dictDataMapper.countDictDataByType(dictType.getDictType())>0){ |
| | | throw new ApiException(String.format("%1$s已分配,不能删除", dictType.getName())); |
| | | } |
| | | boolean b=removeById(dictId); |
| | | SysDictType sysDictType=new SysDictType().setId(dictId) |
| | | .setDelFlag(DeleteFlagEnum.DELETED.getCode()); |
| | | sysDictType.setUpdateBy(ShiroUtils.getSysUser().getName()); |
| | | boolean b=updateById(sysDictType); |
| | | if(!b){ |
| | | throw new ApiException("删除字典类型失败"); |
| | | } |
| | |
| | | @Override |
| | | public boolean checkDictTypeUnique(SysDictType dict) { |
| | | Long dictId = ObjectUtil.isNull(dict.getId()) ? -1L : dict.getId(); |
| | | SysDictType dictType = baseMapper.checkDictTypeUnique(dict.getDictType()); |
| | | SysDictType dictType = baseMapper.checkDictTypeUnique(dict.getDictType(),dict.getName()); |
| | | if (ObjectUtil.isNotNull(dictType) && dictType.getId().longValue() != dictId.longValue()) |
| | | { |
| | | return false; |