Compare commits

...

7 Commits

  1. 39
      pom.xml
  2. 4
      src/main/java/com/huoran/iasf/common/config/WebMvcConfigurer.java
  3. 67
      src/main/java/com/huoran/iasf/common/filter/XssHttpServletRequestWrapper.java
  4. 4
      src/main/java/com/huoran/iasf/common/shiro/ShiroConfig.java
  5. 6
      src/main/java/com/huoran/iasf/common/utils/R.java
  6. 11
      src/main/java/com/huoran/iasf/controller/SysColumnController.java
  7. 17
      src/main/java/com/huoran/iasf/controller/SysContentClassificationController.java
  8. 21
      src/main/java/com/huoran/iasf/controller/SysContentController.java
  9. 4
      src/main/java/com/huoran/iasf/controller/SysContentFileController.java
  10. 16
      src/main/java/com/huoran/iasf/controller/SysContentLabelController.java
  11. 4
      src/main/java/com/huoran/iasf/controller/SysFilesController.java
  12. 11
      src/main/java/com/huoran/iasf/controller/UserController.java
  13. 3
      src/main/java/com/huoran/iasf/service/SysColumnService.java
  14. 9
      src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java
  15. 13
      src/main/java/com/huoran/iasf/service/impl/SysFilesServiceImpl.java
  16. 5
      src/main/java/com/huoran/iasf/vo/resp/DeptRespNodeVO.java
  17. 5
      src/main/java/com/huoran/iasf/vo/resp/HomeRespVO.java
  18. 5
      src/main/java/com/huoran/iasf/vo/resp/LoginRespVO.java
  19. 5
      src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java
  20. 5
      src/main/java/com/huoran/iasf/vo/resp/PermissionRespNode.java
  21. 4
      src/main/java/com/huoran/iasf/vo/resp/SortColumnRespVO.java
  22. 6
      src/main/java/com/huoran/iasf/vo/resp/UserInfoRespVO.java
  23. 6
      src/main/java/com/huoran/iasf/vo/resp/UserListResp.java
  24. 5
      src/main/java/com/huoran/iasf/vo/resp/UserOwnRoleRespVO.java
  25. 17
      src/main/resources/application-dev.yml

@ -52,6 +52,15 @@
<dependencies> <dependencies>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.17.2</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId> <artifactId>spring-boot-configuration-processor</artifactId>
@ -282,6 +291,36 @@
<skipTests>true</skipTests> <skipTests>true</skipTests>
</configuration> </configuration>
</plugin> </plugin>
<!-- 加密插件,防止反编译 -->
<plugin>
<!-- https://gitee.com/roseboy/classfinal -->
<groupId>net.roseboy</groupId>
<artifactId>classfinal-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<!--加密密码,如果是#号,则使用无密码模式加密,【加密后没有pom文件,不用担心泄漏】-->
<password>#</password>
<!--加密的包名(可为空,多个用","分割)-->
<packages>com.huoran.iasf</packages>
<!--需要加密的配置文件,一般是classes目录下的yml或properties文件(可为空,多个用","分割)-->
<cfgfiles>*.properties,*.yml</cfgfiles>
<excludes>org.spring</excludes>
<!--外部依赖的jar目录,例如/tomcat/lib(可为空,多个用","分割)-->
<!--<classpath></classpath>-->
<!--运行命令: java -javaagent:iasf-encrypted.jar -jar iasf-encrypted.jar-->
<!--机器码获取命令:java -jar classfinal-fatjar-1.2.1.jar -C -->
<code>FDDEF78DF2FC3D09D733CBEAB15C3AEFD41D8CD98F00B204E9800998ECF8427ED41D8CD98F00B204E9800998ECF8427E</code>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>classFinal</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
<resources> <resources>

@ -50,8 +50,8 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
// corsConfiguration.addAllowedOrigin("*"); // 允许任何头 // corsConfiguration.addAllowedOrigin("*"); // 允许任何头
corsConfiguration.addAllowedOrigin("https://new.iasf.ac.cn"); //允许信任域名 corsConfiguration.addAllowedOrigin("https://new.iasf.ac.cn"); //允许信任域名
corsConfiguration.addAllowedOrigin("https://www.iasf.ac.cn"); //允许信任域名 corsConfiguration.addAllowedOrigin("https://www.iasf.ac.cn"); //允许信任域名
// corsConfiguration.addAllowedOrigin("http://192.168.31.125:8095"); //允许信任域名 corsConfiguration.addAllowedOrigin("http://192.168.31.125:8095"); //允许信任域名
// corsConfiguration.addAllowedOrigin("http://192.168.31.125:8088"); //允许信任域名 corsConfiguration.addAllowedOrigin("http://192.168.31.125:8088"); //允许信任域名
corsConfiguration.addAllowedOrigin("http://10.10.11.7"); //允许信任域名 corsConfiguration.addAllowedOrigin("http://10.10.11.7"); //允许信任域名
corsConfiguration.addAllowedMethod("*"); // 允许任何方法(post、get等) corsConfiguration.addAllowedMethod("*"); // 允许任何方法(post、get等)
return corsConfiguration; return corsConfiguration;

