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