优化功能模块的接口
This commit is contained in:
@@ -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<String, Object> objectMap = new HashMap<String, Object>();
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<Function> selectByConditionFunction(
|
||||
List<FunctionEx> selectByConditionFunction(
|
||||
@Param("name") String name,
|
||||
@Param("type") String type,
|
||||
@Param("offset") Integer offset,
|
||||
|
||||
@@ -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<Function> select(String name, String type, int offset, int rows)throws Exception {
|
||||
List<Function> list=null;
|
||||
public List<FunctionEx> select(String name, String type, int offset, int rows)throws Exception {
|
||||
List<FunctionEx> 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<Function> list=null;
|
||||
try{
|
||||
list = functionsMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list==null?0:list.size();
|
||||
}
|
||||
|
||||
public List<Function> getRoleFunction(String pNumber)throws Exception {
|
||||
FunctionExample example = new FunctionExample();
|
||||
example.createCriteria().andEnabledEqualTo(true).andParentNumberEqualTo(pNumber)
|
||||
|
||||
@@ -1,36 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jsh.erp.datasource.mappers.FunctionMapperEx">
|
||||
<select id="selectByConditionFunction" parameterType="com.jsh.erp.datasource.entities.FunctionExample" resultMap="com.jsh.erp.datasource.mappers.FunctionMapper.BaseResultMap">
|
||||
select *
|
||||
FROM jsh_function
|
||||
<resultMap extends="com.jsh.erp.datasource.mappers.FunctionMapper.BaseResultMap" id="ResultMapEx" type="com.jsh.erp.datasource.entities.FunctionEx">
|
||||
<result column="parent_name" jdbcType="VARCHAR" property="parentName" />
|
||||
</resultMap>
|
||||
<select id="selectByConditionFunction" parameterType="com.jsh.erp.datasource.entities.FunctionExample"
|
||||
resultMap="ResultMapEx">
|
||||
select fa.*, fb.name parent_name
|
||||
from jsh_function fa
|
||||
left join jsh_function fb on fa.parent_number = fb.number
|
||||
where 1=1
|
||||
<if test="name != null">
|
||||
<bind name="bindName" value="'%'+name+'%'"/>
|
||||
and name like #{bindName}
|
||||
and fa.name like #{bindName}
|
||||
</if>
|
||||
<if test="type != null">
|
||||
and type=#{type}
|
||||
and fa.type=#{type}
|
||||
</if>
|
||||
and ifnull(delete_flag,'0') !='1'
|
||||
order by sort asc
|
||||
and ifnull(fa.delete_flag,'0') !='1'
|
||||
order by fa.sort asc
|
||||
<if test="offset != null and rows != null">
|
||||
limit #{offset},#{rows}
|
||||
</if>
|
||||
</select>
|
||||
<select id="countsByFunction" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(id)
|
||||
FROM jsh_function
|
||||
select
|
||||
count(fa.id)
|
||||
from jsh_function fa
|
||||
left join jsh_function fb on fa.parent_number = fb.number
|
||||
WHERE 1=1
|
||||
<if test="name != null">
|
||||
<bind name="bindName" value="'%'+name+'%'"/>
|
||||
and name like #{bindName}
|
||||
and fa.name like #{bindName}
|
||||
</if>
|
||||
<if test="type != null">
|
||||
and type=#{type}
|
||||
and fa.type=#{type}
|
||||
</if>
|
||||
and ifnull(delete_flag,'0') !='1'
|
||||
and ifnull(fa.delete_flag,'0') !='1'
|
||||
</select>
|
||||
<update id="batchDeleteFunctionByIds">
|
||||
update jsh_function
|
||||
|
||||
Reference in New Issue
Block a user