新增users登录校验锁定,解决swagger包版本依赖 冲突,增加地测科mo品味部分修改功能
This commit is contained in:
parent
e9ae9ebb0d
commit
a841f376a4
8
pom.xml
8
pom.xml
@ -39,9 +39,9 @@
|
||||
<commons-lang.version>2.6</commons-lang.version>
|
||||
<jetty-util.version>9.3.7.v20160115</jetty-util.version>
|
||||
<jjwt.version>0.11.2</jjwt.version>
|
||||
<servlet-api.version>3.0.1</servlet-api.version>
|
||||
<servlet-api.version>5.0.0</servlet-api.version>
|
||||
<common-io.version>2.17.0</common-io.version>
|
||||
<swagger3.version>4.5.0</swagger3.version>
|
||||
<swagger3.version>2.8.6</swagger3.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -152,8 +152,8 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>${swagger3.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
@ -28,9 +28,10 @@ public class DicekeMiningrecordController {
|
||||
private IDicekeMiningrecordService dicekeMiningrecordService;
|
||||
|
||||
@Operation(summary = "查询mo品味报表")
|
||||
@GetMapping("findAll")
|
||||
@GetMapping("findAllMiningrecord")
|
||||
public Result findAll() {
|
||||
List<DicekeMiningrecordVo> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -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() {
|
||||
|
@ -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 +
|
||||
|
@ -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;//异常信息
|
||||
|
||||
}
|
@ -11,6 +11,8 @@ import com.jdc.jdcproject.utils.MD5;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
@ -24,22 +26,21 @@ public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> 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<Users> 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<UsersMapper, Users> 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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user