Compare commits
2 Commits
e9ae9ebb0d
...
a8af8b1ebd
Author | SHA1 | Date | |
---|---|---|---|
a8af8b1ebd | |||
a841f376a4 |
8
pom.xml
8
pom.xml
@ -39,9 +39,9 @@
|
|||||||
<commons-lang.version>2.6</commons-lang.version>
|
<commons-lang.version>2.6</commons-lang.version>
|
||||||
<jetty-util.version>9.3.7.v20160115</jetty-util.version>
|
<jetty-util.version>9.3.7.v20160115</jetty-util.version>
|
||||||
<jjwt.version>0.11.2</jjwt.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>
|
<common-io.version>2.17.0</common-io.version>
|
||||||
<swagger3.version>4.5.0</swagger3.version>
|
<swagger3.version>2.8.6</swagger3.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -152,8 +152,8 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
<version>${swagger3.version}</version>
|
<version>${swagger3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -28,9 +28,10 @@ public class DicekeMiningrecordController {
|
|||||||
private IDicekeMiningrecordService dicekeMiningrecordService;
|
private IDicekeMiningrecordService dicekeMiningrecordService;
|
||||||
|
|
||||||
@Operation(summary = "查询mo品味报表")
|
@Operation(summary = "查询mo品味报表")
|
||||||
@GetMapping("findAll")
|
@GetMapping("findAllMiningrecord")
|
||||||
public Result findAll() {
|
public Result findAll() {
|
||||||
List<DicekeMiningrecordVo> dicekeMiningrecordVoList = dicekeMiningrecordService.findAll();
|
List<DicekeMiningrecordVo> dicekeMiningrecordVoList = dicekeMiningrecordService.findAll();
|
||||||
|
System.out.println(dicekeMiningrecordVoList.toString());
|
||||||
return Result.successResult().data("dicekeMiningrecordVoList", dicekeMiningrecordVoList);
|
return Result.successResult().data("dicekeMiningrecordVoList", dicekeMiningrecordVoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,4 +57,11 @@ public class DicekeMiningrecordController {
|
|||||||
return Result.errorResult();
|
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.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -13,6 +14,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
* @since 2025-04-26
|
* @since 2025-04-26
|
||||||
*/
|
*/
|
||||||
@Schema(name = "Renyuanjiegou", description = "")
|
@Schema(name = "Renyuanjiegou", description = "")
|
||||||
|
@Data
|
||||||
public class Renyuanjiegou implements Serializable {
|
public class Renyuanjiegou implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package com.jdc.jdcproject.entity;
|
package com.jdc.jdcproject.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -12,6 +15,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
* @since 2025-04-26
|
* @since 2025-04-26
|
||||||
*/
|
*/
|
||||||
@Schema(name = "Users", description = "")
|
@Schema(name = "Users", description = "")
|
||||||
|
@Data
|
||||||
public class Users implements Serializable {
|
public class Users implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -31,45 +35,14 @@ public class Users implements Serializable {
|
|||||||
@Schema(description = "手机号")
|
@Schema(description = "手机号")
|
||||||
private String tel;
|
private String tel;
|
||||||
|
|
||||||
public String getId() {
|
@Schema(description = "微信登陆openid")
|
||||||
return id;
|
private String openid;
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
@Schema(description = "记录用户登录错误次数")
|
||||||
this.id = id;
|
private Integer errlogincount = 0;
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
@Schema(description = "记录锁定的时间至何时")
|
||||||
return username;
|
private LocalDateTime lockdatetime;
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -19,7 +19,7 @@ public class DicekeMiningrecordVo {
|
|||||||
private String plateRange;
|
private String plateRange;
|
||||||
|
|
||||||
@Schema(description = "铲号")
|
@Schema(description = "铲号")
|
||||||
private String shovelCoed;
|
private String shovelCode;
|
||||||
|
|
||||||
@Schema(description = "月份")
|
@Schema(description = "月份")
|
||||||
private LocalDate month;
|
private LocalDate month;
|
||||||
@ -53,7 +53,7 @@ public class DicekeMiningrecordVo {
|
|||||||
return "DicekeMiningrecord{" +
|
return "DicekeMiningrecord{" +
|
||||||
"recordID = " + recordID +
|
"recordID = " + recordID +
|
||||||
", plateID = " + plateRange +
|
", plateID = " + plateRange +
|
||||||
", shovelID = " + shovelCoed +
|
", shovelID = " + shovelCode +
|
||||||
", month = " + month +
|
", month = " + month +
|
||||||
", totalMiningTon = " + totalMiningTon +
|
", totalMiningTon = " + totalMiningTon +
|
||||||
", metalTon = " + metalTon +
|
", metalTon = " + metalTon +
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.jdc.jdcproject.exceptionhandler;
|
||||||
|
|
||||||
|
import com.jdc.jdcproject.utils.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
@ControllerAdvice
|
||||||
|
@Slf4j
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
|
//指定出现什么异常执行什么方法
|
||||||
|
@ExceptionHandler(Exception.class)
|
||||||
|
@ResponseBody//为了返回数据
|
||||||
|
public Result error(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return Result.errorResult().message("执行了全局异常处理");
|
||||||
|
}
|
||||||
|
|
||||||
|
//指定出现什么异常执行什么方法
|
||||||
|
@ExceptionHandler(ArithmeticException.class)
|
||||||
|
@ResponseBody//为了返回数据
|
||||||
|
public Result error(ArithmeticException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return Result.errorResult().message("执行了ArithmeticException异常处理");
|
||||||
|
}
|
||||||
|
|
||||||
|
//指定出现什么异常执行什么方法
|
||||||
|
//自定义异常处理
|
||||||
|
@ExceptionHandler(JdcException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public Result error(JdcException e){
|
||||||
|
log.error(e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
return Result.errorResult().code(e.getCode()).message(e.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,12 +5,11 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class JdcException extends RuntimeException {
|
public class JdcException extends RuntimeException {
|
||||||
|
|
||||||
private Integer code;//状态码
|
private Integer code;//状态码
|
||||||
|
|
||||||
private String msg;//异常信息
|
private String msg;//异常信息
|
||||||
|
|
||||||
}
|
}
|
@ -11,6 +11,8 @@ import com.jdc.jdcproject.utils.MD5;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 服务实现类
|
* 服务实现类
|
||||||
@ -24,22 +26,21 @@ public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String login(Users user) {
|
public String login(Users user) {
|
||||||
|
|
||||||
System.out.println(user.toString());
|
System.out.println(user.toString());
|
||||||
String password = user.getPassword();
|
String password = user.getPassword();
|
||||||
String name = user.getUsername();
|
String name = user.getUsername();
|
||||||
String phone = user.getUsername();
|
String phone = user.getUsername();
|
||||||
if (user.getUsername().matches("^\\d{11}$")){
|
|
||||||
|
if (user.getUsername().matches("^\\d{11}$")) {
|
||||||
phone = user.getUsername();
|
phone = user.getUsername();
|
||||||
}else {
|
} else {
|
||||||
name = user.getUsername();
|
name = user.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(user.toString());
|
|
||||||
|
|
||||||
if ((StringUtils.isEmpty(phone) ^ StringUtils.isEmpty(name)) || StringUtils.isEmpty(password)) {
|
if ((StringUtils.isEmpty(phone) ^ StringUtils.isEmpty(name)) || StringUtils.isEmpty(password)) {
|
||||||
throw new JdcException(20001, "登陆失败");
|
throw new JdcException(20001, "登陆失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryWrapper<Users> wrapper = new QueryWrapper<>();
|
QueryWrapper<Users> wrapper = new QueryWrapper<>();
|
||||||
wrapper.eq("username", name).or().eq("tel", phone);
|
wrapper.eq("username", name).or().eq("tel", phone);
|
||||||
Users users = baseMapper.selectOne(wrapper);
|
Users users = baseMapper.selectOne(wrapper);
|
||||||
@ -47,10 +48,35 @@ public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements
|
|||||||
if (users == null) {
|
if (users == null) {
|
||||||
throw new JdcException(20001, "登陆失败");
|
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())) {
|
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, "登陆失败");
|
throw new JdcException(20001, "登陆失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 登录成功,清除错误次数和锁定时间
|
||||||
|
users.setErrlogincount(0);
|
||||||
|
users.setLockdatetime(null);
|
||||||
|
baseMapper.updateById(users);
|
||||||
|
|
||||||
String token = JwtUtils.getJwtToken(users.getId(), users.getUsername());
|
String token = JwtUtils.getJwtToken(users.getId(), users.getUsername());
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,3 @@ server:
|
|||||||
springdoc:
|
springdoc:
|
||||||
swagger-ui:
|
swagger-ui:
|
||||||
path: /swagger-ui.html
|
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