feat:企标新权限
This commit is contained in:
@@ -62,6 +62,11 @@ public class FieldCommon {
|
||||
public static final String COLLECTION_FLAG = "collectionFlag";
|
||||
// 查看详情权限标识
|
||||
public static final String DETAIL_FLAG = "detailFlag";
|
||||
// 编辑删除权限标识
|
||||
public static final String EDIT_FLAG = "editFlag";
|
||||
// 创建人字段
|
||||
public static final String CREATE_BY = "create_by";
|
||||
|
||||
// 我的收藏
|
||||
public static final String MY_COLLECTION = "MyCollection";
|
||||
// 主键
|
||||
|
||||
@@ -63,5 +63,7 @@ public class ResultCommon {
|
||||
|
||||
public static final String TASK_HANDLER_ERROR = "task.handler.error"; // 只有处理人可以操作
|
||||
|
||||
public static final String NO_AUTH = "no.auth"; // 只有处理人可以操作
|
||||
|
||||
|
||||
}
|
||||
|
||||
+11
@@ -36,6 +36,7 @@ import com.jero.modules.personal.service.ILawsBrowsingHistoryService;
|
||||
import com.jero.modules.personal.service.ILawsStandardCollectionService;
|
||||
import com.jero.modules.split.entity.SarFileSplitInfoEO;
|
||||
import com.jero.modules.split.service.ISarFileSplitInfoService;
|
||||
import com.jero.modules.sys.utils.UserUtils;
|
||||
import com.jero.modules.system.entity.SysDepart;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
@@ -166,6 +167,8 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
if (module.equals(TableNameEnum.ENTERPRISE_STANDARDS.getValue())) {
|
||||
// 是否能查看详情
|
||||
esAuthUserService.detailFlagSet(infoPage.getRecords());
|
||||
// 是否能编辑删除
|
||||
esAuthUserService.editFlagSet(infoPage.getRecords());
|
||||
}
|
||||
// 是否收藏判断标识
|
||||
collectionFlag(infoPage.getRecords());
|
||||
@@ -1047,6 +1050,14 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
**/
|
||||
@Override
|
||||
public String deleteByIdsAndModule(String ids, String module) {
|
||||
// 如果是企标的话 校验删除的ids是否有权限
|
||||
if (TableNameEnum.ENTERPRISE_STANDARDS.getValue().equals(module)) {
|
||||
boolean auth = esAuthUserService.verifyESDeleteAuth(ids, UserUtils.getUserId());
|
||||
if (!auth) {
|
||||
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.NO_AUTH));
|
||||
}
|
||||
}
|
||||
|
||||
// 获取要操作的表名
|
||||
String tableName = TableNameEnum.getTableName(module);
|
||||
// 获取要删除的id集合
|
||||
|
||||
+12
@@ -16,7 +16,19 @@ public interface EnterpriseStandardAuthUserService extends IService<EnterpriseSt
|
||||
|
||||
void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission);
|
||||
|
||||
/**
|
||||
* 查看详情权限设置
|
||||
* @param records
|
||||
*/
|
||||
void detailFlagSet(List<Map<String, Object>> records);
|
||||
|
||||
/**
|
||||
* 编辑权限设置
|
||||
* @param records
|
||||
*/
|
||||
void editFlagSet(List<Map<String, Object>> records);
|
||||
|
||||
boolean detailPermissionByUser(String standardNumber, String userId, String user);
|
||||
|
||||
boolean verifyESDeleteAuth(String ids, String userId);
|
||||
}
|
||||
|
||||
+78
-12
@@ -18,10 +18,14 @@ import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
|
||||
import com.jero.modules.sys.entity.LawsEnterpriseStandardLevel;
|
||||
import com.jero.modules.sys.service.ILawsEnterpriseStandardLevelService;
|
||||
import com.jero.modules.sys.utils.UserUtils;
|
||||
import com.jero.modules.system.entity.SysDepart;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.service.ISysDepartService;
|
||||
import com.jero.modules.system.service.ISysRoleService;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -45,12 +49,23 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
@Resource
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private ISysDepartService sysDepartService;
|
||||
|
||||
@Resource
|
||||
private ILawsEnterpriseStandardService enterpriseStandardService;
|
||||
|
||||
@Resource
|
||||
private ILawsEnterpriseStandardLevelService standardLevelService;
|
||||
|
||||
@Resource
|
||||
private ISysRoleService sysRoleService;
|
||||
|
||||
// 注入draftDepartName
|
||||
@Value("${draftDepartName}")
|
||||
private String draftDepartName;
|
||||
|
||||
|
||||
@Override
|
||||
public void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission) {
|
||||
List<EnterpriseStandardAuthUser> esAuthUsers = new ArrayList<>();
|
||||
@@ -74,6 +89,7 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
SysUser currentUser = sysUserService.getById(UserUtils.getUserId());
|
||||
String userId = currentUser.getId();
|
||||
String deptId = currentUser.getDepartIds();
|
||||
SysDepart dept = sysDepartService.getById(deptId);
|
||||
List<String> standardIds = new ArrayList<>();
|
||||
records.forEach(kv -> standardIds.add(String.valueOf(kv.get(FieldCommon.ID))));
|
||||
List<LawsEnterpriseStandard> esList = enterpriseStandardService.list(new LambdaQueryWrapper<LawsEnterpriseStandard>()
|
||||
@@ -103,11 +119,22 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
List<LawsEnterpriseStandardLevel> standardLevelList = standardLevelService.list();
|
||||
List<String> levelDeptIds = standardLevelList.stream().map(LawsEnterpriseStandardLevel::getDeptId).collect(Collectors.toList());
|
||||
|
||||
// 起草部门有所有企标的查看权限
|
||||
if (dept.getDepartName().equals(draftDepartName)) {
|
||||
// 全部设置为有权限
|
||||
records.forEach(kv -> kv.put(FieldCommon.DETAIL_FLAG, true));
|
||||
}
|
||||
for (Map<String, Object> map : records) {
|
||||
String standardId = (String) map.get(FieldCommon.ID);
|
||||
LawsEnterpriseStandard es = esMap.get(standardId);
|
||||
// 等级分类
|
||||
String gradeClassification = es.getGradeClassification();
|
||||
String mainDraftUser = es.getMainDraftingUser();
|
||||
// 主起草人可以看
|
||||
if (userId.equals(mainDraftUser)) {
|
||||
map.put(FieldCommon.DETAIL_FLAG, true);
|
||||
continue;
|
||||
}
|
||||
// 全公司可以看
|
||||
if (gradeClassification.equals("1")) {
|
||||
map.put(FieldCommon.DETAIL_FLAG, true);
|
||||
@@ -132,21 +159,40 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
map.put(FieldCommon.DETAIL_FLAG, true);
|
||||
continue;
|
||||
}
|
||||
// 起草部门
|
||||
String mainDraftDeptId = es.getMainDraftingUnit();
|
||||
if (deptId.equals(mainDraftDeptId)) {
|
||||
map.put(FieldCommon.DETAIL_FLAG, true);
|
||||
continue;
|
||||
}
|
||||
map.put(FieldCommon.DETAIL_FLAG, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editFlagSet(List<Map<String, Object>> records) {
|
||||
// 只有创建人和管理员才有维护的权限
|
||||
String userId = UserUtils.getUserId();
|
||||
SysUser currentUser = sysUserService.getById(userId);
|
||||
if (currentUser.getRoleCode().equals(FieldCommon.ROLE_ADMIN)) {
|
||||
records.forEach(kv -> kv.put(FieldCommon.EDIT_FLAG, true));
|
||||
return;
|
||||
}
|
||||
for (Map<String, Object> map : records) {
|
||||
String createBy = (String) map.get(FieldCommon.CREATE_BY);
|
||||
if (userId.equals(createBy)) {
|
||||
map.put(FieldCommon.EDIT_FLAG, true);
|
||||
} else {
|
||||
map.put(FieldCommon.EDIT_FLAG, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean detailPermissionByUser(String standardId, String standardNumber, String userId) {
|
||||
SysUser user = sysUserService.getById(userId);
|
||||
String deptId = user.getDepartIds();
|
||||
SysDepart dept = sysDepartService.getById(deptId);
|
||||
// 起草部门有全部企标的查看权限
|
||||
if (dept.getDepartName().equals(draftDepartName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(standardId) && StringUtils.isBlank(standardNumber)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "id和标准号不能同时为空");
|
||||
}
|
||||
@@ -168,12 +214,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
if (levelDeptIds.contains(deptId)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// 主起草部门
|
||||
String mainDraftDeptId = es.getMainDraftingUnit();
|
||||
if (deptId.equals(mainDraftDeptId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询临时授权人员
|
||||
@@ -197,6 +237,32 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否有删除权限
|
||||
* @param ids
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public boolean verifyESDeleteAuth(String ids, String userId) {
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "ids不能为空");
|
||||
}
|
||||
// 管理员有所有权限
|
||||
SysUser user = sysUserService.getById(userId);
|
||||
if (user.getRoleCode().equals("admin")) {
|
||||
return true;
|
||||
}
|
||||
// 创建人可以删除
|
||||
List<LawsEnterpriseStandard> list = enterpriseStandardService.list(new LambdaQueryWrapper<LawsEnterpriseStandard>().in(LawsEnterpriseStandard::getId, ids));
|
||||
// 如果不是创建人,则直接返回false
|
||||
for (LawsEnterpriseStandard es : list) {
|
||||
if (!es.getCreateBy().equals(userId)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user