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