| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | */ |
| | | @Service |
| | | public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService { |
| | | @Autowired |
| | | private SysDictTypeMapper dictTypeMapper; |
| | | |
| | | @Autowired |
| | | private SysDictDataMapper dictDataMapper; |
| | |
| | | List<SysDictData> dictDatas = dictDataMapper.selectList( |
| | | new LambdaQueryWrapper<SysDictData>() |
| | | .eq(SysDictData::getStatus, 0) |
| | | .eq(SysDictData::getDictType, dictType) |
| | | .eq(SysDictData::getDictType, dictType.getDictType()) |
| | | .orderByAsc(SysDictData::getDictSort)); |
| | | DictUtils.setDictCache(dictType.getDictType(), dictDatas); |
| | | } |
| | |
| | | public List<SysDictType> selectDictTypeList(SysDictType dictType) { |
| | | Map<String, Object> params = dictType.getParams(); |
| | | return list(new LambdaQueryWrapper<SysDictType>() |
| | | .like(SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(SysDictType::getStatus, dictType.getStatus()) |
| | | .like(SysDictType::getDictType, dictType.getDictType()) |
| | | .apply(params.get("beginTime") != null, |
| | | .like(StrUtil.isNotBlank(dictType.getDictName()),SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(StrUtil.isNotBlank(dictType.getStatus()),SysDictType::getStatus, dictType.getStatus()) |
| | | .like(StrUtil.isNotBlank(dictType.getDictType()),SysDictType::getDictType, dictType.getDictType()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(params.get("endTime") != null, |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime"))); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public int insertDictType(SysDictType dictType) { |
| | | int row = dictTypeMapper.insert(dictType); |
| | | int row = baseMapper.insert(dictType); |
| | | if (row > 0) { |
| | | DictUtils.clearDictCache(); |
| | | } |
| | |
| | | dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>() |
| | | .set(SysDictData::getDictType, dictType.getDictType()) |
| | | .eq(SysDictData::getDictType, oldDict.getDictType())); |
| | | int row = dictTypeMapper.updateById(dictType); |
| | | int row = baseMapper.updateById(dictType); |
| | | if (row > 0) { |
| | | DictUtils.clearDictCache(); |
| | | } |