青羊经侦大队-数据平台
wl
2022-07-25 39f55c08933e7f0292c325f41b0f55390a4acc69
添加验证,更新前端,修复bug
5个文件已修改
35 ■■■■■ 已修改文件
pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/example/jz/auth/MyAccessDeniedHandler.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/example/jz/controller/CauseController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/example/jz/modle/dto/CauseDto.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/example/jz/service/impl/CauseServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -22,6 +22,11 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--validatedX-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <!-- 实体类 -->
        <dependency>
            <groupId>org.projectlombok</groupId>
src/main/java/com/example/jz/auth/MyAccessDeniedHandler.java
@@ -3,8 +3,11 @@
import cn.hutool.json.JSONUtil;
import com.example.jz.modle.R;
import org.springframework.context.annotation.Bean;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.security.web.firewall.HttpFirewall;
import org.springframework.security.web.firewall.StrictHttpFirewall;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;
@@ -12,6 +15,10 @@
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.regex.Pattern;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
/**
 * @author 安瑾然
@@ -21,6 +28,17 @@
@Component
public class MyAccessDeniedHandler implements AccessDeniedHandler {
    @Bean
    public HttpFirewall httpFirewall() {
        StrictHttpFirewall firewall = new StrictHttpFirewall();
        Pattern allowed = Pattern.compile("[\\p{IsAssigned}&&[^\\p{IsControl}]]*");
        firewall.setAllowedHeaderValues((header) -> {
            String parsed = new String(header.getBytes(ISO_8859_1), UTF_8);
            return allowed.matcher(parsed).matches();
        });
        return firewall;
    }
    @Override
    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {
        R<String> r = new R<>();
src/main/java/com/example/jz/controller/CauseController.java
@@ -16,6 +16,7 @@
import io.swagger.annotations.ApiResponse;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -52,7 +53,7 @@
    @ApiOperation(httpMethod = "POST", value = "案件台-案件录入-添加案件")
    @PostMapping("/addCause")
    @ApiResponse(message = "执行成功", code = 200)
    public R addCause(@RequestBody CauseDto causeDto) {
    public R addCause(@RequestBody @Validated CauseDto causeDto) {
        causeService.addCause(causeDto);
        return R.ok();
    }
src/main/java/com/example/jz/modle/dto/CauseDto.java
@@ -4,6 +4,8 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Data
@@ -11,25 +13,31 @@
public class CauseDto {
    //案件编号
    @ApiModelProperty(dataType = "String", value = "案件编号")
    @NotBlank(message = "案件编号不能空")
    private String number;
    //案件名称
    @ApiModelProperty(dataType = "String", value = "案件名称")
    @NotBlank(message = "案件名称不能空")
    private String name;
    //第一次案发时间
    @ApiModelProperty(dataType = "Date", value = "第一次案发时间")
    @NotNull(message = "第一次案发时间不能空")
    private Date firstTime;
    //负责人id
    @ApiModelProperty(dataType = "Integer", value = "负责人id")
    @NotNull(message = "负责人不能为空")
    private Integer userId;
    //案件描述
    @ApiModelProperty(dataType = "String", value = "案件描述")
    @NotBlank(message = "案件描述不能为空")
    private String description;
    //案件状态
    @ApiModelProperty(dataType = "Integer", value = "案件状态")
    @NotNull(message = "案件状态")
    private Integer status;
}
src/main/java/com/example/jz/service/impl/CauseServiceImpl.java
@@ -149,6 +149,7 @@
    @Override
    public void deleteCause(Integer id) {
        causeDao.deleteById(id);
        groupDao.delete(new QueryWrapper<Group>().eq("cause_id",id));
    }
    @Override