Skip to content

Commit

Permalink
chore: 发布版本 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
juzi214032 authored Jul 31, 2020
2 parents 8c9c745 + 905ee66 commit a837af9
Show file tree
Hide file tree
Showing 39 changed files with 659 additions and 195 deletions.
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<img src="https://github.com/juzi214032/oerp/workflows/Java%20CI%20with%20Maven/badge.svg" alt="Github Action">
</a>
<a href="https://spring.io/">
<img src="https://img.shields.io/badge/Spring%20Boot-2.3.1.RELEASE-brightgreen" alt="Spring Boot">
<img src="https://img.shields.io/badge/Spring%20Boot-2.3.2.RELEASE-brightgreen" alt="Spring Boot">
</a>
<a href="https://mp.baomidou.com/">
<img src="https://img.shields.io/badge/MyBatis%20Plus-3.3.2-blue" alt="MyBatis Plus">
Expand Down Expand Up @@ -54,17 +54,20 @@ OERP 是 Online Examination Registration Platform 的缩写,中文名称为:
| |-- com.juzi.oerp
| |-- OerpApplication.java -> SpringBoot 启动类
| |-- common -> 项目通用类
| | |-- aop -> 切面拦截类
| | |-- constant -> 常量
| | |-- exception -> 自定义异常
| | |-- interceptor -> 拦截器(身份认证、权限拦截)
| | |-- jackson -> Jackson 相关
| | |-- store -> 存储型对象(存储当前登录用户的信息)
| |-- configuration -> 系统配置
| | |-- properties -> 自定义配置
| |-- controller -> 系统 API 接口
| |-- dao -> 自定义 DAO 层接口(主要做多表查询)
| |-- mapper -> MyBatis Plus Generator 生成的 DAO 接口(主要做单表 CRUD)
| |-- model -> Java POJO
| | |-- dto -> 数据传输对象(主要用在 Controller 与 Service 层之间)
| | | |-- analysis -> 数据分析相关 DTO 对象
| | | |-- param -> 用于 Controller 层接收参数的对象
| | |-- po -> 持久层对象(和数据库表一一对应,用在 DAO 层)
| | |-- vo -> 视图层对象(作为 Controller 的返回值)
Expand All @@ -74,8 +77,49 @@ OERP 是 Online Examination Registration Platform 的缩写,中文名称为:
|-- application.yml -> Spring Boot 配置文件
|-- banner.txt
|-- oerp.sql -> 数据库 SQL 文件(数据库名为 oerp)
|-- code-message.properties -> 响应信息定义
|-- mybatis
|-- xml
|-- dao -> 自定义 Mybatis Xml
|-- mapper -> MyBatis Plus Generator 生成的 MyBatis Xml
```

## 项目截图

### 用户端

#### 首页

![](https://img.juzibiji.top/20200729112009.png)

![](https://img.juzibiji.top/20200729112454.png)

![](https://img.juzibiji.top/20200729113944.png)

#### 个人中心

![](https://img.juzibiji.top/20200729113345.png)

![](https://img.juzibiji.top/20200729113412.png)

#### 登录

![](https://img.juzibiji.top/20200729113558.png)

![](https://img.juzibiji.top/20200729113559.png)

#### 考试报名

![](https://img.juzibiji.top/20200729114009.png)

![](https://img.juzibiji.top/20200729114030.png)

![](https://img.juzibiji.top/20200729114041.png)

## 贡献

欢迎提交 Pull Request 进行代码贡献

## 协议

[MIT](LICENSE) © 2020 桔子
13 changes: 5 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<version>2.3.2.RELEASE</version>
<relativePath/>
</parent>

Expand All @@ -21,6 +21,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot-admin.version>2.2.3</spring-boot-admin.version>
<spring-boot.version>2.3.1.RELEASE</spring-boot.version>
<hutool.version>5.3.10</hutool.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -89,7 +90,7 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
<version>5.3.10</version>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
Expand All @@ -99,7 +100,7 @@
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.4</version>
<version>4.5.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -112,7 +113,7 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-captcha</artifactId>
<version>5.3.10</version>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -124,10 +125,6 @@
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/com/juzi/oerp/OerpApplication.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.juzi.oerp;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

/**
* @author Juzi
Expand All @@ -19,7 +16,7 @@
@RestController
@SpringBootApplication
@EnableTransactionManagement
@MapperScan({"com.juzi.oerp.dao","com.juzi.oerp.mapper"})
@MapperScan({"com.juzi.oerp.dao", "com.juzi.oerp.mapper"})
@ConfigurationPropertiesScan("com.juzi.oerp.configuration.properties")
public class OerpApplication {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public void addInterceptors(InterceptorRegistry registry) {
"/auth/login/**",
"/auth/registion",
"/auth/captcha/**",
"/auth/password/sms",
"/auth/password/reset/sms",
"/auth/phone/**",
"/swagger-resources/**"
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import com.juzi.oerp.common.exception.AuthenticationException;
import com.juzi.oerp.mapper.UserMapper;
import com.juzi.oerp.model.dto.ChangePasswordDTO;
import com.juzi.oerp.model.dto.RetrieveUserDTO;
import com.juzi.oerp.model.dto.UserPasswordLoginDTO;
import com.juzi.oerp.model.dto.UserRegistionDTO;
import com.juzi.oerp.model.dto.UserSMSLoginDTO;
import com.juzi.oerp.model.dto.param.CheckImageCaptchaParamDTO;
import com.juzi.oerp.model.dto.param.CheckSMSCaptchaParamDTO;
import com.juzi.oerp.model.dto.param.ResetPasswordParamDTO;
import com.juzi.oerp.model.dto.param.SMSCaptchaParamDTO;
import com.juzi.oerp.model.po.UserPO;
import com.juzi.oerp.model.vo.CaptchaVO;
Expand All @@ -29,6 +29,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Pattern;

/**
* @author Juzi
* @date 2020/7/14 14:40
Expand All @@ -43,83 +45,90 @@ public class AuthenticationController {
@Autowired
private UserMapper userMapper;

@PostMapping("/login")
@ApiOperation(value = "密码登录", tags = "登录注册")
public ResponseVO<UserLoginVO> loginByPassword(@RequestBody @Validated UserPasswordLoginDTO userPasswordLoginDTO) {
UserLoginVO result = authenticationService.loginByPassword(userPasswordLoginDTO);
return new ResponseVO<>(result);
}

@PostMapping("/login/sms")
@ApiOperation(value = "短信登录", tags = "登录注册")
public ResponseVO<UserLoginVO> loginBySMS(@RequestBody UserSMSLoginDTO userSMSLoginDTO) {
UserLoginVO result = authenticationService.loginBySMS(userSMSLoginDTO);
return new ResponseVO<>(result);
}

@PostMapping("/registion")
@ApiOperation(value = "账号注册", tags = "登录注册")
public ResponseVO<UserLoginVO> registion(@RequestBody UserRegistionDTO userRegistionDTO) {
UserLoginVO result = authenticationService.registion(userRegistionDTO);
return new ResponseVO<>(result);
}

@GetMapping("/captcha/image")
@ApiOperation(value = "获取图片验证码", tags = "验证码")
public ResponseVO<CaptchaVO> getImageCaptcha() {
CaptchaVO captcha = authenticationService.getImageCaptcha();
return new ResponseVO<>(captcha);
}

@PostMapping("/captcha/image")
@PostMapping("/captcha/image/check")
@ApiOperation(value = "校验图片验证码", tags = "验证码")
public MessageResponseVO checkImageCaptcha(@RequestBody CheckImageCaptchaParamDTO checkImageCaptchaParamDTO) {
public MessageResponseVO checkImageCaptcha(@RequestBody @Validated CheckImageCaptchaParamDTO checkImageCaptchaParamDTO) {
authenticationService.checkImageCaptcha(checkImageCaptchaParamDTO);
return new MessageResponseVO(20001);
}

@PostMapping("/captcha/sms")
@ApiOperation(value = "获取短信验证码", tags = "验证码")
public MessageResponseVO getSMSCaptcha(@RequestBody SMSCaptchaParamDTO smsCaptchaParamDTO) throws JsonProcessingException {
public MessageResponseVO getSMSCaptcha(@RequestBody @Validated SMSCaptchaParamDTO smsCaptchaParamDTO) throws JsonProcessingException {
authenticationService.getSMSCaptcha(smsCaptchaParamDTO);
return new MessageResponseVO(20002);
}

@PostMapping("/captcha/sms/check")
@ApiOperation(value = "校验短信验证码", tags = "验证码")
public MessageResponseVO checkSMSCaptcha(@RequestBody CheckSMSCaptchaParamDTO checkSMSCaptchaParamDTO) {
public MessageResponseVO checkSMSCaptcha(@RequestBody @Validated CheckSMSCaptchaParamDTO checkSMSCaptchaParamDTO) {
authenticationService.checkSMSCaptcha(checkSMSCaptchaParamDTO);
return new MessageResponseVO(20001);
}

@PutMapping("/password")
@PostMapping("/login/password")
@ApiOperation(value = "密码登录", tags = "登录注册")
public ResponseVO<UserLoginVO> loginByPassword(@RequestBody @Validated UserPasswordLoginDTO userPasswordLoginDTO) {
UserLoginVO result = authenticationService.loginByPassword(userPasswordLoginDTO);
return new ResponseVO<>(result);
}

@PostMapping("/login/sms")
@ApiOperation(value = "短信登录", tags = "登录注册")
public ResponseVO<UserLoginVO> loginBySMS(@RequestBody @Validated UserSMSLoginDTO userSMSLoginDTO) {
UserLoginVO result = authenticationService.loginBySMS(userSMSLoginDTO);
return new ResponseVO<>(result);
}

@PostMapping("/registion")
@ApiOperation(value = "账号注册", tags = "登录注册")
public ResponseVO<UserLoginVO> registion(@RequestBody @Validated UserRegistionDTO userRegistionDTO) {
UserLoginVO result = authenticationService.registion(userRegistionDTO);
return new ResponseVO<>(result);
}

@PutMapping("/password/change/old-password")
@ApiOperation(value = "修改密码", notes = "通过原密码修改密码", tags = "账户信息")
public MessageResponseVO updatePassword(@RequestBody ChangePasswordDTO changePasswordDTO) {
authenticationService.updatePassword(changePasswordDTO);
public MessageResponseVO updatePasswordByOldPassword(@RequestBody @Validated ChangePasswordDTO changePasswordDTO) {
authenticationService.updatePasswordByOldPassword(changePasswordDTO);
return new MessageResponseVO(20010);
}

@PutMapping("/password/reset/sms")
@ApiOperation(value = "重置密码", notes = "通过短信验证码重置密码", tags = "账户信息")
public MessageResponseVO resetPassword(@RequestBody @Validated ResetPasswordParamDTO resetPasswordParamDTO) {
authenticationService.resetPassword(resetPasswordParamDTO);
return new MessageResponseVO(20010);
}

@PutMapping("/phone/{phoneNumber}")
@ApiOperation(value = "修改手机号", tags = "账户信息")
public MessageResponseVO updatePhoneNumber(@PathVariable String phoneNumber) {
public MessageResponseVO updatePhoneNumber(
@PathVariable
@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 = "手机号格式错误")
@Validated String phoneNumber) {
authenticationService.updatePhoneNumber(phoneNumber);
return new MessageResponseVO(20010);
}

@GetMapping("/phone/{phoneNumber}")
@ApiOperation(value = "检测手机号", notes = "判断该手机号是否已经注册过", tags = "登录注册")
public MessageResponseVO retrieveUserByPhone(@PathVariable String phoneNumber) {
public MessageResponseVO retrieveUserByPhone(
@PathVariable
@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 = "手机号格式错误")
@Validated String phoneNumber) {
UserPO userPO = userMapper.selectOne(new LambdaQueryWrapper<UserPO>().eq(UserPO::getPhoneNumber, phoneNumber));
if (userPO == null) {
throw new AuthenticationException(40010);
}
return new MessageResponseVO(20008);
}

@PutMapping("/password/sms")
@ApiOperation(value = "重置密码", notes = "通过短信验证码重置密码", tags = "账户信息")
public MessageResponseVO retrieveUser(@RequestBody RetrieveUserDTO retrieveUserDTO) {
authenticationService.resetPassword(retrieveUserDTO);
return new MessageResponseVO(20010);
}
}
11 changes: 9 additions & 2 deletions src/main/java/com/juzi/oerp/controller/ExceptionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.util.StringUtils;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
Expand Down Expand Up @@ -57,7 +58,7 @@ public ExceptionResponseVO exceptionResponseVO(OERPException e) {
@ExceptionHandler(MethodArgumentNotValidException.class)
public ExceptionResponseVO methodArgumentNotValidException(MethodArgumentNotValidException e) {
String validMessage = e.getBindingResult().getAllErrors().get(0).getDefaultMessage();
return new ExceptionResponseVO(40000, validMessage, e.getMessage());
return new ExceptionResponseVO(40000, "参数格式错误", validMessage);
}

/**
Expand All @@ -69,7 +70,7 @@ public ExceptionResponseVO methodArgumentNotValidException(MethodArgumentNotVali
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public ExceptionResponseVO methodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e) {
return new ExceptionResponseVO(40000, "参数格式错误", e.getMessage());
return new ExceptionResponseVO(40000, "参数格式错误");
}

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

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public ExceptionResponseVO httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
return new ExceptionResponseVO(40000, "请求方法不支持", e.getMessage());
}

/**
* 其他未知异常
*
Expand Down
Loading

0 comments on commit a837af9

Please sign in to comment.