diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcDictBizController.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcDictBizController.java index 2792e647..dd18c5d6 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcDictBizController.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcDictBizController.java @@ -2,13 +2,18 @@ package com.xhpc.general.controller; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.general.domain.XhpcDictionary; import com.xhpc.general.service.IXhpcDictBizService; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * 业务字典Controller * @@ -32,5 +37,141 @@ public class XhpcDictBizController extends BaseController { return AjaxResult.success(xhpcDictBizService.getCode(code)); } + /**Adding a parent item to the table(xhpc_dict_biz) + * + * @param name the dictionary's name + * @param code the dictionary's code + * @param sort the dictionary's sortValue + * @return + */ + @PostMapping("/addMainItem") + public AjaxResult addMainDictionaryItem(String name, String code, Integer sort){ + + return xhpcDictBizService.addADictionaryItem(name,code,sort); + } + + + /** + * Getting a dictionary data. + * + * @param id The id is map to dictionary table is dict_biz_id. + * @return + */ + @GetMapping("/getDictionaryItem") + public AjaxResult getADictionaryItem(Long id){ + + return AjaxResult.success(xhpcDictBizService.selectDictionaryItem(id)); + } + + + /** + * Adding a childItem to the table(xhpc_dict_biz) + * @param parentId + * @param code + * @param dictKey + * @param dictValue + * @return + */ + @PostMapping("/addDetailItem") + public AjaxResult addDetailDictionaryItem(Long parentId, String code, String dictKey, String dictValue,Integer sort){ + + return xhpcDictBizService.addAChildDictionaryItem(parentId, code, dictKey, dictValue, sort); + } + + + /** + * Deleting a dictionary item by id(dict_biz_id) + * @param id + * @return + */ + @PostMapping("/deleteChildDictionaryItem") + public AjaxResult deleteChildDictionaryItem(Long id){ + + return xhpcDictBizService.deleteChildDictionaryItem(id); + } + + @PostMapping("/deleteFather") + public AjaxResult deleteParentItem(Long id){ + return xhpcDictBizService.deleteParentItem(id); + } + + + + /** + * Getting a list of the parent dict items by code and name. + * @param code + * @param name + * @return + */ + @GetMapping("/getParentItems") + public TableDataInfo getSearchParentResult(String code, String name ){ + startPage(); + List list = xhpcDictBizService.getMainItems(code,name); + return getDataTable(list); + } + + + + /** + * Getting a list of the child dict items by code,code,parentId. + * @param parentId + * @param code + * @param name + * @return + */ + @GetMapping("/getChildItems") + public TableDataInfo getSearchChildResult(Long parentId, String code, String name){ + + startPage(); + List list=xhpcDictBizService.getDetailsItems(parentId, code, name); + return getDataTable(list); + } + + + /** + * Updating the main item by code,dictValue,sort + * @param dictBizId + * @param code + * @param keyValue the item's name + * @param sort + * @return + */ + @PostMapping("/updateFatherItem") + public AjaxResult updateFatherItem(Long dictBizId,String code,String keyValue,Integer sort){ + + return xhpcDictBizService.updateMainItem(dictBizId, code, keyValue, sort); + } + + + /** + * Updating the child item. + * @param parentId + * @param id + * @param value + * @param key + * @param sort + * @return + */ + @PostMapping("/updateChildItem") + public AjaxResult updateChildItem(Long parentId,Long id, String value, String key,Integer sort ){ + + return xhpcDictBizService.updateChildItem(parentId, id, value, key, sort); + } + + + /** + * Deleting a bundle of child item. + * @param ids + * @return + */ + @PostMapping("/deleteChildItems") + public AjaxResult deletChildItems(String ids){ + + return xhpcDictBizService.deleteChildItems(ids); + } + @PostMapping("/deleteParentItems") + public AjaxResult deleteParentItems(String ids){ + return xhpcDictBizService.deleteParentItems(ids); + } } diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/domain/XhpcDictionary.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/domain/XhpcDictionary.java new file mode 100644 index 00000000..f8f1db01 --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/domain/XhpcDictionary.java @@ -0,0 +1,79 @@ +package com.xhpc.general.domain; +import com.xhpc.common.core.web.domain.BaseEntity; + +/** + * This is a data entity of dictionary. + * program: ruoyi + * User: HongYun + * Date:2021-07-27 11 + */ +public class XhpcDictionary extends BaseEntity { + private Long dictBizId; + private Long parentId; + private String code; + private String dictKey; + private String dictValue; + private Integer sort; + private Integer delFlag; + + + public String getCode() { + return code; + } + + /** + * This is the dictionary's code. + * @param code + */ + public void setCode(String code) { + this.code = code; + } + + public String getDictKey() { + return dictKey; + } + + public void setDictKey(String dictKey) { + this.dictKey = dictKey; + } + + public String getDictValue() { + return dictValue; + } + + public void setDictValue(String dictValue) { + this.dictValue = dictValue; + } + + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public Long getDictBizId() { + return dictBizId; + } + + public void setDictBizId(Long dictBizId) { + this.dictBizId = dictBizId; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public Integer getDelFlag() { + return delFlag; + } + + public void setDelFlag(Integer delFlag) { + this.delFlag = delFlag; + } +} diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizMapper.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizMapper.java index 17562f19..18d7b34b 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizMapper.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizMapper.java @@ -1,6 +1,8 @@ package com.xhpc.general.mapper; import com.xhpc.common.domain.XhpcDictBiz; +import com.xhpc.general.domain.XhpcDictionary; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -20,4 +22,122 @@ public interface XhpcDictBizMapper { */ public List getCode(String code); + /** + * Ensuring the parent name is unique. + * @param name is dict_value. + * @return + */ + int countParentNameColumns(@Param("id")Long id, @Param("name") String name); + + /** + * This is to ensure the child keyValue is unique + * @param id + * @param name + * @return + */ + int countSameParentChildNameColumns(@Param("id") Long id,@Param("name") String name); + + + + /** + * Adding a item to the table(xhpc_dict_biz) + * @param name the dictionary's name + * @param code the dictionary's code + * + */ + void insertAParentItemToTable(@Param("name") String name,@Param("code") String code,@Param("sort") Integer sort); + /** + * Getting a dictionary data. + * + * The id map to dictionary table is dict_biz_id. + * @param id + * @return + */ + XhpcDictionary selectADictionaryItem(@Param("id") Long id); + + /** + * Adding a childIem to the table(xhpc_dict_biz) + * @param parentId + * @param code + * @param dictKey + * @param dictValue + * @return + */ + void insertAChildItemToTable(@Param("id")Long parentId,@Param("code") String code,@Param("dictKey") String dictKey,@Param("dictValue") String dictValue,@Param("sore") Integer sort); + /** + * Deleting a dictionary item by id(dict_biz_id) + * @param id + * @return + */ + int deleteChildDictionaryItemById(@Param("id") Long id); + + void deleteChildItemsFollowParent(@Param("id") Long id); + /** + * Getting a list of the parent dict items by code and name. + * @param code + * @param name + * @return + */ + List selectParentDictionaryItemsByCodeAndName(@Param("code")String code,@Param("name") String name); + + /** + * Getting a list of the child dict items by code,code,parentId. + * @param parentId + * @param code + * @param name + * @return + */ + List selectChildDictionaryItemsByCodeAndName(@Param("id") Long parentId, @Param("code") String code, @Param("name") String name); + + /** + * Updating the main item by code,dictValue,sort + * @param dictBizId + * @param code + * @param keyValue the item's name + * @param sort + * @return + */ + int updateParentItemByCodeDictValueSort(@Param("id") Long id,@Param("code") String code,@Param("dictValue") String dictValue,@Param("sort") Integer sort); + + /** + * Updating the child item's dict_value, after their father item has changed its dict_value. + * @param dictBizId + * @param value + */ + void updateChildValue(@Param("id") Long dictBizId,@Param("code") String code); + + /** + * Updating a child item by value,key. + * @param id + * @param value + * @param key + * @return + */ + int updateChildItem(@Param("id") Long id,@Param("value") String value,@Param("key") String key,@Param("sort") Integer sort); + + /** + * Deleting a bundle of child item. + * @param ids + * @return + */ + int deleteChildItemByIds(@Param("ids") List ids); + + /** + * Deleting a bundle of child item after their parent has been died. + * @param ids + * @return + */ + int deleteChildItemsAfterTheirParentDied(@Param("ids") List ids); + + /** + * Getting parent's name's quantity. + * @param name + * @return + */ + int countParentNameQuantity(@Param("name") String name); + + + + void updateChildCodeAfterParentChanged(@Param("code") String code,@Param("id") Long id); + } diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizQuantityCheckMapper.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizQuantityCheckMapper.java new file mode 100644 index 00000000..2f076325 --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/mapper/XhpcDictBizQuantityCheckMapper.java @@ -0,0 +1,40 @@ +package com.xhpc.general.mapper; + +import org.apache.ibatis.annotations.Param; + +/** + * program: Getting the quantity of one column's rows. + * User: HongYun + * Date:2021-07-28 15 + */ +public interface XhpcDictBizQuantityCheckMapper { + /** + * Ensuring the father's code is unique. + * @param code + * @return + */ + int countCodeRows(@Param("code") String code); + + /** + * Ensuring the child's keyValue is unique. + * @param parentId + * @param key Value + * @return + */ + int countSameParentChildValueColumns(@Param("id") Long parentId, @Param("key") String key); + + int countSameParentChildKeyColumns(@Param("id") Long parentId, @Param("key") String key); + + /** + * Judging the name whether has existed in father items. + * @param name + * @return + */ + int countParentName(@Param("name") String name); + + + + + + +} diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/IXhpcDictBizService.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/IXhpcDictBizService.java index 220d391e..95628f32 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/IXhpcDictBizService.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/IXhpcDictBizService.java @@ -1,6 +1,8 @@ package com.xhpc.general.service; +import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.domain.XhpcDictBiz; +import com.xhpc.general.domain.XhpcDictionary; import java.util.List; @@ -19,4 +21,93 @@ public interface IXhpcDictBizService { * @return 电站 */ public List getCode(String code); + + /**Adding a parent item to the table(xhpc_dict_biz) + * + * @param name the dictionary's name + * @param code the dictionary's code + * @param sort the dictionary's sortValue + * @return + */ + AjaxResult addADictionaryItem(String name, String code, Integer sort); + + /** + * Getting a dictionary data. + * + * The id map to dictionary table is dict_biz_id. + * @param id + * @return + */ + AjaxResult selectDictionaryItem(Long id); + + /** + * Adding a childIem to the table(xhpc_dict_biz) + * @param parentId + * @param code + * @param dictKey + * @param dictValue + * @return + */ + AjaxResult addAChildDictionaryItem(Long parentId,String code,String dictKey,String dictValue,Integer sort); + + /** + * Deleting a dictionary item by id(dict_biz_id) + * @param id + * @return + */ + AjaxResult deleteChildDictionaryItem(Long id); + + + AjaxResult deleteParentItem(Long id); + + /** + * Getting a list of the parent dict items by code and name. + * @param code + * @param name + * @return + */ + List getMainItems(String code,String name); + + /** + * Getting a list of the child dict items by code,code,parentId. + * @param parentId + * @param code + * @param name + * @return + */ + List getDetailsItems(Long parentId, String code, String name); + + /** + * Updating the main item by code,dictValue,sort + * @param dictBizId + * @param code + * @param keyValue the item's name + * @param sort + * @return + */ + AjaxResult updateMainItem(Long id,String code,String dictValue,Integer sort); + + /** + * Updating a child item by value,key. + * @param parentId + * @param id + * @param value + * @param key + * @Param sort + * @return + */ + AjaxResult updateChildItem(Long parentId, Long id, String value, String key, Integer sort); + + /** + * Deleting a bundle of child item. + * @param ids + * @return + */ + AjaxResult deleteChildItems(String ids); + + + /** + * Deleting a bundle of parent item. + */ + AjaxResult deleteParentItems(String ids); } diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcDictBizServiceImpl.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcDictBizServiceImpl.java index d42b1d00..24a4e50a 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcDictBizServiceImpl.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcDictBizServiceImpl.java @@ -1,10 +1,15 @@ package com.xhpc.general.service; +import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.domain.XhpcDictBiz; +import com.xhpc.general.domain.XhpcDictionary; import com.xhpc.general.mapper.XhpcDictBizMapper; +import com.xhpc.general.mapper.XhpcDictBizQuantityCheckMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.List; /** @@ -19,9 +24,334 @@ public class XhpcDictBizServiceImpl implements IXhpcDictBizService{ @Autowired private XhpcDictBizMapper xhpcDictBizMapper; + @Autowired + private XhpcDictBizQuantityCheckMapper xhpcDictBizQuantityCheckMapper; + @Override public List getCode(String code) { return xhpcDictBizMapper.getCode(code); } + + @Transactional + @Override + public AjaxResult addADictionaryItem(String name, String code, Integer sort) { + + //Ensure the parameter is not null. + if(name==null){ + return AjaxResult.error("字典名称不能为空"); + } + if(code==null){ + return AjaxResult.error("字典编码不能为空"); + } + if(sort==null){ + return AjaxResult.error("字典排序不能为空"); + } + //Ensuring the sort's size is bigger than 0 + if(sort<1){ + return AjaxResult.error("字典排序必须大于0"); + } + //Ensuring the length of parameter's is correct. + if(name.length()>255){ + return AjaxResult.error("字典名称的长度不能大于255"); + } + if(code.length()>255){ + return AjaxResult.error("字典编码的长度不能大于255"); + } + if(String.valueOf(sort).length()>11){ + return AjaxResult.error("字典排序的长度不能大于11"); + } + + + //Ensuring the code whether has existed. + int quantity=xhpcDictBizQuantityCheckMapper.countCodeRows(code); + if(quantity>0){ + return AjaxResult.error("您输入的字符编码已经存在"); + } + + //Ensuring the name(dict_value) has existed. + int size=xhpcDictBizMapper.countParentNameQuantity(name); + if(size>0){ + return AjaxResult.error("您输入的字符名称已经存在"); + }else { + xhpcDictBizMapper.insertAParentItemToTable(name,code,sort); + } + return AjaxResult.success(); + } + + @Override + @Transactional + public AjaxResult selectDictionaryItem(Long id) { + XhpcDictionary xhpcDictionary=xhpcDictBizMapper.selectADictionaryItem(id); + if(xhpcDictionary==null){ + return AjaxResult.error("该字典不存在"); + } + return AjaxResult.success(xhpcDictionary); + } + + + @Override + @Transactional + public AjaxResult addAChildDictionaryItem(Long parentId, String code, String dictKey, String dictValue,Integer sort) { + + + if(code==null){ + return AjaxResult.error("字典编码不能为空"); + } + code=code.trim(); + if(code.equals("")){ + return AjaxResult.error("字典编码不能为空"); + } + int keySize=xhpcDictBizQuantityCheckMapper.countSameParentChildKeyColumns(parentId,dictKey); + if(keySize>0){ + return AjaxResult.error("您输入的字典键值已经存在"); + } + //Ensuring the parameter is not null. + if(parentId==null){ + return AjaxResult.error("The parentId is null"); + } + if(dictKey==null){ + return AjaxResult.error("字典键值不能为空"); + } + dictKey=dictKey.trim(); + if(dictKey.equals("")){ + return AjaxResult.error("字典键值不能为空"); + } + if(dictValue==null){ + return AjaxResult.error("字典名称不能为空"); + } + dictValue=dictValue.trim(); + if(dictValue.equals("")){ + return AjaxResult.error("字典名称不能为空"); + } + if(sort==null){ + return AjaxResult.error("字典排序不能为空"); + } + //Ensuring sort is bigger than 0; + if(sort<1){ + return AjaxResult.error("字典排序的值不能小于1"); + } + //Ensuring the length of parameter's is correct. + if(dictKey.length()>255){ + return AjaxResult.error("字典键值的长度不能大于255"); + } + if(dictValue.length()>255){ + return AjaxResult.error("字典名称的长度不能大于255"); + } + if(String.valueOf(sort).length()>11){ + return AjaxResult.error("字典排序的长度不能大于11"); + } + //Ensuring value is unique. + int size=xhpcDictBizMapper.countSameParentChildNameColumns(parentId,dictValue); + int sizeFather=xhpcDictBizQuantityCheckMapper.countParentName(dictValue); + if(size>0||sizeFather>0){ + return AjaxResult.error("你输入的字典名称已经存在"); + }else { + xhpcDictBizMapper.insertAChildItemToTable(parentId, code, dictKey, dictValue,sort); + } + return AjaxResult.success(); + } + + @Override + @Transactional + public AjaxResult deleteChildDictionaryItem(Long id) { + int length=xhpcDictBizMapper.deleteChildDictionaryItemById(id); + if(length==0){ + return AjaxResult.error("not exists"); + } + return AjaxResult.success(); + } + + + @Override + @Transactional + public AjaxResult deleteParentItem(Long id) { + + //At first delete father's item. + int size=xhpcDictBizMapper.deleteChildDictionaryItemById(id); + if(size==0){ + return AjaxResult.error("删除失败"); + } + try { + //Deleting their child. + xhpcDictBizMapper.deleteChildItemsFollowParent(id); + } catch (Exception e) { + return AjaxResult.error("删除失败"); + } + return AjaxResult.success(); + } + + @Override + @Transactional + public List getMainItems(String code, String name) { + + return xhpcDictBizMapper.selectParentDictionaryItemsByCodeAndName(code,name); + } + + @Override + @Transactional + public List getDetailsItems(Long parentId,String code, String name) { + + return xhpcDictBizMapper.selectChildDictionaryItemsByCodeAndName(parentId,code,name); + } + + + @Override + @Transactional + public AjaxResult updateMainItem(Long id,String code, String dictValue, Integer sort) { + + //Ensuring the code is valid, it is not a null value or a white value. + if(code==null){ + return AjaxResult.error("字典编码不能为空"); + } + code=code.trim(); + if(code.equals("")){ + return AjaxResult.error("字典编码不能为空"); + } + if(code.length()>255){ + return AjaxResult.error("字符编码长度不能大于255"); + } + //Ensuring the sort is bigger than zero. + if(sort<1){ + return AjaxResult.error("字典排序的值不能小于1"); + } + if(String.valueOf(sort).length()>11){ + return AjaxResult.error("字典排序长度不能大于11"); + } + + if(dictValue==null){ + return AjaxResult.error("字典名称不能为空"); + } + dictValue=dictValue.trim(); + if(dictValue.equals("")){ + return AjaxResult.error("字典名称不能为空"); + } + if(dictValue.length()>255){ + return AjaxResult.error("字符名称不能大于255"); + } + //Ensuring the code and dict_value is unique. + XhpcDictionary xhpcDictionary=xhpcDictBizMapper.selectADictionaryItem(id); + String value=xhpcDictionary.getDictValue(); + String codeValue=xhpcDictionary.getCode(); + + +// Judging the father item whether could insert. + if(!value.equals(dictValue)){ + //Ensuring the name(dict_value) has existed. + int size=xhpcDictBizMapper.countParentNameQuantity(dictValue); + if(size>0){ + return AjaxResult.error("您输入的字典名称已经存在。"); + } + } + if(!codeValue.equals(code)){ + //Ensuring the code whether has existed. + int quantity=xhpcDictBizQuantityCheckMapper.countCodeRows(code); + if(quantity>0){ + return AjaxResult.error("您输入的字典编号已经存在。"); + } + } + xhpcDictBizMapper.updateParentItemByCodeDictValueSort(id, code, dictValue, sort); + //在父级修改了字典编号后,子级也要修改字字典编号与父级保持一致。 + xhpcDictBizMapper.updateChildCodeAfterParentChanged(code,id); + return AjaxResult.success(); + } + + @Override + @Transactional + public AjaxResult updateChildItem(Long parentId,Long id, String value, String key,Integer sort) { + //Ensuring the value is valid. + if(value==null){ + return AjaxResult.error("字典名称不能为空"); + } + value=value.trim(); + if(value.equals("")){ + return AjaxResult.error("字典名称不能为空"); + } + if(value.length()>255){ + return AjaxResult.error("字符名称长度不能大于255"); + } + //Ensuring the key is valid. + if(key==null){ + return AjaxResult.error("字典键值不能为空"); + } + key=key.trim(); + if(key.equals("")){ + return AjaxResult.error("字典键值不能为空"); + } + if(key.length()>255){ + return AjaxResult.error("字符键值不能为空"); + } + if(sort<1){ + return AjaxResult.error("字典排序不能小于1"); + } + if(String.valueOf(sort).length()>11){ + return AjaxResult.error("字典排序长度不能大于11"); + } + XhpcDictionary xhpcDictionary=xhpcDictBizMapper.selectADictionaryItem(id); + System.out.println(xhpcDictionary.getDictKey()); + //Ensuring the key and value is unique. + if(!xhpcDictionary.getDictKey().equals(key)){ + int keySize=xhpcDictBizQuantityCheckMapper.countSameParentChildKeyColumns(parentId,key); + System.out.println(keySize); + if(keySize!=0){ + return AjaxResult.error("您输入的字典键值已经存在。"); + } + } + System.out.println(xhpcDictionary.getDictValue()); + if(!xhpcDictionary.getDictValue().equals(value)){ + int valueSize=xhpcDictBizQuantityCheckMapper.countSameParentChildValueColumns(parentId,value); + System.out.println(valueSize); + if(valueSize!=0){ + return AjaxResult.error("您输入的字典名称已经存在"); + } + } + int i=xhpcDictBizMapper.updateChildItem(id,value,key,sort); + if(i==0){ + return AjaxResult.error("更新失败"); + }else { + return AjaxResult.success(); + } + + } + + + @Override + @Transactional + public AjaxResult deleteChildItems(String ids) { + //Making the String ids into List ids. + List idsList=new ArrayList<>(); + String [] idsArray=ids.split(","); + for(String value:idsArray){ + idsList.add(Long.parseLong(value)); + } + int size=xhpcDictBizMapper.deleteChildItemByIds(idsList); + if(size==0){ + return AjaxResult.error("删除失败"); + }else { + return AjaxResult.success(); + } + } + + @Override + @Transactional + public AjaxResult deleteParentItems(String ids) { + //Making the String ids into List ids. + List idsList=new ArrayList<>(); + String [] idsArray=ids.split(","); + for(String value:idsArray){ + idsList.add(Long.parseLong(value)); + } + //Deleting parent first. + int sizeParent=xhpcDictBizMapper.deleteChildItemByIds(idsList); + if(sizeParent==0){ + return AjaxResult.error("删除失败"); + } + + //Deleting the parent's child. + int sizeChild=xhpcDictBizMapper.deleteChildItemsAfterTheirParentDied(idsList); + if(sizeChild==0){ + return AjaxResult.error("删除失败"); + } + return AjaxResult.success(); + } } diff --git a/xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcDictBizMapper.xml b/xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcDictBizMapper.xml index cc54bef4..db4dca9d 100644 --- a/xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcDictBizMapper.xml +++ b/xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcDictBizMapper.xml @@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -24,4 +24,98 @@ select code, dict_key, dict_value, sort, remark from xhpc_dict_biz where code = #{code} and parent_id > 0 and del_flag = 0 + + + + + + insert into xhpc_dict_biz(dict_value,code,sort) values(#{name},#{code},#{sort}) + + + + + + insert into xhpc_dict_biz(parent_id,code,dict_key,dict_value,sort) values (#{id},#{code},#{dictKey},#{dictValue},#{sore}) + + + + update xhpc_dict_biz set del_flag=1 where dict_biz_id=#{id} + + + + update xhpc_dict_biz set del_flag=1 where parent_id=#{id} + + + + + + + + update xhpc_dict_biz set code=#{code},dict_value=#{dictValue},sort=#{sort} where dict_biz_id=#{id} + + + + update xhpc_dict_biz set code=#{code} where parent_id=#{id} + + + + update xhpc_dict_biz set dict_key=#{key},dict_value=#{value},sort=#{sort} where dict_biz_id=#{id} + + + + update xhpc_dict_biz set del_flag=1 + where + dict_biz_id in + + #{item} + + + + + + + update xhpc_dict_biz set code=#{code} where parent_id=#{id} + + + + update xhpc_dict_biz set del_flag=1 + where + parent_id in + + #{item} + + + + + + + diff --git a/xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcDictQuantityCheckMapper.xml b/xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcDictQuantityCheckMapper.xml new file mode 100644 index 00000000..b082ac9b --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/resources/mapper/XhpcDictQuantityCheckMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + \ No newline at end of file