优化代码格式

This commit is contained in:
TinyAnts 2023-03-16 10:24:18 +08:00
parent 3cb5582b20
commit 932d46c6ee
10 changed files with 35 additions and 226 deletions

View File

@ -29,12 +29,6 @@ public class ArticleController {
@Resource @Resource
IArticleService iArticleService; IArticleService iArticleService;
/**
* 文章分类
*
* @author fzr
* @return AjaxResult<List<ArticleCateVo>>
*/
@NotLogin @NotLogin
@GetMapping("/category") @GetMapping("/category")
@ApiOperation(value="文章分类") @ApiOperation(value="文章分类")
@ -43,80 +37,52 @@ public class ArticleController {
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/**
* 文章列表
*
* @author fzr
* @return AjaxResult<PageResult<ArticleListVo>>
*/
@NotLogin @NotLogin
@GetMapping("/list") @GetMapping("/list")
@ApiOperation(value="文章列表") @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();
PageResult<ArticleListedVo> list = iArticleService.list(userId, pageValidate, searchValidate); PageResult<ArticleListedVo> list = iArticleService.list(userId, pageValidate, searchValidate);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/**
* 文章详情
*
* @author fzr
* @return AjaxResult<ArticleDetailVo>
*/
@NotLogin @NotLogin
@GetMapping("/detail") @GetMapping("/detail")
@ApiOperation(value="文章详情") @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);
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }
/**
* 收藏列表
*
* @author fzr
* @param pageValidate 分页参数
* @return AjaxResult<PageResult<ArticleCollectVo>>
*/
@GetMapping("/collectList") @GetMapping("/collectList")
@ApiOperation(value="收藏列表") @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);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/**
* 收藏加入
*
* @author fzr
* @param collectValidate 参数
* @return AjaxResult<Object>
*/
@PostMapping("/collectAdd") @PostMapping("/collectAdd")
@ApiOperation(value="收藏加入") @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();
iArticleService.addCollect(articleId, userId); iArticleService.addCollect(articleId, userId);
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 收藏取消
*
* @author fzr
* @param collectValidate 参数
* @return AjaxResult<Object>
*/
@PostMapping("/collectCancel") @PostMapping("/collectCancel")
@ApiOperation(value="收藏取消") @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();
iArticleService.cancelCollect(articleId, userId); iArticleService.cancelCollect(articleId, userId);
return AjaxResult.success(); return AjaxResult.success();
} }

View File

