Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-fb
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王衍超
cloud-fb
Commits
30623c6d
Commit
30623c6d
authored
Mar 16, 2021
by
杨清松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
岗位管理名称重复校验
parent
9629f741
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
121 additions
and
11 deletions
+121
-11
PositionDao.java
...biz/src/main/java/com/xyst/dinas/biz/dao/PositionDao.java
+3
-1
BizErrorCodeEnum.java
...java/com/xyst/dinas/biz/enumeration/BizErrorCodeEnum.java
+31
-0
PositionDaoImpl.java
...java/com/xyst/dinas/biz/internal/dao/PositionDaoImpl.java
+19
-4
PositionServiceImpl.java
.../xyst/dinas/biz/internal/service/PositionServiceImpl.java
+39
-2
PositionService.java
...main/java/com/xyst/dinas/biz/service/PositionService.java
+3
-1
PositionController.java
.../main/java/com/xyst/dinas/biz/web/PositionController.java
+26
-3
No files found.
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/dao/PositionDao.java
View file @
30623c6d
...
...
@@ -15,5 +15,7 @@ public interface PositionDao {
List
<
KObject
>
queryPositionByDept
(
UUID
uuid
);
List
<
KObject
>
queryStaffByPosition
(
String
id
);
List
<
KObject
>
queryStaffByPosition
(
String
name
,
UUID
uuid
);
List
<
KObject
>
queryPositionByName
(
String
name
,
UUID
uuid
);
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/enumeration/BizErrorCodeEnum.java
0 → 100644
View file @
30623c6d
package
com
.
xyst
.
dinas
.
biz
.
enumeration
;
import
com.beecode.inz.common.ErrorCode
;
public
enum
BizErrorCodeEnum
implements
ErrorCode
{
POSTITION_NAME_REPEATED
(
"007019001"
,
"岗位名称重复"
);
private
String
code
;
private
String
description
;
BizErrorCodeEnum
(
String
code
,
String
description
)
{
this
.
code
=
code
;
this
.
description
=
description
;
}
@Override
public
String
getCode
()
{
return
code
;
}
@Override
public
String
getDescription
()
{
return
description
;
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/internal/dao/PositionDaoImpl.java
View file @
30623c6d
...
...
@@ -26,7 +26,7 @@ public class PositionDaoImpl implements PositionDao, PositionConstant {
@Override
public
KObject
load
(
UUID
id
)
{
return
(
KObject
)
template
.
load
(
ENTITY
,
id
);
return
(
KObject
)
template
.
get
(
ENTITY
,
id
);
}
@Override
...
...
@@ -48,13 +48,28 @@ public class PositionDaoImpl implements PositionDao, PositionConstant {
}
@Override
public
List
<
KObject
>
queryStaffByPosition
(
String
i
d
)
{
public
List
<
KObject
>
queryStaffByPosition
(
String
name
,
UUID
departmentI
d
)
{
return
(
List
<
KObject
>)
template
.
execute
(
new
HibernateCallback
<
List
<
KObject
>>()
{
@SuppressWarnings
(
"unchecked"
)
@Override
public
List
<
KObject
>
doInHibernate
(
Session
session
)
throws
HibernateException
{
Query
<
KObject
>
query
=
session
.
createQuery
(
"from "
+
STAFF
+
" where duty =:id"
,
KObject
.
class
);
query
.
setParameter
(
"id"
,
id
);
Query
<
KObject
>
query
=
session
.
createQuery
(
"from "
+
STAFF
+
" where duty =:name and department.id=:departmentId "
,
KObject
.
class
);
query
.
setParameter
(
"name"
,
name
);
query
.
setParameter
(
"departmentId"
,
departmentId
);
return
query
.
getResultList
();
}
});
}
@Override
public
List
<
KObject
>
queryPositionByName
(
String
name
,
UUID
deptId
)
{
return
(
List
<
KObject
>)
template
.
execute
(
new
HibernateCallback
<
List
<
KObject
>>()
{
@SuppressWarnings
(
"unchecked"
)
@Override
public
List
<
KObject
>
doInHibernate
(
Session
session
)
throws
HibernateException
{
Query
<
KObject
>
query
=
session
.
createQuery
(
"from "
+
ENTITY
+
" where (discard is null or discard = 0) and name =:name and regionalCompany.id = :deptId "
,
KObject
.
class
);
query
.
setParameter
(
"name"
,
name
);
query
.
setParameter
(
"deptId"
,
deptId
);
return
query
.
getResultList
();
}
});
...
...
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/internal/service/PositionServiceImpl.java
View file @
30623c6d
...
...
@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.transaction.annotation.Transactional
;
import
com.beecode.amino.core.Amino
;
import
com.beecode.bap.staff.service.StaffService
;
import
com.beecode.bcp.core.context.AminoContextHolder
;
import
com.beecode.bcp.type.KClass
;
import
com.beecode.bcp.type.KObject
;
...
...
@@ -24,6 +25,9 @@ public class PositionServiceImpl implements PositionService, PositionConstant {
@Autowired
private
PositionDao
positionDao
;
@Autowired
private
StaffService
staffService
;
@Override
@Transactional
public
Object
saveAndUpdate
(
JSONObject
jsonObject
)
{
...
...
@@ -44,6 +48,25 @@ public class PositionServiceImpl implements PositionService, PositionConstant {
}
else
{
//编辑
KObject
kObject
=
positionDao
.
load
(
UUID
.
fromString
(
jsonObject
.
getString
(
"id"
)));
//如果岗位名称更改,更改已经关联的岗位名称
if
(!
kObject
.
getString
(
"name"
).
equals
(
jsonObject
.
getString
(
"name"
)))
{
List
<
KObject
>
allStaffByDeptList
=
staffService
.
getAllByDept
(
department
.
getUuid
(
"id"
));
if
(
allStaffByDeptList
.
size
()
>
0
&&
allStaffByDeptList
!=
null
)
{
for
(
int
i
=
0
;
i
<
allStaffByDeptList
.
size
();
i
++)
{
KObject
staffByDept
=
allStaffByDeptList
.
get
(
i
);
//如果岗位不为空
if
(
StringUtils
.
isNotEmpty
(
staffByDept
.
getString
(
"name"
)))
{
if
(
kObject
.
getString
(
"name"
).
equals
(
staffByDept
.
getString
(
"duty"
)))
{
//编辑员工岗位
staffByDept
.
set
(
"duty"
,
jsonObject
.
getString
(
"name"
));
staffService
.
modify
(
staffByDept
);
}
}
}
}
}
kObject
.
set
(
"modifyTime"
,
new
Date
());
kObject
.
set
(
"modifier"
,
staff
);
kObject
.
set
(
"name"
,
jsonObject
.
getString
(
"name"
));
...
...
@@ -66,12 +89,26 @@ public class PositionServiceImpl implements PositionService, PositionConstant {
}
@Override
public
Object
queryPositionIsUse
(
String
id
)
{
List
<
KObject
>
staffList
=
positionDao
.
queryStaffByPosition
(
id
);
public
Object
queryPositionIsUse
(
String
name
)
{
KObject
staff
=
AminoContextHolder
.
getContext
().
getStaff
();
List
<
KObject
>
staffList
=
positionDao
.
queryStaffByPosition
(
name
,
staff
.
get
(
"department"
).
getUuid
(
"id"
));
if
(
staffList
!=
null
&&
staffList
.
size
()
>
0
)
{
return
ResponseObj
.
error
(
"该岗位已经被使用,不支持删除操作"
);
}
return
ResponseObj
.
success
();
}
@Override
public
Boolean
verifyPositionName
(
String
name
)
{
KObject
staff
=
AminoContextHolder
.
getContext
().
getStaff
();
//当前登录人所在区域公司
KObject
department
=
staff
.
get
(
"department"
);
List
<
KObject
>
list
=
positionDao
.
queryPositionByName
(
name
,
department
.
getUuid
(
"id"
));
Boolean
flag
=
false
;
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
flag
=
true
;
}
return
flag
;
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/service/PositionService.java
View file @
30623c6d
...
...
@@ -10,6 +10,8 @@ public interface PositionService {
Object
queryPositionByDept
();
Object
queryPositionIsUse
(
String
id
);
Object
queryPositionIsUse
(
String
name
);
Boolean
verifyPositionName
(
String
name
);
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/web/PositionController.java
View file @
30623c6d
...
...
@@ -8,9 +8,13 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.beecode.inz.basis.team.pojo.ResponseObj
;
import
com.beecode.inz.common.exception.BusinessException
;
import
com.xyst.dinas.biz.enumeration.BizErrorCodeEnum
;
import
com.xyst.dinas.biz.service.PositionService
;
@RestController
...
...
@@ -45,8 +49,27 @@ public class PositionController {
* @throws
*/
@ResponseBody
@RequestMapping
(
value
=
"/biz/position/queryPositionIsUse/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
queryPositionIsUse
(
@PathVariable
(
"id"
)
String
id
)
{
return
positionService
.
queryPositionIsUse
(
id
);
@RequestMapping
(
value
=
"/biz/position/queryPositionIsUse/{name}"
,
method
=
RequestMethod
.
GET
)
public
Object
queryPositionIsUse
(
@PathVariable
(
"name"
)
String
name
)
{
return
positionService
.
queryPositionIsUse
(
name
);
}
/**
* @Description: 岗位名称校验重复
* @param id
* @return return_type
* @throws
*/
@ResponseBody
@RequestMapping
(
value
=
"/biz/position/verifyPositionName"
,
method
=
RequestMethod
.
GET
)
public
Object
verifyPositionName
(
@RequestParam
(
"name"
)
String
name
)
{
Boolean
flag
=
positionService
.
verifyPositionName
(
name
);
if
(
flag
)
{
//throw new BusinessException("岗位名称重复", BizErrorCodeEnum.POSTITION_NAME_REPEATED);
//throw new RuntimeException("岗位名称重复");
return
ResponseObj
.
error
(
"岗位名称重复"
);
}
return
null
;
}
}
Write
Preview
Markdown
is supported
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