diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java index 29515774..efb8499e 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java @@ -10,6 +10,7 @@ import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.functions.FunctionService; import com.jsh.erp.service.userBusiness.UserBusinessService; import com.jsh.erp.utils.BaseResponseInfo; +import com.jsh.erp.utils.ErpInfo; import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.Tools; import io.swagger.annotations.Api; @@ -26,6 +27,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static com.jsh.erp.utils.ResponseJsonUtil.returnJson; + /** * @author ji-sheng-hua jshERP */ @@ -41,6 +44,21 @@ public class FunctionController { @Resource private UserBusinessService userBusinessService; + @GetMapping(value = "/checkIsNumberExist") + @ApiOperation(value = "检查编号是否存在") + public String checkIsNumberExist(@RequestParam Long id, + @RequestParam(value ="number", required = false) String number, + HttpServletRequest request)throws Exception { + Map objectMap = new HashMap(); + int exist = functionService.checkIsNumberExist(id, number); + if(exist > 0) { + objectMap.put("status", true); + } else { + objectMap.put("status", false); + } + return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + } + /** * 根据父编号查询菜单 * @param jsonObject diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/FunctionEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/FunctionEx.java new file mode 100644 index 00000000..c8263e59 --- /dev/null +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/FunctionEx.java @@ -0,0 +1,14 @@ +package com.jsh.erp.datasource.entities; + +public class FunctionEx extends Function { + + private String parentName; + + public String getParentName() { + return parentName; + } + + public void setParentName(String parentName) { + this.parentName = parentName; + } +} \ No newline at end of file diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/FunctionMapperEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/FunctionMapperEx.java index ae76f703..961ce2fc 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/FunctionMapperEx.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/FunctionMapperEx.java @@ -1,6 +1,6 @@ package com.jsh.erp.datasource.mappers; -import com.jsh.erp.datasource.entities.Function; +import com.jsh.erp.datasource.entities.FunctionEx; import org.apache.ibatis.annotations.Param; import java.util.Date; @@ -8,7 +8,7 @@ import java.util.List; public interface FunctionMapperEx { - List selectByConditionFunction( + List selectByConditionFunction( @Param("name") String name, @Param("type") String type, @Param("offset") Integer offset, diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java index 7ef747e1..ce752f6c 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java @@ -3,6 +3,7 @@ package com.jsh.erp.service.functions; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.datasource.entities.Function; +import com.jsh.erp.datasource.entities.FunctionEx; import com.jsh.erp.datasource.entities.FunctionExample; import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.mappers.FunctionMapper; @@ -73,8 +74,8 @@ public class FunctionService { return list; } - public List select(String name, String type, int offset, int rows)throws Exception { - List list=null; + public List select(String name, String type, int offset, int rows)throws Exception { + List list=null; try{ list= functionMapperEx.selectByConditionFunction(name, type, offset, rows); }catch(Exception e){ @@ -164,6 +165,18 @@ public class FunctionService { return list==null?0:list.size(); } + public int checkIsNumberExist(Long id, String number)throws Exception { + FunctionExample example = new FunctionExample(); + example.createCriteria().andIdNotEqualTo(id).andNumberEqualTo(number).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); + List list=null; + try{ + list = functionsMapper.selectByExample(example); + }catch(Exception e){ + JshException.readFail(logger, e); + } + return list==null?0:list.size(); + } + public List getRoleFunction(String pNumber)throws Exception { FunctionExample example = new FunctionExample(); example.createCriteria().andEnabledEqualTo(true).andParentNumberEqualTo(pNumber) diff --git a/jshERP-boot/src/main/resources/mapper_xml/FunctionMapperEx.xml b/jshERP-boot/src/main/resources/mapper_xml/FunctionMapperEx.xml index 7219eac3..11fb1b47 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/FunctionMapperEx.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/FunctionMapperEx.xml @@ -1,36 +1,42 @@ - + select fa.*, fb.name parent_name + from jsh_function fa + left join jsh_function fb on fa.parent_number = fb.number where 1=1 - and name like #{bindName} + and fa.name like #{bindName} - and type=#{type} + and fa.type=#{type} - and ifnull(delete_flag,'0') !='1' - order by sort asc + and ifnull(fa.delete_flag,'0') !='1' + order by fa.sort asc limit #{offset},#{rows} update jsh_function