Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
0fd608fd
Commit
0fd608fd
authored
Jul 28, 2022
by
季圣华
Browse files
优化功能模块的接口
parent
1fce7eeb
Changes
5
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java
View file @
0fd608fd
...
...
@@ -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
...
...
jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/FunctionEx.java
0 → 100644
View file @
0fd608fd
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
jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/FunctionMapperEx.java
View file @
0fd608fd
package
com.jsh.erp.datasource.mappers
;
import
com.jsh.erp.datasource.entities.Function
;
import
com.jsh.erp.datasource.entities.Function
Ex
;
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
<
Function
Ex
>
selectByConditionFunction
(
@Param
(
"name"
)
String
name
,
@Param
(
"type"
)
String
type
,
@Param
(
"offset"
)
Integer
offset
,
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java
View file @
0fd608fd
...
...
@@ -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
<
Function
Ex
>
select
(
String
name
,
String
type
,
int
offset
,
int
rows
)
throws
Exception
{
List
<
Function
Ex
>
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
)
...
...
jshERP-boot/src/main/resources/mapper_xml/FunctionMapperEx.xml
View file @
0fd608fd
<?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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment