From a841f376a4882041c9e81f0bee3b9e7c66cd25e6 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 28 Apr 2025 00:04:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eusers=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=94=81=E5=AE=9A=EF=BC=8C=E8=A7=A3=E5=86=B3?= =?UTF-8?q?swagger=E5=8C=85=E7=89=88=E6=9C=AC=E4=BE=9D=E8=B5=96=20?= =?UTF-8?q?=E5=86=B2=E7=AA=81=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=9C=B0=E6=B5=8B?= =?UTF-8?q?=E7=A7=91mo=E5=93=81=E5=91=B3=E9=83=A8=E5=88=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 ++-- .../DicekeMiningrecordController.java | 10 +++- .../jdc/jdcproject/entity/Renyuanjiegou.java | 2 + .../java/com/jdc/jdcproject/entity/Users.java | 47 ++++--------------- .../entity/VO/DicekeMiningrecordVo.java | 4 +- .../exceptionhandler/JdcException.java | 3 +- .../service/impl/UsersServiceImpl.java | 38 ++++++++++++--- src/main/resources/application.yml | 13 ----- 8 files changed, 60 insertions(+), 65 deletions(-) diff --git a/pom.xml b/pom.xml index 94ef0c4..8e2f8b3 100644 --- a/pom.xml +++ b/pom.xml @@ -39,9 +39,9 @@ 2.6 9.3.7.v20160115 0.11.2 - 3.0.1 + 5.0.0 2.17.0 - 4.5.0 + 2.8.6 @@ -152,8 +152,8 @@ - com.github.xiaoymin - knife4j-openapi3-jakarta-spring-boot-starter + org.springdoc + springdoc-openapi-starter-webmvc-ui ${swagger3.version} diff --git a/src/main/java/com/jdc/jdcproject/controller/DicekeMiningrecordController.java b/src/main/java/com/jdc/jdcproject/controller/DicekeMiningrecordController.java index 4c93f8d..09ba150 100644 --- a/src/main/java/com/jdc/jdcproject/controller/DicekeMiningrecordController.java +++ b/src/main/java/com/jdc/jdcproject/controller/DicekeMiningrecordController.java @@ -28,9 +28,10 @@ public class DicekeMiningrecordController { private IDicekeMiningrecordService dicekeMiningrecordService; @Operation(summary = "查询mo品味报表") - @GetMapping("findAll") + @GetMapping("findAllMiningrecord") public Result findAll() { List dicekeMiningrecordVoList = dicekeMiningrecordService.findAll(); + System.out.println(dicekeMiningrecordVoList.toString()); return Result.successResult().data("dicekeMiningrecordVoList", dicekeMiningrecordVoList); } @@ -56,4 +57,11 @@ public class DicekeMiningrecordController { return Result.errorResult(); } } + + @Operation(summary = "根据id查询Mo品味信息") + @GetMapping("finddicekeMiningrecordById/{recordID}") + public Result finddicekeMiningrecordById(@PathVariable String recordID) { + DicekeMiningrecord dicekeMiningrecordServiceById = dicekeMiningrecordService.getById(recordID); + return Result.successResult().data("dicekeMiningrecordServiceById", dicekeMiningrecordServiceById); + } } diff --git a/src/main/java/com/jdc/jdcproject/entity/Renyuanjiegou.java b/src/main/java/com/jdc/jdcproject/entity/Renyuanjiegou.java index 88631ad..a8b685c 100644 --- a/src/main/java/com/jdc/jdcproject/entity/Renyuanjiegou.java +++ b/src/main/java/com/jdc/jdcproject/entity/Renyuanjiegou.java @@ -3,6 +3,7 @@ package com.jdc.jdcproject.entity; import java.io.Serializable; import java.time.LocalDateTime; import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; /** *

@@ -13,6 +14,7 @@ import io.swagger.v3.oas.annotations.media.Schema; * @since 2025-04-26 */ @Schema(name = "Renyuanjiegou", description = "") +@Data public class Renyuanjiegou implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/jdc/jdcproject/entity/Users.java b/src/main/java/com/jdc/jdcproject/entity/Users.java index 1651b05..05f620b 100644 --- a/src/main/java/com/jdc/jdcproject/entity/Users.java +++ b/src/main/java/com/jdc/jdcproject/entity/Users.java @@ -1,7 +1,10 @@ package com.jdc.jdcproject.entity; import java.io.Serializable; +import java.time.LocalDateTime; + import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; /** *

@@ -12,6 +15,7 @@ import io.swagger.v3.oas.annotations.media.Schema; * @since 2025-04-26 */ @Schema(name = "Users", description = "") +@Data public class Users implements Serializable { private static final long serialVersionUID = 1L; @@ -31,45 +35,14 @@ public class Users implements Serializable { @Schema(description = "手机号") private String tel; - public String getId() { - return id; - } + @Schema(description = "微信登陆openid") + private String openid; - public void setId(String id) { - this.id = id; - } + @Schema(description = "记录用户登录错误次数") + private Integer errlogincount = 0; - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getSalt() { - return salt; - } - - public void setSalt(String salt) { - this.salt = salt; - } - - public String getTel() { - return tel; - } - - public void setTel(String tel) { - this.tel = tel; - } + @Schema(description = "记录锁定的时间至何时") + private LocalDateTime lockdatetime; @Override public String toString() { diff --git a/src/main/java/com/jdc/jdcproject/entity/VO/DicekeMiningrecordVo.java b/src/main/java/com/jdc/jdcproject/entity/VO/DicekeMiningrecordVo.java index b0e67bf..0166e0b 100644 --- a/src/main/java/com/jdc/jdcproject/entity/VO/DicekeMiningrecordVo.java +++ b/src/main/java/com/jdc/jdcproject/entity/VO/DicekeMiningrecordVo.java @@ -19,7 +19,7 @@ public class DicekeMiningrecordVo { private String plateRange; @Schema(description = "铲号") - private String shovelCoed; + private String shovelCode; @Schema(description = "月份") private LocalDate month; @@ -53,7 +53,7 @@ public class DicekeMiningrecordVo { return "DicekeMiningrecord{" + "recordID = " + recordID + ", plateID = " + plateRange + - ", shovelID = " + shovelCoed + + ", shovelID = " + shovelCode + ", month = " + month + ", totalMiningTon = " + totalMiningTon + ", metalTon = " + metalTon + diff --git a/src/main/java/com/jdc/jdcproject/exceptionhandler/JdcException.java b/src/main/java/com/jdc/jdcproject/exceptionhandler/JdcException.java index d489fc4..6df40b3 100644 --- a/src/main/java/com/jdc/jdcproject/exceptionhandler/JdcException.java +++ b/src/main/java/com/jdc/jdcproject/exceptionhandler/JdcException.java @@ -5,12 +5,11 @@ import lombok.Data; import lombok.NoArgsConstructor; @Data -@AllArgsConstructor @NoArgsConstructor +@AllArgsConstructor public class JdcException extends RuntimeException { private Integer code;//状态码 private String msg;//异常信息 - } \ No newline at end of file diff --git a/src/main/java/com/jdc/jdcproject/service/impl/UsersServiceImpl.java b/src/main/java/com/jdc/jdcproject/service/impl/UsersServiceImpl.java index 0da5b26..47c6157 100644 --- a/src/main/java/com/jdc/jdcproject/service/impl/UsersServiceImpl.java +++ b/src/main/java/com/jdc/jdcproject/service/impl/UsersServiceImpl.java @@ -11,6 +11,8 @@ import com.jdc.jdcproject.utils.MD5; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import java.time.LocalDateTime; + /** *

* 服务实现类 @@ -24,22 +26,21 @@ public class UsersServiceImpl extends ServiceImpl implements @Override public String login(Users user) { - System.out.println(user.toString()); String password = user.getPassword(); String name = user.getUsername(); String phone = user.getUsername(); - if (user.getUsername().matches("^\\d{11}$")){ + + if (user.getUsername().matches("^\\d{11}$")) { phone = user.getUsername(); - }else { + } else { name = user.getUsername(); } - System.out.println(user.toString()); - if ((StringUtils.isEmpty(phone) ^ StringUtils.isEmpty(name)) || StringUtils.isEmpty(password)) { throw new JdcException(20001, "登陆失败"); } + QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("username", name).or().eq("tel", phone); Users users = baseMapper.selectOne(wrapper); @@ -47,10 +48,35 @@ public class UsersServiceImpl extends ServiceImpl implements if (users == null) { throw new JdcException(20001, "登陆失败"); } - System.out.println(MD5.encrypt(password)); + + // 增加锁定判断 + if (users.getLockdatetime() != null && users.getLockdatetime().isAfter(LocalDateTime.now())) { + throw new JdcException(20001, "账号已锁定,请稍后再试"); + } + + // 校验密码 if (!MD5.encrypt(password).equals(users.getPassword())) { + // 密码错误,增加错误次数 + Integer errorCount = users.getErrlogincount() == null ? 0 : users.getErrlogincount(); + errorCount++; + + users.setErrlogincount(errorCount); + + // 如果错误次数达到5次,锁定账户 + if (errorCount >= 5) { + users.setLockdatetime(LocalDateTime.now().plusMinutes(30)); + } + + baseMapper.updateById(users); // 保存用户状态 + throw new JdcException(20001, "登陆失败"); } + + // 登录成功,清除错误次数和锁定时间 + users.setErrlogincount(0); + users.setLockdatetime(null); + baseMapper.updateById(users); + String token = JwtUtils.getJwtToken(users.getId(), users.getUsername()); return token; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c8b32a4..82b8539 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -18,16 +18,3 @@ server: springdoc: swagger-ui: path: /swagger-ui.html - tags-sorter: alpha - operations-sorter: alpha - api-docs: - path: /v3/api-docs - group-configs: - - group: 'default' - paths-to-match: '/**' - packages-to-scan: com.jdc.jdcproject.controller # controller -# knife4j -knife4j: - enable: true - setting: - language: zh_cn