package com.thhy.engineering.modules.biz.engineering.service.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.thhy.engineering.modules.biz.engineering.entity.ProSunDto.DictTypeDto; import com.thhy.engineering.modules.biz.engineering.entity.SysDict; import com.thhy.engineering.modules.biz.engineering.mapper.SysDictMapper; import com.thhy.engineering.modules.biz.engineering.service.SysDictService; import com.thhy.general.common.BasicResult; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.HashMap; import java.util.List; import java.util.Map; @Service public class SysDictServiceImp implements SysDictService { @Resource private SysDictMapper dictMapper; @Override public BasicResult dictInsert(Map values) { String dictName = values.get("dictName").toString(); String diceType = values.get("dictType").toString(); String dictId = dictMapper.diceSelectNameByOne(dictName,diceType); if(dictId!=null){ return BasicResult.faild("11111","error","类型名称重复"); } values.put("dict_id",""); dictMapper.dictInsert(values); return BasicResult.success("添加成功"); } @Override public BasicResult dictList(Map values) { Integer pageSize = Integer.valueOf(values.get("pageSize").toString()); Integer pageNum = Integer.valueOf(values.get("pageNum").toString()); PageHelper.startPage(pageNum,pageSize); List sysDicts = dictMapper.dictList(values); PageInfo sysDictPageInfo = new PageInfo<>(sysDicts); return BasicResult.success(sysDictPageInfo); } @Override public BasicResult dictInfo(String dictId) { SysDict sysDict = dictMapper.dictInfo(dictId); return BasicResult.success(sysDict); } @Override public BasicResult dictDel(String dictId) { SysDict dict = dictMapper.dictSelectByOne(dictId); if(dict.getDictType().equals("1")){ List sizeIds = dictMapper.dictByAll(dict.getDictId()); if(sizeIds.size()>0){ return BasicResult.faild("11111","该类型已被占用","该类型已被占用"); } }else if(dict.getDictType().equals("2")){ List hasIds = dictMapper.dictByHasAll(dict.getDictId()); if(hasIds.size()>0){ return BasicResult.faild("11111","该类型已被占用","该类型已被占用"); } }else if(dict.getDictType().equals("3")){ List turnIds = dictMapper.dictByTurnAll(dict.getDictId()); if(turnIds.size()>0){ return BasicResult.faild("11111","该类型已被占用","该类型已被占用"); } } else if(dict.getDictType().equals("4")){ List grouting = dictMapper.dictByGroutingAll(dict.getDictId()); if(grouting.size()>0){ return BasicResult.faild("11111","该类型已被占用","该类型已被占用"); } }else if(dict.getDictType().equals("5")){ List blok = dictMapper.dictByBlokAll(dict.getDictId()); if(blok.size()>0){ return BasicResult.faild("11111","该类型已被占用","该类型已被占用"); } } dictMapper.dictDel(dictId); return BasicResult.success("删除成功"); } @Override public BasicResult dictUpdate(Map values) { String dictName = values.get("dictName").toString(); String diceType = values.get("dictType").toString(); String dictId = dictMapper.diceSelectNameByOne(dictName,diceType); String dictId1 = values.get("dictId").toString(); if(dictId!=null&&!dictId.equals(dictId1)){ return BasicResult.faild("11111","error","类型名称重复"); } dictMapper.dictUpdate(values); return BasicResult.success("修改成功"); } @Override public BasicResult dictTypePull() { List dictTypeDtos = dictMapper.dictTypePull(); return BasicResult.success(dictTypeDtos); } }