@ -3,7 +3,6 @@ package com.mdd.front.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mdd.common.aop.NotLogin; import com.mdd.common.aop.NotLogin;
import com.mdd.common.core.AjaxResult; import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.entity.notice.NoticeRecord; import com.mdd.common.entity.notice.NoticeRecord;
import com.mdd.common.enums.NoticeEnum; import com.mdd.common.enums.NoticeEnum;
import com.mdd.common.exception.OperateException; import com.mdd.common.exception.OperateException;
@ -14,9 +13,7 @@ import com.mdd.common.util.StringUtils;
import com.mdd.common.util.ToolUtils; import com.mdd.common.util.ToolUtils;
import com.mdd.common.validator.annotation.IDMust; import com.mdd.common.validator.annotation.IDMust;
import com.mdd.front.service.IIndexService; import com.mdd.front.service.IIndexService;
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 io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -38,12 +35,6 @@ public class IndexController {
@Resource @Resource
IIndexService iIndexService; IIndexService iIndexService;
/**
* 首页
*
* @author fzr
* @return AjaxResult<Map<String, Object>>
*/
@NotLogin @NotLogin
@GetMapping("/index") @GetMapping("/index")
@ApiOperation(value="首页数据") @ApiOperation(value="首页数据")
@ -52,13 +43,6 @@ public class IndexController {
return AjaxResult.success(detail); return AjaxResult.success(detail);
} }
/**
* 装修
*
* @author fzr
* @param id 主键
* @return AjaxResult<Map<String, Object>>
*/
@NotLogin @NotLogin
@GetMapping("/decorate") @GetMapping("/decorate")
@ApiOperation(value="装修数据") @ApiOperation(value="装修数据")
@ -67,12 +51,6 @@ public class IndexController {
return AjaxResult.success(detail); return AjaxResult.success(detail);
} }
/**
* 配置
*
* @author fzr
* @return AjaxResult<Map<String, Object>>
*/
@NotLogin @NotLogin
@GetMapping("/config") @GetMapping("/config")
@ApiOperation(value="公共配置") @ApiOperation(value="公共配置")
@ -81,13 +59,6 @@ public class IndexController {
return AjaxResult.success(map); return AjaxResult.success(map);
} }
/**
* 协议
*
* @author fzr
* @param type 类型 service=服务协议,privacy=隐私协议
* @return AjaxResult<Map<String, String>>
*/
@NotLogin @NotLogin
@GetMapping("/policy") @GetMapping("/policy")
@ApiOperation(value="政策协议") @ApiOperation(value="政策协议")
@ -96,12 +67,6 @@ public class IndexController {
return AjaxResult.success(map); return AjaxResult.success(map);
} }
/**
* 热搜
*
* @author fzr
* @return AjaxResult<List<String>>
*/
@NotLogin @NotLogin
@GetMapping("/hotSearch") @GetMapping("/hotSearch")
@ApiOperation(value="热门搜索") @ApiOperation(value="热门搜索")
@ -110,13 +75,6 @@ public class IndexController {
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/**
* 发送短信
*
* @author fzr
* @param smsValidate 参数
* @return AjaxResult<Object>
*/
@NotLogin @NotLogin
@PostMapping("/sendSms") @PostMapping("/sendSms")
@ApiOperation(value="发送短信") @ApiOperation(value="发送短信")

View File

@ -26,13 +26,6 @@ public class LoginController {
@Resource @Resource
ILoginService iLoginService; ILoginService iLoginService;
/**
* 注册账号
*
* @author fzr
* @param registerValidate 注册参数
* @return AjaxResult<Object>
*/
@NotLogin @NotLogin
@PostMapping("/register") @PostMapping("/register")
@ApiOperation(value="注册账号") @ApiOperation(value="注册账号")
@ -45,13 +38,6 @@ public class LoginController {
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 账号登录
*
* @author fzr
* @param loginPwdValidate 登录参数
* @return AjaxResult<LoginTokenVo>
*/
@NotLogin @NotLogin
@PostMapping("/accountLogin") @PostMapping("/accountLogin")
@ApiOperation(value="账号登录") @ApiOperation(value="账号登录")
@ -64,13 +50,6 @@ public class LoginController {
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }
/**
* 手机登录
*
* @author fzr
* @param loginPhoneValidate 登录参数
* @return AjaxResult<LoginTokenVo>
*/
@NotLogin @NotLogin
@PostMapping("/mobileLogin") @PostMapping("/mobileLogin")
@ApiOperation(value="手机登录") @ApiOperation(value="手机登录")
@ -83,13 +62,6 @@ public class LoginController {
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }
/**
* 微信登录
*
* @author fzr
* @param loginCodeValidate 登录参数
* @return AjaxResult<LoginTokenVo>
*/
@NotLogin @NotLogin
@PostMapping("/mnpLogin") @PostMapping("/mnpLogin")
@ApiOperation(value="微信登录") @ApiOperation(value="微信登录")
@ -101,13 +73,6 @@ public class LoginController {
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }
/**
* 公众号登录
*
* @author fzr
* @param loginCodeValidate 登录参数
* @return AjaxResult<LoginTokenVo>
*/
@NotLogin @NotLogin
@PostMapping("/oaLogin") @PostMapping("/oaLogin")
@ApiOperation(value="公众号登录") @ApiOperation(value="公众号登录")
@ -119,13 +84,6 @@ public class LoginController {
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }
/**
* 公众号链接
*
* @author fzr
* @param url 跳转链接
* @return AjaxResult<LoginCodesVo>
*/
@NotLogin @NotLogin
@GetMapping("/oaCodeUrl") @GetMapping("/oaCodeUrl")
@ApiOperation(value="公众号链接") @ApiOperation(value="公众号链接")
@ -135,13 +93,6 @@ public class LoginController {
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }
/**
* 扫码链接
*
* @author fzr
* @param session session
* @return AjaxResult<LoginUrlsVo>
*/
@NotLogin @NotLogin
@GetMapping("/scanCodeUrl") @GetMapping("/scanCodeUrl")
@ApiOperation(value="PC扫码链接") @ApiOperation(value="PC扫码链接")
@ -152,13 +103,6 @@ public class LoginController {
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }
/**
* 扫码登录
*
* @author fzr
* @param loginScanValidate 扫码参数
* @return AjaxResult<Object>
*/
@NotLogin @NotLogin
@PostMapping("/scanLogin") @PostMapping("/scanLogin")
@ApiOperation(value="PC扫码登录") @ApiOperation(value="PC扫码登录")

View File

@ -27,12 +27,6 @@ public class PcController {
@Resource @Resource
IPcService iPcService; IPcService iPcService;
/**
* 主页
*
* @author cjh
* @return AjaxResult<Map<String, Object>>
*/
@NotLogin @NotLogin
@GetMapping("/index") @GetMapping("/index")
@ApiOperation(value="主页数据") @ApiOperation(value="主页数据")
@ -41,11 +35,6 @@ public class PcController {
return AjaxResult.success(index); return AjaxResult.success(index);
} }
/**
* 配置
* @author cjh
* @return AjaxResult<Map<String, Object>>
*/
@NotLogin @NotLogin
@GetMapping("/getConfig") @GetMapping("/getConfig")
@ApiOperation(value="公共配置") @ApiOperation(value="公共配置")
@ -54,12 +43,6 @@ public class PcController {
return AjaxResult.success(config); return AjaxResult.success(config);
} }
/**
* 资讯中心
*
* @author fzr
* @return AjaxResult<List<PcArticleCenterVo>>
*/
@NotLogin @NotLogin
@GetMapping("/articleCenter") @GetMapping("/articleCenter")
@ApiOperation(value="资讯中心") @ApiOperation(value="资讯中心")
@ -68,18 +51,12 @@ public class PcController {
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/**
* 文章详情
*
* @author fzr
* @param id 文章主键
* @return AjaxResult<PcArticleDetailVo>
*/
@NotLogin @NotLogin
@GetMapping("/articleDetail") @GetMapping("/articleDetail")
@ApiOperation(value="文章详情") @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);
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }

View File

@ -22,13 +22,6 @@ import javax.servlet.http.HttpServletRequest;
@Api(tags = "上传管理") @Api(tags = "上传管理")
public class UploadController { public class UploadController {
/**
* 上传图片
*
* @author fzr
* @param request 请求对象
* @return AjaxResult<UploadFilesVo>
*/
@NotLogin @NotLogin
@PostMapping("/image") @PostMapping("/image")
@ApiOperation(value="上传图片") @ApiOperation(value="上传图片")

View File

@ -26,101 +26,63 @@ public class UserController {
@Resource @Resource
IUserService iUserService; IUserService iUserService;
/**
* 个人中心
*
* @author fzr
* @return AjaxResult<UserCenterVo>
*/
@GetMapping("/center") @GetMapping("/center")
@ApiOperation(value="个人中心") @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);
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }
/**
* 个人信息
*
* @author fzr
* @return AjaxResult<UserInfoVo>
*/
@GetMapping("/info") @GetMapping("/info")
@ApiOperation(value="个人信息") @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);
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }
/**
* 编辑信息
*
* @author fzr
* @param updateValidate 参数
* @return AjaxResult<Object>
*/
@PostMapping("/edit") @PostMapping("/edit")
@ApiOperation(value="编辑信息") @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);
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 修改密码
*
* @author fzr
* @param passwordValidate 参数
* @return AjaxResult<Object>
*/
@PostMapping("/changePwd") @PostMapping("/changePwd")
@ApiOperation(value="修改密码") @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);
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 忘记密码
*
* @author fzr
* @param userForgetPwdValidate 参数
* @return AjaxResult<Object>
*/
@NotLogin @NotLogin
@PostMapping("/forgotPwd") @PostMapping("/forgotPwd")
@ApiOperation(value="忘记密码") @ApiOperation(value="忘记密码")
public AjaxResult<Object> forgotPwd(@Validated @RequestBody UserForgetPwdValidate userForgetPwdValidate) { public AjaxResult<Object> forgotPwd(@Validated @RequestBody UserForgetPwdValidate userForgetPwdValidate) {
iUserService.forgotPwd(userForgetPwdValidate); String password = userForgetPwdValidate.getPassword();
String mobile = userForgetPwdValidate.getMobile();
String code = userForgetPwdValidate.getCode();
iUserService.forgotPwd(password, mobile, code);
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 绑定手机号
*
* @author fzr
* @param mobileValidate 参数
* @return AjaxResult<Object>
*/
@PostMapping("/bindMobile") @PostMapping("/bindMobile")
@ApiOperation(value="绑定手机") @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);
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 微信手机号
*
* @author fzr
* @param mobileValidate 参数
* @return AjaxResult<Object>
*/
@PostMapping("/mnpMobile") @PostMapping("/mnpMobile")
@ApiOperation(value="微信手机号") @ApiOperation(value="微信手机号")
public AjaxResult<Object> mnpMobile(@Validated @RequestBody UserPhoneMnpValidate mobileValidate) { public AjaxResult<Object> mnpMobile(@Validated @RequestBody UserPhoneMnpValidate mobileValidate) {

View File

@ -24,6 +24,7 @@ public interface IIndexService {
* 装修 * 装修
* *
* @author fzr * @author fzr
* @param id 装修ID
* @return Map<String, Object> * @return Map<String, Object>
*/ */
Map<String, Object> decorate(Integer id); Map<String, Object> decorate(Integer id);

View File

@ -25,7 +25,7 @@ public interface IPcService {
/** /**
* 资讯中心 * 资讯中心
* *
* @authro fzr * @author fzr
* @return PcArticleCenterVo * @return PcArticleCenterVo
*/ */
List<PcArticleCenterVo> articleCenter(); List<PcArticleCenterVo> articleCenter();
@ -34,7 +34,8 @@ public interface IPcService {
* 文章详情 * 文章详情
* *
* @author fzr * @author fzr
* @param id 文章主键 * @param id 文章ID
* @param userId 用户ID
* @return PcArticleDetailVo * @return PcArticleDetailVo
*/ */
PcArticleDetailVo articleDetail(Integer id, Integer userId); PcArticleDetailVo articleDetail(Integer id, Integer userId);

View File

@ -15,7 +15,7 @@ public interface IUserService {
* 个人中心 * 个人中心
* *
* @author fzr * @author fzr
* @param userId 用户 * @param userId 用户ID
* @return UserCenterVo * @return UserCenterVo
*/ */
UserCenterVo center(Integer userId); UserCenterVo center(Integer userId);
@ -48,7 +48,15 @@ public interface IUserService {
*/ */
void changePwd(String password, String oldPassword, Integer userId); void changePwd(String password, String oldPassword, Integer userId);
void forgotPwd(UserForgetPwdValidate userForgetPwdValidate); /**
* 忘记密码
*
* @author fzr
* @param password 新密码
* @param mobile 手机号
* @param code 验证码
*/
void forgotPwd(String password, String mobile, String code);
/** /**
* 绑定手机 * 绑定手机

View File

@ -204,14 +204,13 @@ public class UserServiceImpl implements IUserService {
/** /**
* 忘记密码 * 忘记密码
* *
* @param userForgetPwdValidate * @author fzr
* @param password 新密码
* @param mobile 手机号
* @param code 验证码
*/ */
@Override @Override
public void forgotPwd(UserForgetPwdValidate userForgetPwdValidate) { public void forgotPwd(String password, String mobile, String code) {
String mobile = userForgetPwdValidate.getMobile();
String code = userForgetPwdValidate.getCode();
String password = userForgetPwdValidate.getPassword();
// 校验验证码 // 校验验证码
int sceneCode = NoticeEnum.FORGOT_PASSWORD_CODE.getCode(); int sceneCode = NoticeEnum.FORGOT_PASSWORD_CODE.getCode();
if (!NoticeCheck.verify(sceneCode, code)) { if (!NoticeCheck.verify(sceneCode, code)) {