增加: 接入Swagger3 [未完成]
This commit is contained in:
parent
eff789eb82
commit
7bc8d4fce1
|
|
@ -48,15 +48,15 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
|||
@NotNull Object handler) throws Exception {
|
||||
|
||||
// 请求方法类型
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
if (!(handler instanceof HandlerMethod)) {
|
||||
String reqUri = request.getRequestURI();
|
||||
if (!(handler instanceof HandlerMethod) || !reqUri.startsWith("/api")) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
// 登录权限校验
|
||||
try {
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
Method method = this.obtainAop(handler);
|
||||
String reqUri = request.getRequestURI();
|
||||
this.checkLogin(method, reqUri);
|
||||
} catch (LoginException e) {
|
||||
AjaxResult<Object> result = AjaxResult.failed(e.getCode(), e.getMsg());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.mdd.admin.config;
|
||||
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
@Configuration
|
||||
@EnableOpenApi
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi(){
|
||||
return new Docket(DocumentationType.OAS_30)
|
||||
.apiInfo(apiInfo())
|
||||
.enable(true)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.mdd.admin.controller"))
|
||||
.build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo(){
|
||||
return new ApiInfoBuilder()
|
||||
.title("LikeAdmin【后台】接口文档")
|
||||
.description("likeadmin快速开发管理后台")
|
||||
.version(GlobalConfig.version)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,6 +23,8 @@ spring:
|
|||
mvc:
|
||||
static-path-pattern: /api/static/**
|
||||
throw-exception-if-no-handler-found: true
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
# 数据源配置
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/likeadmin?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
|
|
|
|||
|
|
@ -197,6 +197,11 @@
|
|||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-mp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -44,17 +44,17 @@ public class LikeFrontInterceptor implements HandlerInterceptor {
|
|||
@NonNull HttpServletResponse response,
|
||||
@NonNull Object handler) throws Exception {
|
||||
|
||||
// 记录当前平台
|
||||
String terminal = request.getHeader("terminal");
|
||||
terminal = StringUtils.isEmpty(terminal) ? "1" : terminal;
|
||||
LikeFrontThreadLocal.put("terminal", terminal);
|
||||
|
||||
// 判断请求接口
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
if (!(handler instanceof HandlerMethod)) {
|
||||
String reqUri = request.getRequestURI();
|
||||
if (!(handler instanceof HandlerMethod) || !reqUri.startsWith("/api")) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
// 记录当前平台
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
String terminal = request.getHeader("terminal");
|
||||
LikeFrontThreadLocal.put("terminal", StringUtils.isEmpty(terminal) ? "1" : terminal);
|
||||
|
||||
// 登录权限校验
|
||||
try {
|
||||
Method method = this.obtainAop(handler);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.mdd.front.config;
|
||||
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
@Configuration
|
||||
@EnableOpenApi
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi(){
|
||||
return new Docket(DocumentationType.OAS_30)
|
||||
.apiInfo(apiInfo())
|
||||
.enable(true)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.mdd.front"))
|
||||
.build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo(){
|
||||
return new ApiInfoBuilder()
|
||||
.title("LikeAdmin【前台】接口文档")
|
||||
.description("likeadmin快速开发管理后台")
|
||||
.version(GlobalConfig.version)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,17 +13,17 @@ import com.mdd.front.vo.article.ArticleCateVo;
|
|||
import com.mdd.front.vo.article.ArticleCollectVo;
|
||||
import com.mdd.front.vo.article.ArticleDetailVo;
|
||||
import com.mdd.front.vo.article.ArticleListedVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/article")
|
||||
@Api(tags = "文章管理")
|
||||
public class ArticleController {
|
||||
|
||||
@Resource
|
||||
|
|
@ -37,6 +37,7 @@ public class ArticleController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/category")
|
||||
@ApiOperation(value="文章分类")
|
||||
public AjaxResult<List<ArticleCateVo>> category() {
|
||||
List<ArticleCateVo> list = iArticleService.category();
|
||||
return AjaxResult.success(list);
|
||||
|
|
@ -50,6 +51,7 @@ public class ArticleController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value="文章列表")
|
||||
public AjaxResult<PageResult<ArticleListedVo>> list(@Validated PageValidate pageValidate,
|
||||
@Validated ArticleSearchValidate searchValidate) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
|
|
@ -65,6 +67,7 @@ public class ArticleController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/detail")
|
||||
@ApiOperation(value="文章详情")
|
||||
public AjaxResult<ArticleDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
ArticleDetailVo vo = iArticleService.detail(id, userId);
|
||||
|
|
@ -72,13 +75,14 @@ public class ArticleController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 文章收藏
|
||||
* 收藏列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageValidate 分页参数
|
||||
* @return AjaxResult<PageResult<ArticleCollectVo>>
|
||||
*/
|
||||
@GetMapping("/collect")
|
||||
@GetMapping("/collectList")
|
||||
@ApiOperation(value="收藏列表")
|
||||
public AjaxResult<PageResult<ArticleCollectVo>> collect(@Validated PageValidate pageValidate) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
PageResult<ArticleCollectVo> list = iArticleService.collect(pageValidate, userId);
|
||||
|
|
@ -86,13 +90,14 @@ public class ArticleController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 加入收藏
|
||||
* 收藏加入
|
||||
*
|
||||
* @author fzr
|
||||
* @param collectValidate 参数
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/addCollect")
|
||||
@PostMapping("/collectAdd")
|
||||
@ApiOperation(value="收藏加入")
|
||||
public AjaxResult<Object> addCollect(@Validated @RequestBody ArticleCollectValidate collectValidate) {
|
||||
Integer articleId = collectValidate.getArticleId();
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
|
|
@ -101,13 +106,14 @@ public class ArticleController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 取消收藏
|
||||
* 收藏取消
|
||||
*
|
||||
* @author fzr
|
||||
* @param collectValidate 参数
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/cancelCollect")
|
||||
@PostMapping("/collectCancel")
|
||||
@ApiOperation(value="收藏取消")
|
||||
public AjaxResult<Object> cancelCollect(@Validated @RequestBody ArticleCollectValidate collectValidate) {
|
||||
Integer articleId = collectValidate.getArticleId();
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import com.mdd.front.service.IIndexService;
|
|||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.validate.common.SmsValidate;
|
||||
import com.mdd.front.vo.article.ArticleListedVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -25,11 +27,9 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 主页管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/index")
|
||||
@Api(tags = "主页管理")
|
||||
public class IndexController {
|
||||
|
||||
@Resource
|
||||
|
|
@ -46,6 +46,7 @@ public class IndexController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/index")
|
||||
@ApiOperation(value="首页数据")
|
||||
public AjaxResult<Map<String, Object>> index() {
|
||||
Map<String, Object> detail = iIndexService.index();
|
||||
return AjaxResult.success(detail);
|
||||
|
|
@ -60,6 +61,7 @@ public class IndexController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/decorate")
|
||||
@ApiOperation(value="装修数据")
|
||||
public AjaxResult<Map<String, Object>> decorate(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
Map<String, Object> detail = iIndexService.decorate(id);
|
||||
return AjaxResult.success(detail);
|
||||
|
|
@ -73,6 +75,7 @@ public class IndexController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/config")
|
||||
@ApiOperation(value="公共配置")
|
||||
public AjaxResult<Map<String, Object>> config() {
|
||||
Map<String, Object> map = iIndexService.config();
|
||||
return AjaxResult.success(map);
|
||||
|
|
@ -87,6 +90,7 @@ public class IndexController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/policy")
|
||||
@ApiOperation(value="政策协议")
|
||||
public AjaxResult<Map<String, String>> policy(@RequestParam String type) {
|
||||
Map<String, String> map = iIndexService.policy(type);
|
||||
return AjaxResult.success(map);
|
||||
|
|
@ -100,6 +104,7 @@ public class IndexController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/hotSearch")
|
||||
@ApiOperation(value="热门搜索")
|
||||
public AjaxResult<List<String>> hotSearch() {
|
||||
List<String> list = iIndexService.hotSearch();
|
||||
return AjaxResult.success(list);
|
||||
|
|
@ -115,6 +120,7 @@ public class IndexController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/search")
|
||||
@ApiOperation(value="搜索文章")
|
||||
public AjaxResult<PageResult<ArticleListedVo>> search(@Validated PageValidate pageValidate,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<ArticleListedVo> list = iIndexService.search(pageValidate, params);
|
||||
|
|
@ -130,6 +136,7 @@ public class IndexController {
|
|||
*/
|
||||
@NotLogin
|
||||
@PostMapping("/sendSms")
|
||||
@ApiOperation(value="发送短信")
|
||||
public AjaxResult<Object> sendSms(@Validated @RequestBody SmsValidate smsValidate) {
|
||||
NoticeRecord noticeRecord = noticeRecordMapper.selectOne(new QueryWrapper<NoticeRecord>()
|
||||
.eq("account", smsValidate.getMobile())
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import com.mdd.front.service.ILoginService;
|
|||
import com.mdd.front.validate.login.*;
|
||||
import com.mdd.front.vo.login.LoginUrlsVo;
|
||||
import com.mdd.front.vo.login.LoginTokenVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -15,12 +17,10 @@ import javax.annotation.Resource;
|
|||
import javax.servlet.http.HttpSession;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 登录管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/login")
|
||||
@Api(tags = "登录管理")
|
||||
public class LoginController {
|
||||
|
||||
@Resource
|
||||
|
|
@ -35,6 +35,7 @@ public class LoginController {
|
|||
*/
|
||||
@NotLogin
|
||||
@PostMapping("/register")
|
||||
@ApiOperation(value="注册账号")
|
||||
public AjaxResult<Object> register(@Validated @RequestBody RegisterValidate registerValidate) {
|
||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||
String username = registerValidate.getUsername();
|
||||
|
|
@ -53,6 +54,7 @@ public class LoginController {
|
|||
*/
|
||||
@NotLogin
|
||||
@PostMapping("/accountLogin")
|
||||
@ApiOperation(value="账号登录")
|
||||
public AjaxResult<LoginTokenVo> accountLogin(@Validated @RequestBody LoginPwdValidate loginPwdValidate) {
|
||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||
String username = loginPwdValidate.getUsername();
|
||||
|
|
@ -71,6 +73,7 @@ public class LoginController {
|
|||
*/
|
||||
@NotLogin
|
||||
@PostMapping("/mobileLogin")
|
||||
@ApiOperation(value="手机登录")
|
||||
public AjaxResult<LoginTokenVo> mobileLogin(@Validated @RequestBody LoginPhoneValidate loginPhoneValidate) {
|
||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||
String mobile = loginPhoneValidate.getMobile();
|
||||
|
|
@ -89,6 +92,7 @@ public class LoginController {
|
|||
*/
|
||||
@NotLogin
|
||||
@PostMapping("/mnpLogin")
|
||||
@ApiOperation(value="微信登录")
|
||||
public AjaxResult<LoginTokenVo> mnpLogin(@Validated @RequestBody LoginCodeValidate loginCodeValidate) {
|
||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||
String code = loginCodeValidate.getCode();
|
||||
|
|
@ -106,6 +110,7 @@ public class LoginController {
|
|||
*/
|
||||
@NotLogin
|
||||
@PostMapping("/oaLogin")
|
||||
@ApiOperation(value="公众号登录")
|
||||
public AjaxResult<LoginTokenVo> oaLogin(@Validated @RequestBody LoginCodeValidate loginCodeValidate) {
|
||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||
String code = loginCodeValidate.getCode();
|
||||
|
|
@ -123,6 +128,7 @@ public class LoginController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/oaCodeUrl")
|
||||
@ApiOperation(value="公众号链接")
|
||||
public AjaxResult<LoginUrlsVo> oaCodeUrl(@Validated @NotNull() @RequestParam("url") String url) {
|
||||
LoginUrlsVo vo = new LoginUrlsVo();
|
||||
vo.setUrl(iLoginService.oaCodeUrl(url));
|
||||
|
|
@ -138,6 +144,7 @@ public class LoginController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/scanCodeUrl")
|
||||
@ApiOperation(value="PC扫码链接")
|
||||
public AjaxResult<LoginUrlsVo> scanCodeUrl(@Validated @NotNull() @RequestParam("url") String url, HttpSession session) {
|
||||
String qrcodeUrl = iLoginService.scanCodeUrl(url, session);
|
||||
LoginUrlsVo vo = new LoginUrlsVo();
|
||||
|
|
@ -154,6 +161,7 @@ public class LoginController {
|
|||
*/
|
||||
@NotLogin
|
||||
@PostMapping("/scanLogin")
|
||||
@ApiOperation(value="PC扫码登录")
|
||||
public AjaxResult<Object> scanLogin(@Validated @RequestBody LoginScanValidate loginScanValidate, HttpSession session) {
|
||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||
String code = loginScanValidate.getCode();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import com.mdd.front.LikeFrontThreadLocal;
|
|||
import com.mdd.front.service.IPcService;
|
||||
import com.mdd.front.vo.article.PcArticleCenterVo;
|
||||
import com.mdd.front.vo.article.PcArticleDetailVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -17,11 +19,9 @@ import javax.annotation.Resource;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* pc端接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/pc")
|
||||
@Api(tags = "电脑管理")
|
||||
public class PcController {
|
||||
|
||||
@Resource
|
||||
|
|
@ -35,6 +35,7 @@ public class PcController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/index")
|
||||
@ApiOperation(value="主页数据")
|
||||
public AjaxResult<Map<String,Object>> index() {
|
||||
Map<String, Object> index = iPcService.index();
|
||||
return AjaxResult.success(index);
|
||||
|
|
@ -47,6 +48,7 @@ public class PcController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/getConfig")
|
||||
@ApiOperation(value="公共配置")
|
||||
public AjaxResult<Map<String, Object>> getConfig() {
|
||||
Map<String, Object> config = iPcService.getConfig();
|
||||
return AjaxResult.success(config);
|
||||
|
|
@ -60,6 +62,7 @@ public class PcController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/articleCenter")
|
||||
@ApiOperation(value="资讯中心")
|
||||
public AjaxResult<List<PcArticleCenterVo>> articleCenter() {
|
||||
List<PcArticleCenterVo> list = iPcService.articleCenter();
|
||||
return AjaxResult.success(list);
|
||||
|
|
@ -74,6 +77,7 @@ public class PcController {
|
|||
*/
|
||||
@NotLogin
|
||||
@GetMapping("/articleDetail")
|
||||
@ApiOperation(value="文章详情")
|
||||
public AjaxResult<PcArticleDetailVo> articleDetail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
PcArticleDetailVo vo = iPcService.articleDetail(id, userId);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import com.mdd.common.exception.OperateException;
|
|||
import com.mdd.common.plugin.storage.StorageDriver;
|
||||
import com.mdd.common.plugin.storage.UploadFilesVo;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
@ -15,11 +17,9 @@ import org.springframework.web.multipart.MultipartRequest;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 上传管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/upload")
|
||||
@Api(tags = "上传管理")
|
||||
public class UploadController {
|
||||
|
||||
/**
|
||||
|
|
@ -31,6 +31,7 @@ public class UploadController {
|
|||
*/
|
||||
@NotLogin
|
||||
@PostMapping("/image")
|
||||
@ApiOperation(value="上传图片")
|
||||
public AjaxResult<UploadFilesVo> image(HttpServletRequest request) {
|
||||
MultipartFile multipartFile;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ import com.mdd.front.validate.users.UserChangePwdValidate;
|
|||
import com.mdd.front.validate.users.UserUpdateValidate;
|
||||
import com.mdd.front.vo.users.UserCenterVo;
|
||||
import com.mdd.front.vo.users.UserInfoVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 用户管理表
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/user")
|
||||
@Api(tags = "用户管理")
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
|
|
@ -33,6 +33,7 @@ public class UserController {
|
|||
* @return AjaxResult<UserCenterVo>
|
||||
*/
|
||||
@GetMapping("/center")
|
||||
@ApiOperation(value="个人中心")
|
||||
public AjaxResult<UserCenterVo> center() {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
UserCenterVo vo = iUserService.center(userId);
|
||||
|
|
@ -46,6 +47,7 @@ public class UserController {
|
|||
* @return AjaxResult<UserInfoVo>
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
@ApiOperation(value="个人信息")
|
||||
public AjaxResult<UserInfoVo> info() {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
UserInfoVo vo = iUserService.info(userId);
|
||||
|
|
@ -60,6 +62,7 @@ public class UserController {
|
|||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
@ApiOperation(value="编辑信息")
|
||||
public AjaxResult<Object> edit(@Validated @RequestBody UserUpdateValidate updateValidate) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
iUserService.edit(updateValidate, userId);
|
||||
|
|
@ -74,6 +77,7 @@ public class UserController {
|
|||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/changePwd")
|
||||
@ApiOperation(value="修改密码")
|
||||
public AjaxResult<Object> changePwd(@Validated @RequestBody UserChangePwdValidate passwordValidate) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
iUserService.changePwd(passwordValidate.getPassword(), passwordValidate.getOldPassword(), userId);
|
||||
|
|
@ -89,6 +93,7 @@ public class UserController {
|
|||
*/
|
||||
@NotLogin
|
||||
@PostMapping("/forgotPwd")
|
||||
@ApiOperation(value="忘记密码")
|
||||
public AjaxResult<Object> forgotPwd(@Validated @RequestBody UserForgetPwdValidate userForgetPwdValidate) {
|
||||
iUserService.forgotPwd(userForgetPwdValidate);
|
||||
return AjaxResult.success();
|
||||
|
|
@ -102,6 +107,7 @@ public class UserController {
|
|||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/bindMobile")
|
||||
@ApiOperation(value="绑定手机")
|
||||
public AjaxResult<Object> bindMobile(@Validated @RequestBody UserPhoneBindValidate mobileValidate) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
iUserService.bindMobile(mobileValidate, userId);
|
||||
|
|
@ -116,6 +122,7 @@ public class UserController {
|
|||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/mnpMobile")
|
||||
@ApiOperation(value="微信手机号")
|
||||
public AjaxResult<Object> mnpMobile(@Validated @RequestBody UserPhoneMnpValidate mobileValidate) {
|
||||
iUserService.mnpMobile(mobileValidate.getCode().trim());
|
||||
return AjaxResult.success();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ like:
|
|||
# 服务配置
|
||||
server:
|
||||
port: 8084
|
||||
servlet:
|
||||
context-path: /
|
||||
# servlet:
|
||||
# context-path: /
|
||||
|
||||
# 框架配置
|
||||
spring:
|
||||
|
|
@ -16,6 +16,8 @@ spring:
|
|||
mvc:
|
||||
static-path-pattern: /api/static/**
|
||||
throw-exception-if-no-handler-found: true
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
# 数据源配置
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/local_likeadmin?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
|
|
|
|||
|
|
@ -242,6 +242,12 @@
|
|||
<artifactId>like-common</artifactId>
|
||||
<version>${like.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue