苍穹外卖--完善员工登录功能&swagger的接口文档的生成与使用介绍
This commit is contained in:
1
pom.xml
1
pom.xml
@@ -12,6 +12,7 @@
|
|||||||
<artifactId>sky-take-out</artifactId>
|
<artifactId>sky-take-out</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<!--聚合工程-->
|
||||||
<modules>
|
<modules>
|
||||||
<module>sky-common</module>
|
<module>sky-common</module>
|
||||||
<module>sky-pojo</module>
|
<module>sky-pojo</module>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import springfox.documentation.spring.web.plugins.Docket;
|
|||||||
/**
|
/**
|
||||||
* 配置类,注册web层相关组件
|
* 配置类,注册web层相关组件
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration//springMvc的配置类
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||||
|
|
||||||
@@ -41,8 +41,9 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
|||||||
* 通过knife4j生成接口文档
|
* 通过knife4j生成接口文档
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean//将当前方法的返回值交给spring容器来管理
|
||||||
public Docket docket() {
|
public Docket docket() {
|
||||||
|
log.info("准备生成接口文档....");
|
||||||
ApiInfo apiInfo = new ApiInfoBuilder()
|
ApiInfo apiInfo = new ApiInfoBuilder()
|
||||||
.title("苍穹外卖项目接口文档")
|
.title("苍穹外卖项目接口文档")
|
||||||
.version("2.0")
|
.version("2.0")
|
||||||
@@ -61,7 +62,9 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
|||||||
* 设置静态资源映射
|
* 设置静态资源映射
|
||||||
* @param registry
|
* @param registry
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
log.info("开始设置静态资源映射,为了在浏览器中可以访问自动生成的swagger接口文档");
|
||||||
registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import com.sky.result.Result;
|
|||||||
import com.sky.service.EmployeeService;
|
import com.sky.service.EmployeeService;
|
||||||
import com.sky.utils.JwtUtil;
|
import com.sky.utils.JwtUtil;
|
||||||
import com.sky.vo.EmployeeLoginVO;
|
import com.sky.vo.EmployeeLoginVO;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -24,6 +26,7 @@ import java.util.Map;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/admin/employee")
|
@RequestMapping("/admin/employee")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Api(tags = "员工管理相关接口")
|
||||||
public class EmployeeController {
|
public class EmployeeController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -37,6 +40,7 @@ public class EmployeeController {
|
|||||||
* @param employeeLoginDTO
|
* @param employeeLoginDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation(value = "员工登录")//描述当前方法的作用
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public Result<EmployeeLoginVO> login(@RequestBody EmployeeLoginDTO employeeLoginDTO) {
|
public Result<EmployeeLoginVO> login(@RequestBody EmployeeLoginDTO employeeLoginDTO) {
|
||||||
log.info("员工登录:{}", employeeLoginDTO);
|
log.info("员工登录:{}", employeeLoginDTO);
|
||||||
@@ -66,6 +70,7 @@ public class EmployeeController {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("员工退出")
|
||||||
@PostMapping("/logout")
|
@PostMapping("/logout")
|
||||||
public Result<String> logout() {
|
public Result<String> logout() {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ public class EmployeeServiceImpl implements EmployeeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//密码比对
|
//密码比对
|
||||||
// TODO 后期需要进行md5加密,然后再进行比对
|
//对前端传过来的明文123456密码进行md5加密处理
|
||||||
|
password = DigestUtils.md5DigestAsHex(password.getBytes());
|
||||||
if (!password.equals(employee.getPassword())) {
|
if (!password.equals(employee.getPassword())) {
|
||||||
//密码错误
|
//密码错误
|
||||||
throw new PasswordErrorException(MessageConstant.PASSWORD_ERROR);
|
throw new PasswordErrorException(MessageConstant.PASSWORD_ERROR);
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ sky:
|
|||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
host: localhost
|
host: localhost
|
||||||
port: 3306
|
port: 3306
|
||||||
database: sky_take_out
|
database: sky_take_out2
|
||||||
username: root
|
username: root
|
||||||
password: 1234
|
password: 1234
|
||||||
|
|||||||
Reference in New Issue
Block a user