feat: 根据是否适用校验删除权限
This commit is contained in:
@@ -150,5 +150,8 @@ public class FieldCommon {
|
||||
// 草案
|
||||
public static final String FILE_DRAFT = "draft";
|
||||
public static final String DEL_FLAG = "del_flag";
|
||||
public static final String TRY_FLAG = "try_flag";
|
||||
public static final String RELEASE_DATE = "release_date";
|
||||
public static final String TRIAL_PERIOD = "trial_period";
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -175,8 +175,10 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
if (module.equals(TableNameEnum.ENTERPRISE_STANDARDS.getValue())) {
|
||||
// 是否能查看详情
|
||||
esAuthUserService.detailFlagSet(infoPage.getRecords());
|
||||
// 是否能编辑删除
|
||||
// 是否能编辑
|
||||
esAuthUserService.editFlagSet(infoPage.getRecords());
|
||||
// 是否能删除
|
||||
esAuthUserService.delFlagSet(infoPage.getRecords());
|
||||
}
|
||||
// 是否收藏判断标识
|
||||
collectionFlag(infoPage.getRecords());
|
||||
|
||||
+6
@@ -28,6 +28,12 @@ public interface EnterpriseStandardAuthUserService extends IService<EnterpriseSt
|
||||
*/
|
||||
void editFlagSet(List<Map<String, Object>> records);
|
||||
|
||||
/**
|
||||
* 删除权限设置
|
||||
* @param records
|
||||
*/
|
||||
void delFlagSet(List<Map<String, Object>> records);
|
||||
|
||||
boolean detailPermissionByUser(String standardNumber, String userId, String user);
|
||||
|
||||
boolean verifyESDeleteAuth(String ids, String userId);
|
||||
|
||||
+72
@@ -1,6 +1,7 @@
|
||||
package com.jero.modules.laws.enterprise.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
@@ -181,6 +182,77 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delFlagSet(List<Map<String, Object>> records) {
|
||||
String userId = UserUtils.getUserId();
|
||||
SysUser currentUser = sysUserService.getById(userId);
|
||||
List<String> standardIds = new ArrayList<>();
|
||||
String username = currentUser.getUsername();
|
||||
records.forEach(kv -> standardIds.add(String.valueOf(kv.get(FieldCommon.ID))));
|
||||
List<LawsEnterpriseStandard> esList = enterpriseStandardService.list(new LambdaQueryWrapper<LawsEnterpriseStandard>()
|
||||
.in(CollUtil.isNotEmpty(standardIds), LawsEnterpriseStandard::getId, standardIds)
|
||||
.eq(LawsEnterpriseStandard::getDelFlag, YesOrNoEnum.NO.getValue()));
|
||||
Map<String, LawsEnterpriseStandard> esMap = esList.stream().collect(Collectors.toMap(LawsEnterpriseStandard::getId, e -> e));
|
||||
|
||||
// 设置是否适用
|
||||
records.forEach(kv -> kv.put(FieldCommon.TRY_FLAG, esMap.get(kv.get(FieldCommon.ID)).getTryFlag() == null ? "0" : esMap.get(kv.get(FieldCommon.ID)).getTryFlag()));
|
||||
records.forEach(kv -> kv.put(FieldCommon.RELEASE_DATE, esMap.get(kv.get(FieldCommon.ID)).getReleaseDate()));
|
||||
records.forEach(kv -> kv.put(FieldCommon.TRIAL_PERIOD, esMap.get(kv.get(FieldCommon.ID)).getTrialPeriod()));
|
||||
// 只有试用期的企标才能删除
|
||||
|
||||
Date currentDate = new Date();
|
||||
// 获取当前用户的角色roleCode
|
||||
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
|
||||
// 管理员能够删除所有试用期的企标
|
||||
if (roleList != null && roleList.contains(FieldCommon.ROLE_ADMIN)) {
|
||||
for (Map<String, Object> map : records) {
|
||||
String tryFlag = String.valueOf(map.get(FieldCommon.TRY_FLAG));
|
||||
if (tryFlag.equals(YesOrNoEnum.NO.getValue())) {
|
||||
map.put(FieldCommon.DEL_FLAG, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
Date releaseDate = (Date) map.get(FieldCommon.RELEASE_DATE);
|
||||
int trialPeriodMonths = Integer.parseInt(String.valueOf(map.get(FieldCommon.TRIAL_PERIOD))); // 将试用周期转换为天数
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(releaseDate);
|
||||
calendar.add(Calendar.MONTH, trialPeriodMonths); // 将试用周期加到发布日期上
|
||||
Date trialEndDate = calendar.getTime(); // 获取试用期结束日期
|
||||
|
||||
// 在适用周期之内的可以删除
|
||||
if (tryFlag.equals(YesOrNoEnum.YES.getValue()) && currentDate.compareTo(trialEndDate) <= 0) {
|
||||
map.put(FieldCommon.DEL_FLAG, true);
|
||||
} else {
|
||||
map.put(FieldCommon.DEL_FLAG, false);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建人只能删除自己的试用期的企标
|
||||
for (Map<String, Object> map : records) {
|
||||
String createBy = (String) map.get(FieldCommon.CREATE_BY);
|
||||
String tryFlag = String.valueOf(map.get(FieldCommon.TRY_FLAG));
|
||||
if (tryFlag.equals(YesOrNoEnum.NO.getValue())) {
|
||||
map.put(FieldCommon.DEL_FLAG, false);
|
||||
continue;
|
||||
}
|
||||
Date releaseDate = (Date) map.get(FieldCommon.RELEASE_DATE);
|
||||
int trialPeriodMonths = Integer.parseInt(String.valueOf(map.get(FieldCommon.TRIAL_PERIOD))); // 将试用周期转换为天数
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(releaseDate);
|
||||
calendar.add(Calendar.MONTH, trialPeriodMonths); // 将试用周期加到发布日期上
|
||||
Date trialEndDate = calendar.getTime(); // 获取试用期结束日期
|
||||
if (username.equals(createBy) && tryFlag.equals(YesOrNoEnum.YES.getValue())
|
||||
&& currentDate.compareTo(trialEndDate) <= 0 ) {
|
||||
map.put(FieldCommon.DEL_FLAG, true);
|
||||
} else {
|
||||
map.put(FieldCommon.DEL_FLAG, false);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean detailPermissionByUser(String standardId, String standardNumber, String userId) {
|
||||
List<DepartIdModel> departIdModels = sysUserDepartService.queryDepartIdsOfUser(userId);
|
||||
|
||||
Reference in New Issue
Block a user