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