Skip to content

Commit a837af9

Browse files
authored
chore: 发布版本 0.0.3
2 parents 8c9c745 + 905ee66 commit a837af9

39 files changed

+659
-195
lines changed

README.md

+45-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<img src="https://github.com/juzi214032/oerp/workflows/Java%20CI%20with%20Maven/badge.svg" alt="Github Action">
1010
</a>
1111
<a href="https://spring.io/">
12-
<img src="https://img.shields.io/badge/Spring%20Boot-2.3.1.RELEASE-brightgreen" alt="Spring Boot">
12+
<img src="https://img.shields.io/badge/Spring%20Boot-2.3.2.RELEASE-brightgreen" alt="Spring Boot">
1313
</a>
1414
<a href="https://mp.baomidou.com/">
1515
<img src="https://img.shields.io/badge/MyBatis%20Plus-3.3.2-blue" alt="MyBatis Plus">
@@ -54,17 +54,20 @@ OERP 是 Online Examination Registration Platform 的缩写,中文名称为:
5454
| |-- com.juzi.oerp
5555
| |-- OerpApplication.java -> SpringBoot 启动类
5656
| |-- common -> 项目通用类
57+
| | |-- aop -> 切面拦截类
5758
| | |-- constant -> 常量
5859
| | |-- exception -> 自定义异常
5960
| | |-- interceptor -> 拦截器(身份认证、权限拦截)
6061
| | |-- jackson -> Jackson 相关
6162
| | |-- store -> 存储型对象(存储当前登录用户的信息)
6263
| |-- configuration -> 系统配置
64+
| | |-- properties -> 自定义配置
6365
| |-- controller -> 系统 API 接口
6466
| |-- dao -> 自定义 DAO 层接口(主要做多表查询)
6567
| |-- mapper -> MyBatis Plus Generator 生成的 DAO 接口(主要做单表 CRUD)
6668
| |-- model -> Java POJO
6769
| | |-- dto -> 数据传输对象(主要用在 Controller 与 Service 层之间)
70+
| | | |-- analysis -> 数据分析相关 DTO 对象
6871
| | | |-- param -> 用于 Controller 层接收参数的对象
6972
| | |-- po -> 持久层对象(和数据库表一一对应,用在 DAO 层)
7073
| | |-- vo -> 视图层对象(作为 Controller 的返回值)
@@ -74,8 +77,49 @@ OERP 是 Online Examination Registration Platform 的缩写,中文名称为:
7477
|-- application.yml -> Spring Boot 配置文件
7578
|-- banner.txt
7679
|-- oerp.sql -> 数据库 SQL 文件(数据库名为 oerp)
80+
|-- code-message.properties -> 响应信息定义
7781
|-- mybatis
7882
|-- xml
7983
|-- dao -> 自定义 Mybatis Xml
8084
|-- mapper -> MyBatis Plus Generator 生成的 MyBatis Xml
8185
```
86+
87+
## 项目截图
88+
89+
### 用户端
90+
91+
#### 首页
92+
93+
![](https://img.juzibiji.top/20200729112009.png)
94+
95+
![](https://img.juzibiji.top/20200729112454.png)
96+
97+
![](https://img.juzibiji.top/20200729113944.png)
98+
99+
#### 个人中心
100+
101+
![](https://img.juzibiji.top/20200729113345.png)
102+
103+
![](https://img.juzibiji.top/20200729113412.png)
104+
105+
#### 登录
106+
107+
![](https://img.juzibiji.top/20200729113558.png)
108+
109+
![](https://img.juzibiji.top/20200729113559.png)
110+
111+
#### 考试报名
112+
113+
![](https://img.juzibiji.top/20200729114009.png)
114+
115+
![](https://img.juzibiji.top/20200729114030.png)
116+
117+
![](https://img.juzibiji.top/20200729114041.png)
118+
119+
## 贡献
120+
121+
欢迎提交 Pull Request 进行代码贡献
122+
123+
## 协议
124+
125+
[MIT](LICENSE) © 2020 桔子

pom.xml

+5-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>2.3.1.RELEASE</version>
14+
<version>2.3.2.RELEASE</version>
1515
<relativePath/>
1616
</parent>
1717

@@ -21,6 +21,7 @@
2121
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2222
<spring-boot-admin.version>2.2.3</spring-boot-admin.version>
2323
<spring-boot.version>2.3.1.RELEASE</spring-boot.version>
24+
<hutool.version>5.3.10</hutool.version>
2425
</properties>
2526

2627
<dependencies>
@@ -89,7 +90,7 @@
8990
<dependency>
9091
<groupId>cn.hutool</groupId>
9192
<artifactId>hutool-crypto</artifactId>
92-
<version>5.3.10</version>
93+
<version>${hutool.version}</version>
9394
</dependency>
9495
<dependency>
9596
<groupId>com.auth0</groupId>
@@ -99,7 +100,7 @@
99100
<dependency>
100101
<groupId>com.aliyun</groupId>
101102
<artifactId>aliyun-java-sdk-core</artifactId>
102-
<version>4.5.4</version>
103+
<version>4.5.5</version>
103104
</dependency>
104105
<dependency>
105106
<groupId>org.springframework.boot</groupId>
@@ -112,7 +113,7 @@
112113
<dependency>
113114
<groupId>cn.hutool</groupId>
114115
<artifactId>hutool-captcha</artifactId>
115-
<version>5.3.10</version>
116+
<version>${hutool.version}</version>
116117
</dependency>
117118
<dependency>
118119
<groupId>org.springframework.boot</groupId>
@@ -124,10 +125,6 @@
124125
<artifactId>knife4j-spring-boot-starter</artifactId>
125126
<version>2.0.4</version>
126127
</dependency>
127-
<dependency>
128-
<groupId>org.springframework.boot</groupId>
129-
<artifactId>spring-boot-starter-validation</artifactId>
130-
</dependency>
131128

132129
<dependency>
133130
<groupId>fr.opensagres.xdocreport</groupId>

src/main/java/com/juzi/oerp/OerpApplication.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package com.juzi.oerp;
22

33
import org.mybatis.spring.annotation.MapperScan;
4-
import org.springframework.beans.factory.annotation.Autowired;
54
import org.springframework.boot.SpringApplication;
65
import org.springframework.boot.autoconfigure.SpringBootApplication;
76
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
87
import org.springframework.cache.annotation.EnableCaching;
98
import org.springframework.transaction.annotation.EnableTransactionManagement;
109
import org.springframework.web.bind.annotation.GetMapping;
11-
import org.springframework.web.bind.annotation.RequestMapping;
1210
import org.springframework.web.bind.annotation.RestController;
13-
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
1411

1512
/**
1613
* @author Juzi
@@ -19,7 +16,7 @@
1916
@RestController
2017
@SpringBootApplication
2118
@EnableTransactionManagement
22-
@MapperScan({"com.juzi.oerp.dao","com.juzi.oerp.mapper"})
19+
@MapperScan({"com.juzi.oerp.dao", "com.juzi.oerp.mapper"})
2320
@ConfigurationPropertiesScan("com.juzi.oerp.configuration.properties")
2421
public class OerpApplication {
2522

src/main/java/com/juzi/oerp/configuration/SpringMvcConfiguration.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public void addInterceptors(InterceptorRegistry registry) {
9393
"/auth/login/**",
9494
"/auth/registion",
9595
"/auth/captcha/**",
96-
"/auth/password/sms",
96+
"/auth/password/reset/sms",
97+
"/auth/phone/**",
9798
"/swagger-resources/**"
9899
);
99100

src/main/java/com/juzi/oerp/controller/AuthenticationController.java

+46-37
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
import com.juzi.oerp.common.exception.AuthenticationException;
66
import com.juzi.oerp.mapper.UserMapper;
77
import com.juzi.oerp.model.dto.ChangePasswordDTO;
8-
import com.juzi.oerp.model.dto.RetrieveUserDTO;
98
import com.juzi.oerp.model.dto.UserPasswordLoginDTO;
109
import com.juzi.oerp.model.dto.UserRegistionDTO;
1110
import com.juzi.oerp.model.dto.UserSMSLoginDTO;
1211
import com.juzi.oerp.model.dto.param.CheckImageCaptchaParamDTO;
1312
import com.juzi.oerp.model.dto.param.CheckSMSCaptchaParamDTO;
13+
import com.juzi.oerp.model.dto.param.ResetPasswordParamDTO;
1414
import com.juzi.oerp.model.dto.param.SMSCaptchaParamDTO;
1515
import com.juzi.oerp.model.po.UserPO;
1616
import com.juzi.oerp.model.vo.CaptchaVO;
@@ -29,6 +29,8 @@
2929
import org.springframework.web.bind.annotation.RequestMapping;
3030
import org.springframework.web.bind.annotation.RestController;
3131

32+
import javax.validation.constraints.Pattern;
33+
3234
/**
3335
* @author Juzi
3436
* @date 2020/7/14 14:40
@@ -43,83 +45,90 @@ public class AuthenticationController {
4345
@Autowired
4446
private UserMapper userMapper;
4547

46-
@PostMapping("/login")
47-
@ApiOperation(value = "密码登录", tags = "登录注册")
48-
public ResponseVO<UserLoginVO> loginByPassword(@RequestBody @Validated UserPasswordLoginDTO userPasswordLoginDTO) {
49-
UserLoginVO result = authenticationService.loginByPassword(userPasswordLoginDTO);
50-
return new ResponseVO<>(result);
51-
}
52-
53-
@PostMapping("/login/sms")
54-
@ApiOperation(value = "短信登录", tags = "登录注册")
55-
public ResponseVO<UserLoginVO> loginBySMS(@RequestBody UserSMSLoginDTO userSMSLoginDTO) {
56-
UserLoginVO result = authenticationService.loginBySMS(userSMSLoginDTO);
57-
return new ResponseVO<>(result);
58-
}
59-
60-
@PostMapping("/registion")
61-
@ApiOperation(value = "账号注册", tags = "登录注册")
62-
public ResponseVO<UserLoginVO> registion(@RequestBody UserRegistionDTO userRegistionDTO) {
63-
UserLoginVO result = authenticationService.registion(userRegistionDTO);
64-
return new ResponseVO<>(result);
65-
}
66-
6748
@GetMapping("/captcha/image")
6849
@ApiOperation(value = "获取图片验证码", tags = "验证码")
6950
public ResponseVO<CaptchaVO> getImageCaptcha() {
7051
CaptchaVO captcha = authenticationService.getImageCaptcha();
7152
return new ResponseVO<>(captcha);
7253
}
7354

74-
@PostMapping("/captcha/image")
55+
@PostMapping("/captcha/image/check")
7556
@ApiOperation(value = "校验图片验证码", tags = "验证码")
76-
public MessageResponseVO checkImageCaptcha(@RequestBody CheckImageCaptchaParamDTO checkImageCaptchaParamDTO) {
57+
public MessageResponseVO checkImageCaptcha(@RequestBody @Validated CheckImageCaptchaParamDTO checkImageCaptchaParamDTO) {
7758
authenticationService.checkImageCaptcha(checkImageCaptchaParamDTO);
7859
return new MessageResponseVO(20001);
7960
}
8061

8162
@PostMapping("/captcha/sms")
8263
@ApiOperation(value = "获取短信验证码", tags = "验证码")
83-
public MessageResponseVO getSMSCaptcha(@RequestBody SMSCaptchaParamDTO smsCaptchaParamDTO) throws JsonProcessingException {
64+
public MessageResponseVO getSMSCaptcha(@RequestBody @Validated SMSCaptchaParamDTO smsCaptchaParamDTO) throws JsonProcessingException {
8465
authenticationService.getSMSCaptcha(smsCaptchaParamDTO);
8566
return new MessageResponseVO(20002);
8667
}
8768

8869
@PostMapping("/captcha/sms/check")
8970
@ApiOperation(value = "校验短信验证码", tags = "验证码")
90-
public MessageResponseVO checkSMSCaptcha(@RequestBody CheckSMSCaptchaParamDTO checkSMSCaptchaParamDTO) {
71+
public MessageResponseVO checkSMSCaptcha(@RequestBody @Validated CheckSMSCaptchaParamDTO checkSMSCaptchaParamDTO) {
9172
authenticationService.checkSMSCaptcha(checkSMSCaptchaParamDTO);
9273
return new MessageResponseVO(20001);
9374
}
9475

95-
@PutMapping("/password")
76+
@PostMapping("/login/password")
77+
@ApiOperation(value = "密码登录", tags = "登录注册")
78+
public ResponseVO<UserLoginVO> loginByPassword(@RequestBody @Validated UserPasswordLoginDTO userPasswordLoginDTO) {
79+
UserLoginVO result = authenticationService.loginByPassword(userPasswordLoginDTO);
80+
return new ResponseVO<>(result);
81+
}
82+
83+
@PostMapping("/login/sms")
84+
@ApiOperation(value = "短信登录", tags = "登录注册")
85+
public ResponseVO<UserLoginVO> loginBySMS(@RequestBody @Validated UserSMSLoginDTO userSMSLoginDTO) {
86+
UserLoginVO result = authenticationService.loginBySMS(userSMSLoginDTO);
87+
return new ResponseVO<>(result);
88+
}
89+
90+
@PostMapping("/registion")
91+
@ApiOperation(value = "账号注册", tags = "登录注册")
92+
public ResponseVO<UserLoginVO> registion(@RequestBody @Validated UserRegistionDTO userRegistionDTO) {
93+
UserLoginVO result = authenticationService.registion(userRegistionDTO);
94+
return new ResponseVO<>(result);
95+
}
96+
97+
@PutMapping("/password/change/old-password")
9698
@ApiOperation(value = "修改密码", notes = "通过原密码修改密码", tags = "账户信息")
97-
public MessageResponseVO updatePassword(@RequestBody ChangePasswordDTO changePasswordDTO) {
98-
authenticationService.updatePassword(changePasswordDTO);
99+
public MessageResponseVO updatePasswordByOldPassword(@RequestBody @Validated ChangePasswordDTO changePasswordDTO) {
100+
authenticationService.updatePasswordByOldPassword(changePasswordDTO);
101+
return new MessageResponseVO(20010);
102+
}
103+
104+
@PutMapping("/password/reset/sms")
105+
@ApiOperation(value = "重置密码", notes = "通过短信验证码重置密码", tags = "账户信息")
106+
public MessageResponseVO resetPassword(@RequestBody @Validated ResetPasswordParamDTO resetPasswordParamDTO) {
107+
authenticationService.resetPassword(resetPasswordParamDTO);
99108
return new MessageResponseVO(20010);
100109
}
101110

102111
@PutMapping("/phone/{phoneNumber}")
103112
@ApiOperation(value = "修改手机号", tags = "账户信息")
104-
public MessageResponseVO updatePhoneNumber(@PathVariable String phoneNumber) {
113+
public MessageResponseVO updatePhoneNumber(
114+
@PathVariable
115+
@Pattern(regexp = "(?:(?:\\+|00)86)?1(?:(?:3[\\d])|(?:4[5-7|9])|(?:5[0-3|5-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\\d])|(?:9[1|8|9]))\\d{8}", message = "手机号格式错误")
116+
@Validated String phoneNumber) {
105117
authenticationService.updatePhoneNumber(phoneNumber);
106118
return new MessageResponseVO(20010);
107119
}
108120

109121
@GetMapping("/phone/{phoneNumber}")
110122
@ApiOperation(value = "检测手机号", notes = "判断该手机号是否已经注册过", tags = "登录注册")
111-
public MessageResponseVO retrieveUserByPhone(@PathVariable String phoneNumber) {
123+
public MessageResponseVO retrieveUserByPhone(
124+
@PathVariable
125+
@Pattern(regexp = "(?:(?:\\+|00)86)?1(?:(?:3[\\d])|(?:4[5-7|9])|(?:5[0-3|5-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\\d])|(?:9[1|8|9]))\\d{8}", message = "手机号格式错误")
126+
@Validated String phoneNumber) {
112127
UserPO userPO = userMapper.selectOne(new LambdaQueryWrapper<UserPO>().eq(UserPO::getPhoneNumber, phoneNumber));
113128
if (userPO == null) {
114129
throw new AuthenticationException(40010);
115130
}
116131
return new MessageResponseVO(20008);
117132
}
118133

119-
@PutMapping("/password/sms")
120-
@ApiOperation(value = "重置密码", notes = "通过短信验证码重置密码", tags = "账户信息")
121-
public MessageResponseVO retrieveUser(@RequestBody RetrieveUserDTO retrieveUserDTO) {
122-
authenticationService.resetPassword(retrieveUserDTO);
123-
return new MessageResponseVO(20010);
124-
}
125134
}

src/main/java/com/juzi/oerp/controller/ExceptionController.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.http.HttpStatus;
99
import org.springframework.util.StringUtils;
10+
import org.springframework.web.HttpRequestMethodNotSupportedException;
1011
import org.springframework.web.bind.MethodArgumentNotValidException;
1112
import org.springframework.web.bind.annotation.ExceptionHandler;
1213
import org.springframework.web.bind.annotation.ResponseStatus;
@@ -57,7 +58,7 @@ public ExceptionResponseVO exceptionResponseVO(OERPException e) {
5758
@ExceptionHandler(MethodArgumentNotValidException.class)
5859
public ExceptionResponseVO methodArgumentNotValidException(MethodArgumentNotValidException e) {
5960
String validMessage = e.getBindingResult().getAllErrors().get(0).getDefaultMessage();
60-
return new ExceptionResponseVO(40000, validMessage, e.getMessage());
61+
return new ExceptionResponseVO(40000, "参数格式错误", validMessage);
6162
}
6263

6364
/**
@@ -69,7 +70,7 @@ public ExceptionResponseVO methodArgumentNotValidException(MethodArgumentNotVali
6970
@ResponseStatus(HttpStatus.BAD_REQUEST)
7071
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
7172
public ExceptionResponseVO methodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e) {
72-
return new ExceptionResponseVO(40000, "参数格式错误", e.getMessage());
73+
return new ExceptionResponseVO(40000, "参数格式错误");
7374
}
7475

7576
/**
@@ -90,6 +91,12 @@ public ExceptionResponseVO missingServletRequestPartException(MissingServletRequ
9091
return new ExceptionResponseVO(40015, e.getMessage());
9192
}
9293

94+
@ResponseStatus(HttpStatus.BAD_REQUEST)
95+
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
96+
public ExceptionResponseVO httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
97+
return new ExceptionResponseVO(40000, "请求方法不支持", e.getMessage());
98+
}
99+
93100
/**
94101
* 其他未知异常
95102
*

0 commit comments

Comments
 (0)