|
|
@ -11,6 +11,7 @@ import com.spring.modules.lab.vo.LabSubmitVo; |
|
|
import com.spring.modules.oss.entity.SysOssEntity; |
|
|
import com.spring.modules.oss.entity.SysOssEntity; |
|
|
import com.spring.modules.oss.service.SysOssService; |
|
|
import com.spring.modules.oss.service.SysOssService; |
|
|
import com.spring.modules.sift.vo.QuerySavedVo; |
|
|
import com.spring.modules.sift.vo.QuerySavedVo; |
|
|
|
|
|
import com.spring.modules.sys.dao.SysMenuDao; |
|
|
import com.spring.modules.sys.entity.SysUserEntity; |
|
|
import com.spring.modules.sys.entity.SysUserEntity; |
|
|
import org.apache.commons.lang.StringUtils; |
|
|
import org.apache.commons.lang.StringUtils; |
|
|
import org.apache.shiro.SecurityUtils; |
|
|
import org.apache.shiro.SecurityUtils; |
|
|
@ -41,6 +42,9 @@ public class LabController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private TransNoControlService transNoControlService; |
|
|
private TransNoControlService transNoControlService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SysMenuDao sysMenuDao; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 列表查询 |
|
|
* 列表查询 |
|
|
*/ |
|
|
*/ |
|
|
@ -240,6 +244,9 @@ public class LabController { |
|
|
if (!"草稿".equals(exists.getStatus())) { |
|
|
if (!"草稿".equals(exists.getStatus())) { |
|
|
return R.error("仅草稿状态的单据允许删除"); |
|
|
return R.error("仅草稿状态的单据允许删除"); |
|
|
} |
|
|
} |
|
|
|
|
|
if (!canDeleteLabByApplicantOrSuperAdmin(exists)) { |
|
|
|
|
|
return R.error("仅申请人本人或超级管理员允许删除"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
QueryWrapper<LabEntity> deleteWrapper = new QueryWrapper<>(); |
|
|
QueryWrapper<LabEntity> deleteWrapper = new QueryWrapper<>(); |
|
|
deleteWrapper.eq("site", lab.getSite()).eq("reference_no", lab.getReferenceNo()); |
|
|
deleteWrapper.eq("site", lab.getSite()).eq("reference_no", lab.getReferenceNo()); |
|
|
@ -258,4 +265,18 @@ public class LabController { |
|
|
SysUserEntity user = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
SysUserEntity user = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
return user == null ? "" : user.getUsername(); |
|
|
return user == null ? "" : user.getUsername(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean canDeleteLabByApplicantOrSuperAdmin(LabEntity exists) { |
|
|
|
|
|
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
|
if (currentUser == null) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
boolean isSuperAdmin = !sysMenuDao.checkSuperAdmin(currentUser.getUserId()).isEmpty(); |
|
|
|
|
|
if (isSuperAdmin) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
String currentUserName = StringUtils.trimToEmpty(currentUser.getUsername()); |
|
|
|
|
|
String applicant = exists == null ? "" : StringUtils.trimToEmpty(exists.getApplicant()); |
|
|
|
|
|
return StringUtils.equals(currentUserName, applicant); |
|
|
|
|
|
} |
|
|
} |
|
|
} |