|
@@ -24,8 +24,10 @@ import org.jeecg.modules.system.app.vo.staff.StaffResponseVO;
|
|
|
import org.jeecg.modules.system.app.vo.staff.StaffSaveVO;
|
|
|
import org.jeecg.modules.system.app.vo.staff.StaffVO;
|
|
|
import org.jeecg.modules.system.entity.SysDepart;
|
|
|
+import org.jeecg.modules.system.entity.SysRole;
|
|
|
import org.jeecg.modules.system.entity.SysUser;
|
|
|
import org.jeecg.modules.system.service.ISysDepartService;
|
|
|
+import org.jeecg.modules.system.service.ISysRoleService;
|
|
|
import org.jeecg.modules.system.service.ISysUserService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.BeansException;
|
|
@@ -57,6 +59,8 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
private BaseCommonService baseCommonService;
|
|
|
@Autowired
|
|
|
private ISysDepartService sysDepartService;
|
|
|
+ @Autowired
|
|
|
+ private ISysRoleService iSysRoleService;
|
|
|
|
|
|
/**
|
|
|
* 分页列表查询
|
|
@@ -76,7 +80,7 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
HttpServletRequest req) {
|
|
|
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
- Page<AppInstructor> page = new Page<AppInstructor>(pageNo, pageSize);
|
|
|
+ Page<StaffResponseVO> page = new Page<StaffResponseVO>(pageNo, pageSize);
|
|
|
IPage<StaffResponseVO> pageList = appInstructorService.findPage(page, staffRequestVO,loginUser.getOrgCode());
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
@@ -102,8 +106,18 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
if (StringUtils.isEmpty(staffSaveVO.getSelecteddeparts())){
|
|
|
return Result.error("所属部门为空");
|
|
|
}
|
|
|
+
|
|
|
+ SysUser sysUser = sysUserService.findByUserName(staffSaveVO.getUsername());
|
|
|
+ if (sysUser!=null){
|
|
|
+ return Result.error("该登录账号已存在");
|
|
|
+ }
|
|
|
+ SysRole sysRole = iSysRoleService.getById(staffSaveVO.getSelectedroles());
|
|
|
+ if (sysRole==null||StringUtils.isEmpty(sysRole.getRoleCode())){
|
|
|
+ return Result.error("未查询到角色信息");
|
|
|
+ }
|
|
|
SysDepart departById =null;
|
|
|
- if (staffSaveVO.getSelectedroles().indexOf("instructor")==0){
|
|
|
+
|
|
|
+ if (sysRole.getRoleCode().indexOf("instructor")==0){
|
|
|
if (staffSaveVO.getSelecteddeparts().contains(",")){
|
|
|
return Result.error("该角色涉及教练,不允许多部门");
|
|
|
}
|
|
@@ -117,6 +131,9 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
}
|
|
|
departById = sysDepartService.getDepartById(dept);
|
|
|
}
|
|
|
+ if (departById==null){
|
|
|
+ return Result.error("未查询到部门信息");
|
|
|
+ }
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
try {
|
|
|
BeanUtils.copyProperties(staffSaveVO,user);
|
|
@@ -139,11 +156,20 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
log.error(e.getMessage(), e);
|
|
|
return Result.error("添加失败!");
|
|
|
}
|
|
|
- BeanUtils.copyProperties(staffSaveVO,appInstructor);
|
|
|
- appInstructor.setId(UuidUtils.getUUID());
|
|
|
- appInstructor.setUserId(user.getId());
|
|
|
- appInstructor.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
- appInstructorService.save(appInstructor);
|
|
|
+ if (sysRole.getRoleCode().indexOf("instructor")==0){
|
|
|
+ BeanUtils.copyProperties(staffSaveVO,appInstructor);
|
|
|
+ if (appInstructor.getStatus().equals(1)){
|
|
|
+ appInstructor.setStatus(0);
|
|
|
+ }else {
|
|
|
+ appInstructor.setStatus(1);
|
|
|
+ }
|
|
|
+ appInstructor.setId(UuidUtils.getUUID());
|
|
|
+ appInstructor.setUserId(user.getId());
|
|
|
+ appInstructor.setOrgCode(departById.getOrgCode());
|
|
|
+ appInstructor.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ appInstructorService.save(appInstructor);
|
|
|
+ }
|
|
|
+
|
|
|
} catch (BeansException e) {
|
|
|
e.getMessage();
|
|
|
return Result.error("添加失败!");
|
|
@@ -171,6 +197,13 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
if (staffVO==null){
|
|
|
return Result.error("编辑失败!未查询到需要编辑的员工信息。");
|
|
|
}
|
|
|
+
|
|
|
+ if (!(StringUtils.isNotEmpty(staffVO.getUsername())&&staffVO.getUsername().equals(staffSaveVO.getUsername()))){
|
|
|
+ SysUser sysUserO = sysUserService.findByUserName(staffSaveVO.getUsername());
|
|
|
+ if (sysUserO!=null){
|
|
|
+ return Result.error("该登录账号已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
if (StringUtils.isEmpty(staffVO.getStaffId())){
|
|
|
return Result.error("编辑失败!未知员工信息");
|
|
|
}
|
|
@@ -180,8 +213,12 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
if (StringUtils.isEmpty(staffSaveVO.getSelecteddeparts())){
|
|
|
return Result.error("所属部门为空");
|
|
|
}
|
|
|
+ SysRole sysRole = iSysRoleService.getById(staffSaveVO.getSelectedroles());
|
|
|
+ if (sysRole==null||StringUtils.isEmpty(sysRole.getRoleCode())){
|
|
|
+ return Result.error("未查询到角色信息");
|
|
|
+ }
|
|
|
SysDepart departById =null;
|
|
|
- if (staffSaveVO.getSelectedroles().indexOf("instructor")==0){
|
|
|
+ if (sysRole.getRoleCode().indexOf("instructor")==0){
|
|
|
if (staffSaveVO.getSelecteddeparts().contains(",")){
|
|
|
return Result.error("该角色涉及教练,不允许多部门");
|
|
|
}
|
|
@@ -195,6 +232,9 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
}
|
|
|
departById = sysDepartService.getDepartById(dept);
|
|
|
}
|
|
|
+ if (departById==null){
|
|
|
+ return Result.error("未查询到部门信息");
|
|
|
+ }
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
SysUser sysUser = new SysUser();
|
|
|
BeanUtils.copyProperties(staffSaveVO,sysUser);
|
|
@@ -206,21 +246,39 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
boolean fal=StringUtils.isNotEmpty(staffVO.getInstructorId());
|
|
|
AppInstructor appInstructor = new AppInstructor();
|
|
|
BeanUtils.copyProperties(staffSaveVO,appInstructor);
|
|
|
- if (staffSaveVO.getSelectedroles().indexOf("instructor")==0&&fal){
|
|
|
+ if (sysRole.getRoleCode().indexOf("instructor")==0&&fal){
|
|
|
appInstructor.setId(staffVO.getInstructorId());
|
|
|
appInstructor.setUpdateBy(loginUser.getUsername());
|
|
|
appInstructor.setUpdateTime(new Date());
|
|
|
+ if (staffSaveVO.getStatus().equals(1)){
|
|
|
+ appInstructor.setStatus(0);
|
|
|
+ }else {
|
|
|
+ appInstructor.setStatus(1);
|
|
|
+ }
|
|
|
+ appInstructor.setOrgCode(departById.getOrgCode());
|
|
|
appInstructorService.updateById(appInstructor);
|
|
|
- }else if (staffSaveVO.getSelectedroles().indexOf("instructor")==0&&!fal){
|
|
|
+ }else if (sysRole.getRoleCode().indexOf("instructor")==0&&!fal){
|
|
|
appInstructor.setId(UuidUtils.getUUID());
|
|
|
appInstructor.setUserId(sysUser.getId());
|
|
|
appInstructor.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ if (staffSaveVO.getStatus().equals(1)){
|
|
|
+ appInstructor.setStatus(0);
|
|
|
+ }else {
|
|
|
+ appInstructor.setStatus(1);
|
|
|
+ }
|
|
|
+ appInstructor.setOrgCode(departById.getOrgCode());
|
|
|
appInstructorService.save(appInstructor);
|
|
|
- }else if (staffSaveVO.getSelectedroles().indexOf("instructor")!=0&&fal){
|
|
|
+ }else if (sysRole.getRoleCode().indexOf("instructor")!=0&&fal){
|
|
|
appInstructor.setId(staffVO.getInstructorId());
|
|
|
appInstructor.setDelFlag(CommonConstant.DEL_FLAG_1);
|
|
|
appInstructor.setUpdateBy(loginUser.getUsername());
|
|
|
appInstructor.setUpdateTime(new Date());
|
|
|
+ if (staffSaveVO.getStatus().equals(1)){
|
|
|
+ appInstructor.setStatus(0);
|
|
|
+ }else {
|
|
|
+ appInstructor.setStatus(1);
|
|
|
+ }
|
|
|
+ appInstructor.setOrgCode(departById.getOrgCode());
|
|
|
appInstructorService.updateById(appInstructor);
|
|
|
}
|
|
|
} catch (BeansException e) {
|
|
@@ -245,7 +303,7 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
try {
|
|
|
StaffVO staffVO =sysUserService.findByUserIdStaff(id);
|
|
|
if (staffVO==null){
|
|
|
- return Result.OK("删除失败!未查询到信息");
|
|
|
+ return Result.error("删除失败!未查询到信息");
|
|
|
}
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
SysUser sysUser = new SysUser();
|
|
@@ -253,14 +311,20 @@ public class AppInstructorController extends JeecgController<AppInstructor, IApp
|
|
|
sysUser.setDelFlag(CommonConstant.DEL_FLAG_1);
|
|
|
sysUser.setUpdateBy(loginUser.getUsername());
|
|
|
sysUser.setUpdateTime(new Date());
|
|
|
- sysUserService.updateById(sysUser);
|
|
|
+ Integer i=sysUserService.updateDelStatus(sysUser);
|
|
|
+ if (i<1){
|
|
|
+ return Result.error("删除失败!");
|
|
|
+ }
|
|
|
if (StringUtils.isNotEmpty(staffVO.getInstructorId())){
|
|
|
AppInstructor appInstructor = new AppInstructor();
|
|
|
appInstructor.setId(staffVO.getInstructorId());
|
|
|
appInstructor.setDelFlag(CommonConstant.DEL_FLAG_1);
|
|
|
appInstructor.setUpdateBy(loginUser.getUsername());
|
|
|
appInstructor.setUpdateTime(new Date());
|
|
|
- appInstructorService.updateById(appInstructor);
|
|
|
+ i=appInstructorService.updateDelStatus(appInstructor);
|
|
|
+ if (i<1){
|
|
|
+ return Result.error("删除失败!");
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.getMessage();
|