@ -5,6 +5,9 @@ import com.huoran.iasf.common.exception.BusinessException;
import com.huoran.iasf.common.exception.code.BaseResponseCode; import com.huoran.iasf.common.exception.code.BaseResponseCode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.safety.Safelist;
import javax.servlet.ReadListener; import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream; import javax.servlet.ServletInputStream;
@ -143,11 +146,19 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
public ServletInputStream getInputStream() throws IOException { public ServletInputStream getInputStream() throws IOException {
// 非文件上传进行过滤 // 非文件上传进行过滤
if (!fileUpload) { if (!fileUpload) {
// 获取body中的请求参数
JSONObject json = JSONObject.parseObject(new String(body)); try {
// 校验并过滤xss攻击和sql注入 // 解析请求体为字符串
for (String k : json.keySet()) { String bodyStr = new String(body, StandardCharsets.UTF_8);
cleanSQLInject(cleanXSS(json.getString(k)));
// 清理HTML,只允许安全的元素和属性
Safelist safelist = Safelist.basicWithImages(); // 自定义safelist
String safeHtml = Jsoup.clean(bodyStr, "", safelist, new Document.OutputSettings().prettyPrint(false));
cleanSQLInject(safeHtml);
} catch (Exception e) {
// 处理解析或处理过程中的任何异常
log.error("Error processing request body {}", e.getMessage());
} }
} }
// 将请求体参数流转 -- 流读取一次就会消失,所以我们事先读取之后就存在byte数组里边方便流转 // 将请求体参数流转 -- 流读取一次就会消失,所以我们事先读取之后就存在byte数组里边方便流转
@ -175,12 +186,35 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
}; };
} }
public String cleanXSS(String src) {
if (StringUtils.isBlank(src)) {
return src;
}
// 创建一个允许的HTML标签和属性的Safelist
Safelist safelist = Safelist.relaxed() // 允许大多数基本的HTML标签和属性
.addTags("img") // 添加额外的标签,如img(记得添加允许的属性,如src和alt)
.addAttributes("*", "class") // 允许所有标签使用"class"属性
.addAttributes("img", "src", "alt") // 允许img标签的src和alt属性
.addProtocols("img", "src", "http", "https") // 只允许http和https协议的src
; // 移除协议相对URL,避免安全问题
// 使用JSoup进行清理
Document document = Jsoup.parseBodyFragment(src, ""); // 解析HTML片段
document.outputSettings(new Document.OutputSettings().prettyPrint(false)); // 禁止美化输出,保持原始结构
String html = document.html();
String clean = Jsoup.clean(html, "", safelist);// 使用Safelist进行清理
return clean; // 返回清理后的HTML字符串
}
/** /**
* 清除xss * 清除xss
* @param src 单个参数 * @param src 单个参数
* @return * @return
*/ */
public String cleanXSS(String src) { /*public String cleanXSS(String src) {
if(StringUtils.isBlank(src)){ if(StringUtils.isBlank(src)){
return src; return src;
} }
@ -202,7 +236,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
} }
return src; return src;
} }*/
/** /**
* 过滤sql注入 -- 需要增加通配过滤大小写组合 * 过滤sql注入 -- 需要增加通配过滤大小写组合
@ -213,12 +247,19 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
if(StringUtils.isBlank(src)){ if(StringUtils.isBlank(src)){
return src; return src;
} }
String cleanedText = Jsoup.clean(src, Safelist.basic());
String SQL_KEYWORD_PATTERN =
"(?i)(?:(?!<[^>]*?>))((select|update|insert|delete|drop|create|alter|exec|union|table|database)[^a-zA-Z0-9])";
// 过滤SQL关键字
cleanedText = cleanedText.replaceAll(SQL_KEYWORD_PATTERN, "");
// 非法sql注入正则 // 非法sql注入正则
Pattern sqlPattern = Pattern.compile(badStrReg, Pattern.CASE_INSENSITIVE); // Pattern sqlPattern = Pattern.compile(badStrReg, Pattern.CASE_INSENSITIVE);
if (sqlPattern.matcher(src.toLowerCase()).find()) { // if (sqlPattern.matcher(src.toLowerCase()).find()) {
log.error("sql注入检查:输入信息存在SQL攻击!"); // log.error("sql注入检查:输入信息存在SQL攻击!");
throw new BusinessException(BaseResponseCode.SQL_FILTER); // throw new BusinessException(BaseResponseCode.SQL_FILTER);
} // }
return src; return cleanedText;
} }
} }

@ -148,7 +148,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/sysContent/queryArticleColumnParent", "anon"); filterChainDefinitionMap.put("/sysContent/queryArticleColumnParent", "anon");
/*filterChainDefinitionMap.put("/index/**", "anon"); /*filterChainDefinitionMap.put("/index/**", "anon");
filterChainDefinitionMap.put("/doc.html", "anon"); filterChainDefinitionMap.put("/iasf/doc.html", "anon");
filterChainDefinitionMap.put("/swagger-resources/**", "anon"); filterChainDefinitionMap.put("/swagger-resources/**", "anon");
filterChainDefinitionMap.put("/v2/api-docs", "anon"); filterChainDefinitionMap.put("/v2/api-docs", "anon");
filterChainDefinitionMap.put("/v2/api-docs-ext", "anon"); filterChainDefinitionMap.put("/v2/api-docs-ext", "anon");
@ -156,7 +156,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/static/**", "anon"); filterChainDefinitionMap.put("/static/**", "anon");
filterChainDefinitionMap.put("/webjars/**", "anon"); filterChainDefinitionMap.put("/webjars/**", "anon");
filterChainDefinitionMap.put("/druid/**", "anon"); filterChainDefinitionMap.put("/druid/**", "anon");
filterChainDefinitionMap.put("/favicon.ico", "anon"); filterChainDefinitionMap.put("/iasf/favicon.ico", "anon");
filterChainDefinitionMap.put("/captcha.jpg", "anon"); filterChainDefinitionMap.put("/captcha.jpg", "anon");
filterChainDefinitionMap.put("/csrf", "anon"); filterChainDefinitionMap.put("/csrf", "anon");
//文件上传可直接访问 //文件上传可直接访问

@ -5,6 +5,8 @@ import com.huoran.iasf.common.exception.code.ResponseCodeInterface;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
/** /**
* 返回值R * 返回值R
* *
@ -13,7 +15,9 @@ import lombok.Data;
* @date 2022年7月28日 * @date 2022年7月28日
*/ */
@Data @Data
public class R { public class R implements Serializable {
// 类的内容
private static final long serialVersionUID = 1L;
/** /**
* 请求响应code0为成功 其他为失败 * 请求响应code0为成功 其他为失败

@ -19,6 +19,8 @@ import com.huoran.iasf.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -108,7 +110,7 @@ public class SysColumnController {
return R.success(sysColumn); return R.success(sysColumn);
} }
@NoRepeatSubmit // @NoRepeatSubmit
@PostMapping("/save") @PostMapping("/save")
@ApiOperation(value = "新增", response = SysColumn.class) @ApiOperation(value = "新增", response = SysColumn.class)
@RequiresPermissions("sys:column:save") @RequiresPermissions("sys:column:save")
@ -126,6 +128,7 @@ public class SysColumnController {
@RequiresPermissions("sys:column:update") @RequiresPermissions("sys:column:update")
public R update(@RequestBody SysColumn sysColumn) { public R update(@RequestBody SysColumn sysColumn) {
boolean updateState = service.updateById(sysColumn); boolean updateState = service.updateById(sysColumn);
service.removeArticles(sysColumn.getId());
return updateState ? R.success() : R.fail("编辑失败"); return updateState ? R.success() : R.fail("编辑失败");
} }
@ -184,13 +187,15 @@ public class SysColumnController {
//删除栏目后删除栏目下的文章 //删除栏目后删除栏目下的文章
sysColumnLongPageService.remove(queryWrapper1); sysColumnLongPageService.remove(queryWrapper1);
ret = service.removeByIds(idList); ret = service.removeByIds(idList);
for (Integer columnId : idList) {
service.removeArticles(columnId);
}
} }
return R.success(); return R.success();
} }
@PostMapping("/sameLevelJudgment") @PostMapping("/sameLevelJudgment")
@Decrypt @Decrypt
@ApiOperation(value = "同级判重", response = ColumnWeightReqVO.class) @ApiOperation(value = "同级判重", response = ColumnWeightReqVO.class)
@ -249,7 +254,7 @@ public class SysColumnController {
} }
// @Cacheable(value = "articles", key = "#id")
public String getIds(Integer id) { public String getIds(Integer id) {
//1 创建list集合,用于封装所有删除菜单id值 //1 创建list集合,用于封装所有删除菜单id值
List<Integer> idList = new ArrayList<>(); List<Integer> idList = new ArrayList<>();

@ -24,6 +24,9 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
@ -67,8 +70,9 @@ public class SysContentClassificationController {
@Decrypt @Decrypt
@ApiOperation(value = "分类校验判重", response = SysContentClassification.class) @ApiOperation(value = "分类校验判重", response = SysContentClassification.class)
public R checkForHeavy( public R checkForHeavy(
@RequestBody CheckForHeavy checkForHeavy) { @RequestBody CheckForHeavy checkForHeavy) throws UnsupportedEncodingException {
String name = URLDecoder.decode(checkForHeavy.getClassificationName(), StandardCharsets.UTF_8.toString());
checkForHeavy.setClassificationName(name);
QueryWrapper<SysContentClassification> queryWrapper = new QueryWrapper<SysContentClassification>().eq("site_id", checkForHeavy.getSiteId()). QueryWrapper<SysContentClassification> queryWrapper = new QueryWrapper<SysContentClassification>().eq("site_id", checkForHeavy.getSiteId()).
eq("classification_name", checkForHeavy.getClassificationName()); eq("classification_name", checkForHeavy.getClassificationName());
@ -88,7 +92,10 @@ public class SysContentClassificationController {
@PostMapping("/save") @PostMapping("/save")
@Decrypt @Decrypt
@ApiOperation(value = "新增", response = SysContentClassification.class) @ApiOperation(value = "新增", response = SysContentClassification.class)
public R save(@RequestBody @Valid @ApiParam(name = "文章所属分类对象", value = "传入json格式", required = true) SysContentClassification sysContentClassification) { public R save(@RequestBody @Valid @ApiParam(name = "文章所属分类对象", value = "传入json格式", required = true) SysContentClassification sysContentClassification) throws UnsupportedEncodingException {
String name = URLDecoder.decode(sysContentClassification.getClassificationName(), StandardCharsets.UTF_8.toString());
sysContentClassification.setClassificationName(name);
boolean addState = service.save(sysContentClassification); boolean addState = service.save(sysContentClassification);
return addState ? R.success() : R.fail("新增失败"); return addState ? R.success() : R.fail("新增失败");
} }
@ -97,7 +104,9 @@ public class SysContentClassificationController {
@PostMapping("/update") @PostMapping("/update")
@Decrypt @Decrypt
@ApiOperation(value = "修改", response = SysContentClassification.class) @ApiOperation(value = "修改", response = SysContentClassification.class)
public R update(@RequestBody @ApiParam(name = "文章所属分类对象", value = "传入json格式", required = true) SysContentClassification sysContentClassification) { public R update(@RequestBody @ApiParam(name = "文章所属分类对象", value = "传入json格式", required = true) SysContentClassification sysContentClassification) throws UnsupportedEncodingException {
String name = URLDecoder.decode(sysContentClassification.getClassificationName(), StandardCharsets.UTF_8.toString());
sysContentClassification.setClassificationName(name);
boolean updateState = service.updateById(sysContentClassification); boolean updateState = service.updateById(sysContentClassification);
return updateState ? R.success() : R.fail("编辑失败"); return updateState ? R.success() : R.fail("编辑失败");
} }

@ -141,7 +141,7 @@ public class SysContentController {
} }
sysContent.setSequence(count + 1);*/ sysContent.setSequence(count + 1);*/
boolean addState = service.save(sysContent); boolean addState = service.save(sysContent);
columnService.removeArticles(sysContent.getColumnId());
return addState ? R.success(sysContent.getId()) : R.fail("新增失败"); return addState ? R.success(sysContent.getId()) : R.fail("新增失败");
} }
@ -152,6 +152,7 @@ public class SysContentController {
@ApiOperation(value = "修改", response = SysContent.class) @ApiOperation(value = "修改", response = SysContent.class)
public R update(@RequestBody @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) { public R update(@RequestBody @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) {
boolean updateState = service.updateById(sysContent); boolean updateState = service.updateById(sysContent);
columnService.removeArticles(sysContent.getColumnId());
return updateState ? R.success() : R.fail("编辑失败"); return updateState ? R.success() : R.fail("编辑失败");
} }
@ -166,6 +167,8 @@ public class SysContentController {
queryWrapper.eq("quote_type", 0); queryWrapper.eq("quote_type", 0);
queryWrapper.set("is_del", 1); queryWrapper.set("is_del", 1);
sysFilesService.update(queryWrapper); sysFilesService.update(queryWrapper);
SysContent sysContent = service.getById(id);
columnService.removeArticles(sysContent.getColumnId());
boolean delState = service.removeById(id); boolean delState = service.removeById(id);
return delState ? R.success() : R.fail("删除失败"); return delState ? R.success() : R.fail("删除失败");
} }
@ -176,6 +179,8 @@ public class SysContentController {
@ApiOperation(value = "批量删除文章", response = SysContent.class) @ApiOperation(value = "批量删除文章", response = SysContent.class)
public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestBody List<Integer> ids) { public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestBody List<Integer> ids) {
for (Integer id : ids) { for (Integer id : ids) {
SysContent sysContent = service.getById(id);
columnService.removeArticles(sysContent.getColumnId());
UpdateWrapper<SysFilesEntity> queryWrapper = new UpdateWrapper<>(); UpdateWrapper<SysFilesEntity> queryWrapper = new UpdateWrapper<>();
queryWrapper.eq("quote_id", id); queryWrapper.eq("quote_id", id);
queryWrapper.eq("quote_type", 0); queryWrapper.eq("quote_type", 0);
@ -187,14 +192,14 @@ public class SysContentController {
} }
@PostMapping("/checkIfTheTitleIsRepeat") @PostMapping("/checkIfTheTitleIsRepeat")
@Decrypt // @Decrypt
@ApiOperation(value = "标题判重——只对已发布的判重(新增,编辑,点击发布时候都要调用判断))", response = ContentHeavyTitleReqVO.class) @ApiOperation(value = "标题判重——只对已发布的判重(新增,编辑,点击发布时候都要调用判断))", response = ContentHeavyTitleReqVO.class)
public R checkIfTheTitleIsRepeat(@RequestBody @Valid ContentHeavyTitleReqVO content) throws UnsupportedEncodingException { public R checkIfTheTitleIsRepeat(@RequestBody @Valid ContentHeavyTitleReqVO content) throws UnsupportedEncodingException {
if (!org.springframework.util.StringUtils.isEmpty(content.getTitle())) { // if (!org.springframework.util.StringUtils.isEmpty(content.getTitle())) {
//中文转码 // //中文转码
String name = URLDecoder.decode(content.getTitle(), StandardCharsets.UTF_8.toString()); // String name = URLDecoder.decode(content.getTitle(), StandardCharsets.UTF_8.toString());
content.setTitle(name); // content.setTitle(name);
} // }
return service.checkIfTheTitleIsRepeat(content) ? R.success() : R.fail("该标题已重复!"); return service.checkIfTheTitleIsRepeat(content) ? R.success() : R.fail("该标题已重复!");
} }
@ -299,6 +304,8 @@ public class SysContentController {
//是否置顶(默认为0 不置顶 1为置顶) //是否置顶(默认为0 不置顶 1为置顶)
UpdateWrapper<SysContent> updateWrap = new UpdateWrapper<>(); UpdateWrapper<SysContent> updateWrap = new UpdateWrapper<>();
// columnService.removeArticles(columnId);
if (articleTopOperation.getIsTop() == 1) { if (articleTopOperation.getIsTop() == 1) {
//置顶时间(置顶一次更新一次) //置顶时间(置顶一次更新一次)
updateWrap.set("top_time", new Date()); updateWrap.set("top_time", new Date());

@ -48,7 +48,7 @@ public class SysContentFileController {
return R.success(sysContentFile); return R.success(sysContentFile);
} }
@NoRepeatSubmit // @NoRepeatSubmit
@PostMapping("/save") @PostMapping("/save")
@ApiOperation(value = "新增", response = SysContentFile.class) @ApiOperation(value = "新增", response = SysContentFile.class)
public R save(@RequestBody @ApiParam(name = "文章附件管理表对象", value = "传入json格式", required = true) SysContentFile sysContentFile) { public R save(@RequestBody @ApiParam(name = "文章附件管理表对象", value = "传入json格式", required = true) SysContentFile sysContentFile) {
@ -64,7 +64,7 @@ public class SysContentFileController {
return updateState ? R.success() : R.fail("编辑失败"); return updateState ? R.success() : R.fail("编辑失败");
} }
@NoRepeatSubmit // @NoRepeatSubmit
@PostMapping("/delete") @PostMapping("/delete")
@ApiOperation(value = "删除", response = SysContentFile.class) @ApiOperation(value = "删除", response = SysContentFile.class)
public R delete(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { public R delete(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) {

@ -21,6 +21,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
@ -63,7 +66,9 @@ public class SysContentLabelController {
@PostMapping("/save") @PostMapping("/save")
@Decrypt @Decrypt
@ApiOperation(value = "新增", response = SysContentLabel.class) @ApiOperation(value = "新增", response = SysContentLabel.class)
public R save(@RequestBody @Valid @ApiParam(name = "文章主题标签对象", value = "传入json格式", required = true) SysContentLabel sysContentLabel) { public R save(@RequestBody @Valid @ApiParam(name = "文章主题标签对象", value = "传入json格式", required = true) SysContentLabel sysContentLabel) throws UnsupportedEncodingException {
String name = URLDecoder.decode(sysContentLabel.getLabelName(), StandardCharsets.UTF_8.toString());
sysContentLabel.setLabelName(name);
boolean addState = service.save(sysContentLabel); boolean addState = service.save(sysContentLabel);
return addState ? R.success() : R.fail("新增失败"); return addState ? R.success() : R.fail("新增失败");
} }
@ -73,8 +78,9 @@ public class SysContentLabelController {
@Decrypt @Decrypt
@ApiOperation(value = "标签校验判重", response = SysContentLabel.class) @ApiOperation(value = "标签校验判重", response = SysContentLabel.class)
public R checkForHeavy( public R checkForHeavy(
@RequestBody LabelCheckForHeavy labelCheckForHeavy) { @RequestBody LabelCheckForHeavy labelCheckForHeavy) throws UnsupportedEncodingException {
String name = URLDecoder.decode(labelCheckForHeavy.getLabelName(), StandardCharsets.UTF_8.toString());
labelCheckForHeavy.setLabelName(name);
QueryWrapper<SysContentLabel> queryWrapper = new QueryWrapper<SysContentLabel>(). QueryWrapper<SysContentLabel> queryWrapper = new QueryWrapper<SysContentLabel>().
eq("site_id", labelCheckForHeavy.getSiteId()).eq("label_name", labelCheckForHeavy.getLabelName()); eq("site_id", labelCheckForHeavy.getSiteId()).eq("label_name", labelCheckForHeavy.getLabelName());
@ -94,7 +100,9 @@ public class SysContentLabelController {
@PostMapping("/update") @PostMapping("/update")
@Decrypt @Decrypt
@ApiOperation(value = "修改", response = SysContentLabel.class) @ApiOperation(value = "修改", response = SysContentLabel.class)
public R update(@RequestBody @ApiParam(name = "文章主题标签对象", value = "传入json格式", required = true) SysContentLabel sysContentLabel) { public R update(@RequestBody @ApiParam(name = "文章主题标签对象", value = "传入json格式", required = true) SysContentLabel sysContentLabel) throws UnsupportedEncodingException {
String name = URLDecoder.decode(sysContentLabel.getLabelName(), StandardCharsets.UTF_8.toString());
sysContentLabel.setLabelName(name);
boolean updateState = service.updateById(sysContentLabel); boolean updateState = service.updateById(sysContentLabel);
return updateState ? R.success() : R.fail("编辑失败"); return updateState ? R.success() : R.fail("编辑失败");
} }

@ -75,7 +75,7 @@ public class SysFilesController {
result.put("imageFieldName", "file"); result.put("imageFieldName", "file");
return result.toJSONString(); return result.toJSONString();
} }
@NoRepeatSubmit // @NoRepeatSubmit
@ApiOperation(value = "新增") @ApiOperation(value = "新增")
@PostMapping("/upload") @PostMapping("/upload")
// @RequiresPermissions(value = {"sysFiles:add", "sysContent:update", "sysContent:add"}, logical = Logical.OR) // @RequiresPermissions(value = {"sysFiles:add", "sysContent:update", "sysContent:add"}, logical = Logical.OR)
@ -119,7 +119,7 @@ public class SysFilesController {
public void preview(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { public void preview(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
sysFilesService.preview(id, req, res); sysFilesService.preview(id, req, res);
} }
@NoRepeatSubmit // @NoRepeatSubmit
@ApiOperation(value = "文件下载") @ApiOperation(value = "文件下载")
@GetMapping("/download/{id}") @GetMapping("/download/{id}")
public void download(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) { public void download(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) {

@ -135,7 +135,16 @@ public class UserController {
@RequiresPermissions("sys:user:add") @RequiresPermissions("sys:user:add")
@Decrypt @Decrypt
@LogAnnotation(title = "用户管理", action = "新增用户") @LogAnnotation(title = "用户管理", action = "新增用户")
public R addUser(@RequestBody @Valid SysUser vo) { public R addUser(@RequestBody @Valid SysUser vo) throws UnsupportedEncodingException {
//中文转码
if (!StringUtils.isEmpty(vo.getRealName())) {
String realName = URLDecoder.decode(vo.getRealName(), StandardCharsets.UTF_8.toString());
vo.setRealName(realName);
}
if (!StringUtils.isEmpty(vo.getUsername())) {
String realName = URLDecoder.decode(vo.getUsername(), StandardCharsets.UTF_8.toString());
vo.setUsername(realName);
}
userService.addUser(vo); userService.addUser(vo);
return R.success(); return R.success();
} }

@ -7,6 +7,7 @@ import com.huoran.iasf.vo.req.ColumnWeightReqVO;
import com.huoran.iasf.vo.req.LongPageColumnReqVO; import com.huoran.iasf.vo.req.LongPageColumnReqVO;
import com.huoran.iasf.vo.req.PageContentReqVO; import com.huoran.iasf.vo.req.PageContentReqVO;
import com.huoran.iasf.vo.req.PaginationColumnReqVO; import com.huoran.iasf.vo.req.PaginationColumnReqVO;
import org.springframework.cache.annotation.CacheEvict;
import java.util.List; import java.util.List;
@ -31,7 +32,7 @@ public interface SysColumnService extends IService<SysColumn> {
R getsTheSubColumn(Integer parentId,String ids,Integer siteId); R getsTheSubColumn(Integer parentId,String ids,Integer siteId);
void removeArticles(Integer columnId);
R getsSublevelColumnsUnderALevel(Integer parentId,String ids,Integer siteId); R getsSublevelColumnsUnderALevel(Integer parentId,String ids,Integer siteId);

@ -18,6 +18,8 @@ import com.huoran.iasf.vo.req.PageContentReqVO;
import com.huoran.iasf.vo.req.PaginationColumnReqVO; import com.huoran.iasf.vo.req.PaginationColumnReqVO;
import com.huoran.iasf.vo.resp.PageContentRespVO; import com.huoran.iasf.vo.resp.PageContentRespVO;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -154,6 +156,12 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn
return R.success(pageList); return R.success(pageList);
} }
@Override
// @CacheEvict(value = "articles", key = "#id")
public void removeArticles(Integer id) {
}
@Override @Override
public R getsTheSubColumn(Integer pid, String ids,Integer siteId) { public R getsTheSubColumn(Integer pid, String ids,Integer siteId) {
@ -182,6 +190,7 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn
} }
@Override @Override
// @Cacheable(value = "articles", key = "#id")
public R queryArticlesByColumnType(String ids, Integer id) { public R queryArticlesByColumnType(String ids, Integer id) {
Integer count = 0; Integer count = 0;

@ -21,6 +21,8 @@ import com.huoran.iasf.vo.req.FileParameters;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
@ -193,6 +195,8 @@ public class SysFilesServiceImpl extends ServiceImpl<SysFilesMapper, SysFilesEnt
@Override @Override
// 缓存预览结果,使用id作为缓存键
// @Cacheable(value = "preview", key = "#id")
public void preview(String id, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { public void preview(String id, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
if (id != null) { if (id != null) {
SysFilesEntity entity = this.getById(id); SysFilesEntity entity = this.getById(id);
@ -210,6 +214,9 @@ public class SysFilesServiceImpl extends ServiceImpl<SysFilesMapper, SysFilesEnt
//判断类型,根据不同的类型文件来处理对应的数据 //判断类型,根据不同的类型文件来处理对应的数据
res.setContentType(mimeType); res.setContentType(mimeType);
res.addHeader("Content-Length", "" + file.length()); res.addHeader("Content-Length", "" + file.length());
res.setHeader("Cache-Control", "public, max-age=31536000");
res.setDateHeader("Expires", System.currentTimeMillis() + 31536000000L);
} }
//转换视频流部分 //转换视频流部分
req.setAttribute(NonStaticResourceHttpRequestConfig.ATTR_FILE, filePath); req.setAttribute(NonStaticResourceHttpRequestConfig.ATTR_FILE, filePath);
@ -293,9 +300,15 @@ public class SysFilesServiceImpl extends ServiceImpl<SysFilesMapper, SysFilesEnt
if (file.exists()) { if (file.exists()) {
file.delete(); file.delete();
} }
removePreview(entity.getId());
}); });
this.removeByIds(ids); this.removeByIds(ids);
}
// 删除预览结果的缓存,同样使用id作为键
// @CacheEvict(value = "preview", key = "#id")
public void removePreview(String id) {
} }
/** /**

@ -3,6 +3,7 @@ package com.huoran.iasf.vo.resp;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
@ -13,7 +14,9 @@ import java.util.List;
* @date 2022年7月28日 * @date 2022年7月28日
*/ */
@Data @Data
public class DeptRespNodeVO { public class DeptRespNodeVO implements Serializable {
// 类的内容
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "组织id") @ApiModelProperty(value = "组织id")
private Integer id; private Integer id;

@ -3,6 +3,7 @@ package com.huoran.iasf.vo.resp;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
@ -13,7 +14,9 @@ import java.util.List;
* @date 2022年7月28日 * @date 2022年7月28日
*/ */
@Data @Data
public class HomeRespVO { public class HomeRespVO implements Serializable {
// 类的内容
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "用户信息") @ApiModelProperty(value = "用户信息")
private UserInfoRespVO userInfo; private UserInfoRespVO userInfo;
@ApiModelProperty(value = "目录菜单") @ApiModelProperty(value = "目录菜单")

@ -4,6 +4,7 @@ import com.huoran.iasf.entity.SysPermission;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
@ -14,7 +15,9 @@ import java.util.List;
* @date 2022年7月28日 * @date 2022年7月28日
*/ */
@Data @Data
public class LoginRespVO { public class LoginRespVO implements Serializable {
// 类的内容
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "token") @ApiModelProperty(value = "token")
private String accessToken; private String accessToken;
@ApiModelProperty(value = "用户名") @ApiModelProperty(value = "用户名")

@ -7,6 +7,7 @@ import com.huoran.iasf.vo.FatherContentRespVO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -16,7 +17,9 @@ import java.util.List;
* @日期: 2022-08-05 * @日期: 2022-08-05
*/ */
@Data @Data
public class PageContentRespVO { public class PageContentRespVO implements Serializable {
// 类的内容
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

@ -3,6 +3,7 @@ package com.huoran.iasf.vo.resp;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
@ -13,7 +14,9 @@ import java.util.List;
* @date 2022年7月28日 * @date 2022年7月28日
*/ */
@Data @Data
public class PermissionRespNode { public class PermissionRespNode implements Serializable {
// 类的内容
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private Integer id; private Integer id;

@ -16,7 +16,9 @@ import java.util.List;
* @日期: 2022-08-03 * @日期: 2022-08-03
*/ */
@Data @Data
public class SortColumnRespVO { public class SortColumnRespVO implements Serializable {
// 类的内容
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

@ -3,6 +3,8 @@ package com.huoran.iasf.vo.resp;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
/** /**
* UserInfoRespVO * UserInfoRespVO
* *
@ -11,7 +13,9 @@ import lombok.Data;
* @date 2022年7月28日 * @date 2022年7月28日
*/ */
@Data @Data
public class UserInfoRespVO { public class UserInfoRespVO implements Serializable {
// 类的内容
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "用户id") @ApiModelProperty(value = "用户id")
private String id; private String id;
@ApiModelProperty(value = "账号") @ApiModelProperty(value = "账号")

@ -6,6 +6,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable;
/** /**
* @Author chen * @Author chen
* @DATE 2022/8/15 15:34 * @DATE 2022/8/15 15:34
@ -15,7 +17,9 @@ import lombok.experimental.Accessors;
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel(value = "UserListResp", description = "用户列表") @ApiModel(value = "UserListResp", description = "用户列表")
public class UserListResp { public class UserListResp implements Serializable {
// 类的内容
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "组织架构ID") @ApiModelProperty(value = "组织架构ID")
private String deptArchitectureId; private String deptArchitectureId;

@ -4,6 +4,7 @@ import com.huoran.iasf.entity.SysRole;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
@ -14,7 +15,9 @@ import java.util.List;
* @date 2022年7月28日 * @date 2022年7月28日
*/ */
@Data @Data
public class UserOwnRoleRespVO { public class UserOwnRoleRespVO implements Serializable {
// 类的内容
private static final long serialVersionUID = 1L;
@ApiModelProperty("所有角色集合") @ApiModelProperty("所有角色集合")
private List<SysRole> allRole; private List<SysRole> allRole;
@ApiModelProperty(value = "用户所拥有角色集合") @ApiModelProperty(value = "用户所拥有角色集合")

@ -6,12 +6,12 @@ spring:
datasource: datasource:
master: master:
username: root username: root
password: 123456 # password: 123456
# password: iasf#2022 password: iasf#2022
# password: HuoRan@2021 # password: HuoRan@2021
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://127.0.0.1:3306/iasf?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8 url: jdbc:mysql://127.0.0.1:3306/iasf?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
url: jdbc:mysql://192.168.31.136:3306/iasf?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8 # url: jdbc:mysql://192.168.31.136:3306/iasf?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
# url: jdbc:mysql://139.9.47.170:3306/iasf?serverTimezone=GMT%2B8 # url: jdbc:mysql://139.9.47.170:3306/iasf?serverTimezone=GMT%2B8
cache: cache:
type: redis type: redis
@ -37,10 +37,9 @@ file:
path: C:/files/ path: C:/files/
#文件预览url #文件预览url
url: /iasf/sysFiles/preview/ url: /iasf/sysFiles/preview/
# ip: http://10.10.11.7
ip: https://new.iasf.ac.cn
#knife4j:
# production: true #生成环境禁用查看文档
#本地开启 #本地开启
# url: :10000/iasf/sysFiles/preview/ # url: :10000/iasf/sysFiles/preview/
# ip: http://192.168.31.51
ip: https://new.iasf.ac.cn
knife4j:
production: true #生成环境禁用查看文档
Loading…
Cancel
Save