Browse Source

feat: [试验管理] 增加TFM角色权限

master
memorylkf 1 week ago
parent
commit
6572a4e831
2 changed files with 50 additions and 32 deletions
  1. +28
    -29
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java
  2. +22
    -3
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java

+ 28
- 29
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java View File

@ -185,34 +185,33 @@ public class StudyController extends BaseController
}
/**
* 解锁
* 检查锁定
* @param form
* @return
*/
@RequiresPermissions({"business:study:js"})
@PostMapping("/js")
public AjaxResult js(@RequestBody StudySaveForm form)
@RequiresPermissions({"business:study:sd"})
@PostMapping("/checkSd")
public AjaxResult checkSd(@RequestBody StudySaveForm form)
{
Study study = form.getStudy();
SignForm sign = form.getSign();
if(study==null || sign==null){
if(study==null){
return AjaxResult.error("参数有误");
}
if(study.getId()==null || study.getId().longValue()<=0){
return AjaxResult.error("参数有误");
}
studyService.js(form);
studyService.checkSd(studyService.getById(study.getId()));
return AjaxResult.success();
}
/**
* 解档
* 锁定
* @param form
* @return
*/
@RequiresPermissions({"business:study:jd"})
@PostMapping("/jd")
public AjaxResult jd(@RequestBody StudySaveForm form)
@RequiresPermissions({"business:study:sd"})
@PostMapping("/sd")
public AjaxResult sd(@RequestBody StudySaveForm form)
{
Study study = form.getStudy();
SignForm sign = form.getSign();
@ -222,18 +221,18 @@ public class StudyController extends BaseController
if(study.getId()==null || study.getId().longValue()<=0){
return AjaxResult.error("参数有误");
}
studyService.jd(form);
studyService.sd(form);
return AjaxResult.success();
}
/**
* 借阅
* 解锁
* @param form
* @return
*/
@RequiresPermissions({"business:study:jy"})
@PostMapping("/jy")
public AjaxResult jy(@RequestBody StudySaveForm form)
@RequiresPermissions({"business:study:js"})
@PostMapping("/js")
public AjaxResult js(@RequestBody StudySaveForm form)
{
Study study = form.getStudy();
SignForm sign = form.getSign();
@ -243,38 +242,39 @@ public class StudyController extends BaseController
if(study.getId()==null || study.getId().longValue()<=0){
return AjaxResult.error("参数有误");
}
studyService.jy(form);
studyService.js(form);
return AjaxResult.success();
}
/**
* 检查锁定
* 解档
* @param form
* @return
*/
@RequiresPermissions({"business:study:sd"})
@PostMapping("/checkSd")
public AjaxResult checkSd(@RequestBody StudySaveForm form)
@RequiresPermissions({"business:study:jd"})
@PostMapping("/jd")
public AjaxResult jd(@RequestBody StudySaveForm form)
{
Study study = form.getStudy();
if(study==null){
SignForm sign = form.getSign();
if(study==null || sign==null){
return AjaxResult.error("参数有误");
}
if(study.getId()==null || study.getId().longValue()<=0){
return AjaxResult.error("参数有误");
}
studyService.checkSd(studyService.getById(study.getId()));
studyService.jd(form);
return AjaxResult.success();
}
/**
* 锁定
* 借阅
* @param form
* @return
*/
@RequiresPermissions({"business:study:sd"})
@PostMapping("/sd")
public AjaxResult sd(@RequestBody StudySaveForm form)
@RequiresPermissions({"business:study:jy"})
@PostMapping("/jy")
public AjaxResult jy(@RequestBody StudySaveForm form)
{
Study study = form.getStudy();
SignForm sign = form.getSign();
@ -284,8 +284,7 @@ public class StudyController extends BaseController
if(study.getId()==null || study.getId().longValue()<=0){
return AjaxResult.error("参数有误");
}
studyService.sd(form);
studyService.jy(form);
return AjaxResult.success();
}
}

+ 22
- 3
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java View File

@ -192,6 +192,7 @@ public class StudyServiceImpl extends ServiceImpl implements
if(!info.getStatus().equals(StudyStatusEnum.cg.getValue())){
throw new ServiceException("当前状态不能删除");
}
checkPermit(info);
checkPassword(sign);
studyJcgjService.saveInfo(study.getId(), JcgjlxEnum.lc, JcmcysEnum.red,"删除实验", null,SecurityUtils.getUserId(),SecurityUtils.getNickName(),sign.getRemark());
removeById(study.getId());
@ -208,12 +209,10 @@ public class StudyServiceImpl extends ServiceImpl implements
if(study==null){
throw new ServiceException("信息不存在");
}
if(!study.getCreateBy().equals(SecurityUtils.getUserId().toString())){
throw new ServiceException("SD才能锁定");
}
if(study.getStatus().equals(StudyStatusEnum.ysd.getValue())){
throw new ServiceException("该试验已锁定");
}
checkPermit(study);
String name = baseMapper.queryNotFinishFormName(study.getId());
if(StringUtils.isNoneBlank(name)){
throw new ServiceException("该实验下"+name+"还未结束,请先完成该表单后再进行锁定试验");
@ -235,7 +234,20 @@ public class StudyServiceImpl extends ServiceImpl implements
@Override
@Transactional(rollbackFor = Exception.class)
public void js(StudySaveForm form) {
Study study = form.getStudy();
SignForm sign = form.getSign();
Study info = getById(study.getId());
if(info==null){
throw new ServiceException("信息不存在");
}
if(!info.getStatus().equals(StudyStatusEnum.ysd.getValue())){
throw new ServiceException("当前状态不能解锁");
}
checkPermit(info);
checkPassword(sign);
info.setStatus(StudyStatusEnum.syz.getValue());
studyJcgjService.saveInfo(study.getId(), JcgjlxEnum.lc, JcmcysEnum.blue,"解锁实验", null,SecurityUtils.getUserId(),SecurityUtils.getNickName(),sign.getRemark());
}
@Override
@ -260,4 +272,11 @@ public class StudyServiceImpl extends ServiceImpl implements
}
sysUserService.checkPassword(SecurityUtils.getLoginUser().getSysUser(),sign.getQmrmm(),false);
}
private void checkPermit(Study study){
String tfmRole = "TFM";
if(!AuthUtil.hasRole(tfmRole) && !study.getLeader().equals(SecurityUtils.getUserId())){
throw new ServiceException("没有该试验操作权限");
}
}
}

Loading…
Cancel
Save