bug: 78237政策法规资料可下载者一定可查看

This commit is contained in:
wxyclub
2023-11-27 14:10:15 +08:00
parent 9983d0595f
commit 4684ec8dbc
2 changed files with 30 additions and 18 deletions
@@ -3,6 +3,7 @@ package com.adc.da.slrs.sarLawsInformation.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.base.page.BasePage;
import com.adc.da.utils.annotation.CompareField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -37,6 +38,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 一级资料类别
*/
@CompareField(fieldName = "1级资料分类")
@ApiModelProperty("1级资料分类")
@TableField(value = "FIRST_TYPE")
private String firstType;
@@ -44,7 +46,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 一级资料类别名称
*/
@ApiModelProperty(value = "级资料类名称")
@ApiModelProperty(value = "1级资料类名称")
// @TableField(exist = false)
@Excel(name = "*1级资料分类", orderNum = "0")
private String firstTypeName;
@@ -52,14 +54,15 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 二级资料类别
*/
@ApiModelProperty(value = "级资料类")
@CompareField(fieldName = "2级资料")
@ApiModelProperty(value = "2级资料分类")
@TableField(value = "SECOND_TYPE")
private String secondType;
/**
* 二级资料类别名称
*/
@ApiModelProperty(value = "级资料类名称")
@ApiModelProperty(value = "2级资料类名称")
// @TableField(exist = false)
@Excel(name = "*2级资料分类", orderNum = "1")
private String secondTypeName;
@@ -67,14 +70,15 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 三级资料类别
*/
@ApiModelProperty(value = "级资料类")
@CompareField(fieldName = "3级资料")
@ApiModelProperty(value = "3级资料分类")
@TableField(value = "THIRD_TYPE")
private String thirdType;
/**
* 三级资料类别名称
*/
@ApiModelProperty(value = "级资料类名称")
@ApiModelProperty(value = "3级资料类名称")
// @TableField(exist = false)
@Excel(name = "*3级资料分类", orderNum = "2")
private String thirdTypeName;
@@ -82,14 +86,15 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 四级资料类别
*/
@ApiModelProperty(value = "级资料类")
@CompareField(fieldName = "4级资料")
@ApiModelProperty(value = "4级资料分类")
@TableField(value = "FOURTH_TYPE")
private String fourthType;
/**
* 四级资料类别名称
*/
@ApiModelProperty(value = "四级资料类名称")
@ApiModelProperty(value = "四级资料类名称")
// @TableField(exist = false)
@Excel(name = "*4级资料分类", orderNum = "3")
private String fourthTypeName;
@@ -97,6 +102,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 资料名称
*/
@CompareField(fieldName = "资料名称")
@ApiModelProperty(value = "资料名称")
@TableField(value = "NAME")
@Excel(name = "*资料名称", orderNum = "4")
@@ -105,6 +111,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 资料归属部门
*/
@CompareField(fieldName = "资料归属部门")
@ApiModelProperty(value = "资料归属部门")
@TableField(value = "DEPARTMENT")
@Excel(name = "*资料归属部门", orderNum = "5")
@@ -113,6 +120,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 作者
*/
@CompareField(fieldName = "作者")
@ApiModelProperty(value = "作者")
@TableField(value = "AUTHOR")
@Excel(name = "作者", orderNum = "6")
@@ -121,6 +129,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 上传时间
*/
@CompareField(fieldName = "上传时间")
@ApiModelProperty(value = "上传时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@@ -131,6 +140,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 资料说明
*/
@CompareField(fieldName = "资料说明")
@ApiModelProperty(value = "资料说明")
@TableField(value = "DESCRIPTION")
@Excel(name = "资料说明", orderNum = "8")
@@ -139,6 +149,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 资料文件
*/
@CompareField(fieldName = "资料文件")
@ApiModelProperty(value = "资料文件")
@TableField(value = "INFORMATION_FILE")
@Excel(name = "资料文件", orderNum = "9")
@@ -154,6 +165,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 可查看者,若设置为空则所有用户均可查看,若设置人员后,仅有可查看者可以查看文件信息。
*/
@CompareField(fieldName = "可查看者")
@ApiModelProperty(value = "可查看者")
@TableField(exist = false)
private String viewableBy;
@@ -161,6 +173,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 可下载者,若设置为空则仅有上传人和审批人可以查看,若设置人员后,仅有可下载者可下载文件信息。
*/
@CompareField(fieldName = "可下载者")
@ApiModelProperty(value = "可下载者")
@TableField(exist = false)
private String downloadableBy;
@@ -21,6 +21,7 @@ import com.adc.da.slrs.tsDictionaryType.entity.TsDicType;
import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService;
import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.annotation.CompareField;
import com.adc.da.utils.util.FieldConvertUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -28,7 +29,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation;
import com.adc.da.slrs.sarLawsInformation.service.SarLawsInformationService;
import com.adc.da.slrs.sarLawsInformation.dao.SarLawsInformationDao;
import io.swagger.annotations.ApiModelProperty;
import lombok.SneakyThrows;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
@@ -161,7 +161,8 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
LambdaQueryWrapper<SarLawsInformationAuth> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SarLawsInformationAuth::getUserId, userId);
wrapper.and(each -> each.eq(SarLawsInformationAuth::getAuthType, "viewableBy")
.or().eq(SarLawsInformationAuth::getAuthType, "createAndApproveBy"));
.or().eq(SarLawsInformationAuth::getAuthType, "createAndApproveBy")
.or().eq(SarLawsInformationAuth::getAuthType, "downloadableBy"));
wrapper.select(SarLawsInformationAuth::getLawsInformationId);
List<SarLawsInformationAuth> informationAuthList = authService.list(wrapper);
if (informationAuthList.size() > 0) {
@@ -625,15 +626,13 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
* @return 差异
*/
public List<String> compareSarLawsInformation(SarLawsInformation oldInfo, SarLawsInformation newInfo) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<String> changes = new ArrayList<>();
// 需要比较的字段
String[] fieldArr = {"firstType","secondType","thirdType","fourthType","name",
"department","author","description","informationFile","treeNodeId","viewableBy","downloadableBy"};
List<String> fieldList = Arrays.asList(fieldArr);
// 获取SarLawsInformation类的所有字段
Field[] fields = SarLawsInformation.class.getDeclaredFields();
for (Field field : fields) {
if (fieldList.contains(field.getName())) {
boolean annotationPresent = field.isAnnotationPresent(CompareField.class);
if (annotationPresent) {
try {
field.setAccessible(true);
String oldValue = String.valueOf(field.get(oldInfo));
@@ -681,13 +680,13 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
}
}
// 获取字段名称
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "\"" + String.join(",", oldFileNameList) + "\"改为\"" + String.join(",", fileNameList) + "\"");
CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0];
changes.add(annotationsByType.fieldName() + "\"" + String.join(",", oldFileNameList) + "\"改为\"" + String.join(",", fileNameList) + "\"");
break;
}
default: {
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "\"" + oldValue + "\"改为\"" + newValue + "\"");
CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0];
changes.add(annotationsByType.fieldName() + "\"" + oldValue + "\"改为\"" + newValue + "\"");
break;
}
}