mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-06-25 06:30:48 +08:00
整体优化代码结构
This commit is contained in:
@@ -6,7 +6,7 @@ import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.front.LikeFrontThreadLocal;
|
||||
import com.mdd.front.service.IArticleService;
|
||||
import com.mdd.front.validate.PageParam;
|
||||
import com.mdd.front.validate.PageValidate;
|
||||
import com.mdd.front.vo.article.ArticleCateVo;
|
||||
import com.mdd.front.vo.article.ArticleCollectVo;
|
||||
import com.mdd.front.vo.article.ArticleDetailVo;
|
||||
@@ -32,10 +32,10 @@ public class ArticleController {
|
||||
* 文章分类
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @return AjaxResult<List<ArticleCateVo>>
|
||||
*/
|
||||
@GetMapping("/category")
|
||||
public Object category() {
|
||||
public AjaxResult<List<ArticleCateVo>> category() {
|
||||
List<ArticleCateVo> list = iArticleService.category();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
@@ -44,13 +44,13 @@ public class ArticleController {
|
||||
* 文章列表
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @return AjaxResult<PageResult<ArticleListVo>>
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(@Validated PageParam pageParam,
|
||||
@RequestParam(value = "cid", defaultValue = "0") Integer cid) {
|
||||
public AjaxResult<PageResult<ArticleListVo>> list(@Validated PageValidate pageValidate,
|
||||
@RequestParam(value = "cid", defaultValue = "0") Integer cid) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
PageResult<ArticleListVo> list = iArticleService.list(pageParam, cid, userId);
|
||||
PageResult<ArticleListVo> list = iArticleService.list(pageValidate, cid, userId);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@@ -58,10 +58,10 @@ public class ArticleController {
|
||||
* 文章详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @return AjaxResult<ArticleDetailVo>
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
public AjaxResult<ArticleDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
ArticleDetailVo vo = iArticleService.detail(id, userId);
|
||||
return AjaxResult.success(vo);
|
||||
@@ -71,13 +71,13 @@ public class ArticleController {
|
||||
* 文章收藏
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @return Object
|
||||
* @param pageValidate 分页参数
|
||||
* @return AjaxResult<PageResult<ArticleCollectVo>>
|
||||
*/
|
||||
@GetMapping("/collect")
|
||||
public Object collect(@Validated PageParam pageParam) {
|
||||
public AjaxResult<PageResult<ArticleCollectVo>> collect(@Validated PageValidate pageValidate) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
PageResult<ArticleCollectVo> list = iArticleService.collect(pageParam, userId);
|
||||
PageResult<ArticleCollectVo> list = iArticleService.collect(pageValidate, userId);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@@ -86,10 +86,10 @@ public class ArticleController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/addCollect")
|
||||
public Object addCollect(@RequestBody Map<String, String> params) {
|
||||
public AjaxResult<Object> addCollect(@RequestBody Map<String, String> params) {
|
||||
Assert.notNull(params.get("articleId"), "articleId参数缺失");
|
||||
Integer articleId = Integer.parseInt(params.get("articleId"));
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
@@ -102,10 +102,10 @@ public class ArticleController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/cancelCollect")
|
||||
public Object cancelCollect(@RequestBody Map<String, String> params) {
|
||||
public AjaxResult<Object> cancelCollect(@RequestBody Map<String, String> params) {
|
||||
Assert.notNull(params.get("articleId"), "id参数缺失");
|
||||
Integer articleId = Integer.parseInt(params.get("articleId"));
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.front.service.IIndexService;
|
||||
import com.mdd.front.validate.PageParam;
|
||||
import com.mdd.front.validate.PageValidate;
|
||||
import com.mdd.front.vo.article.ArticleListVo;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -30,10 +30,10 @@ public class IndexController {
|
||||
* 首页
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @return AjaxResult<Map<String, Object>>
|
||||
*/
|
||||
@GetMapping("/index")
|
||||
public Object index() {
|
||||
public AjaxResult<Map<String, Object>> index() {
|
||||
Map<String, Object> detail = iIndexService.index();
|
||||
return AjaxResult.success(detail);
|
||||
}
|
||||
@@ -43,10 +43,10 @@ public class IndexController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return Object
|
||||
* @return AjaxResult<Map<String, Object>>
|
||||
*/
|
||||
@GetMapping("/decorate")
|
||||
public 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);
|
||||
return AjaxResult.success(detail);
|
||||
}
|
||||
@@ -55,10 +55,10 @@ public class IndexController {
|
||||
* 配置
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @return AjaxResult<Map<String, Object>>
|
||||
*/
|
||||
@GetMapping("/config")
|
||||
public Object config() {
|
||||
public AjaxResult<Map<String, Object>> config() {
|
||||
Map<String, Object> map = iIndexService.config();
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
@@ -68,10 +68,10 @@ public class IndexController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param type 类型 service=服务协议,privacy=隐私协议
|
||||
* @return Object
|
||||
* @return AjaxResult<Map<String, String>>
|
||||
*/
|
||||
@GetMapping("/policy")
|
||||
public Object policy(@RequestParam String type) {
|
||||
public AjaxResult<Map<String, String>> policy(@RequestParam String type) {
|
||||
Map<String, String> map = iIndexService.policy(type);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
@@ -80,10 +80,10 @@ public class IndexController {
|
||||
* 热搜
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @return AjaxResult<List<String>>
|
||||
*/
|
||||
@GetMapping("/hotSearch")
|
||||
public Object hotSearch() {
|
||||
public AjaxResult<List<String>> hotSearch() {
|
||||
List<String> list = iIndexService.hotSearch();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
@@ -92,12 +92,14 @@ public class IndexController {
|
||||
* 搜索
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @param pageValidate 分页参数
|
||||
* @param params 搜素参数
|
||||
* @return AjaxResult<PageResult<ArticleListVo>>
|
||||
*/
|
||||
@GetMapping("/search")
|
||||
public Object search(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<ArticleListVo> list = iIndexService.search(pageParam, params);
|
||||
public AjaxResult<PageResult<ArticleListVo>> search(@Validated PageValidate pageValidate,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<ArticleListVo> list = iIndexService.search(pageValidate, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.mdd.front.controller;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.front.service.ILoginService;
|
||||
import com.mdd.front.validate.RegParam;
|
||||
import com.mdd.front.validate.RegValidate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -27,12 +27,12 @@ public class LoginController {
|
||||
* 注册账号
|
||||
*
|
||||
* @author fzr
|
||||
* @param regParam 参数
|
||||
* @return Object
|
||||
* @param regValidate 参数
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
public Object register(@Validated @RequestBody RegParam regParam) {
|
||||
iLoginService.register(regParam);
|
||||
public AjaxResult<Object> register(@Validated @RequestBody RegValidate regValidate) {
|
||||
iLoginService.register(regValidate);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ public class LoginController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
* @return AjaxResult<Map<String, Object>>
|
||||
*/
|
||||
@PostMapping("/check")
|
||||
public Object check(@RequestBody Map<String, String> params) {
|
||||
public AjaxResult<Map<String, Object>> check(@RequestBody Map<String, String> params) {
|
||||
Assert.notNull(params.get("scene"), "scene参数缺失!");
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
switch (params.get("scene")) {
|
||||
@@ -66,10 +66,10 @@ public class LoginController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
* @return AjaxResult<Map<String, Object>>
|
||||
*/
|
||||
@GetMapping("/oaLogin")
|
||||
public Object oaLogin(@RequestParam Map<String, String> params) {
|
||||
public AjaxResult<Map<String, Object>> oaLogin(@RequestParam Map<String, String> params) {
|
||||
Map<String, Object> map = iLoginService.officeLogin(params);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
@@ -79,10 +79,10 @@ public class LoginController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param url 连接
|
||||
* @return Object
|
||||
* @return AjaxResult<Map<String, String>>
|
||||
*/
|
||||
@GetMapping("/codeUrl")
|
||||
public Object codeUrl(@RequestParam String url) {
|
||||
public AjaxResult<Map<String, String>> codeUrl(@RequestParam String url) {
|
||||
Assert.notNull(url, "url参数不能为空");
|
||||
String uri = iLoginService.codeUrl(url);
|
||||
Map<String, String> response = new LinkedHashMap<>();
|
||||
@@ -95,10 +95,10 @@ public class LoginController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/forgotPassword")
|
||||
public Object forgotPassword(@RequestBody Map<String, String> params) {
|
||||
public AjaxResult<Object> forgotPassword(@RequestBody Map<String, String> params) {
|
||||
iLoginService.forgotPassword(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.mdd.front.controller;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.plugin.notice.NoticeDriver;
|
||||
import com.mdd.common.utils.ToolsUtil;
|
||||
import com.mdd.front.validate.SmsParam;
|
||||
import com.mdd.front.validate.SmsValidate;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -24,14 +24,14 @@ public class SmsController {
|
||||
* 发送短信
|
||||
*
|
||||
* @author fzr
|
||||
* @param smsParam 参数
|
||||
* @return Object
|
||||
* @param smsValidate 参数
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/send")
|
||||
public Object send(@Validated @RequestBody SmsParam smsParam) {
|
||||
public AjaxResult<Object> send(@Validated @RequestBody SmsValidate smsValidate) {
|
||||
Map<String, String> config = new LinkedHashMap<>();
|
||||
config.put("scene", smsParam.getScene());
|
||||
config.put("mobile", smsParam.getMobile());
|
||||
config.put("scene", smsValidate.getScene());
|
||||
config.put("mobile", smsValidate.getMobile());
|
||||
Map<String, String> params = new LinkedHashMap<>();
|
||||
params.put("code", ToolsUtil.randomInt(4));
|
||||
(new NoticeDriver()).handle(config, params);
|
||||
|
||||
@@ -25,10 +25,10 @@ public class UploadController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param request 请求对象
|
||||
* @return Object
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/image")
|
||||
public Object image(HttpServletRequest request) {
|
||||
public AjaxResult<Object> image(HttpServletRequest request) {
|
||||
MultipartFile multipartFile;
|
||||
try {
|
||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||
|
||||
@@ -28,10 +28,10 @@ public class UserController {
|
||||
* 个人中心
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @return AjaxResult<UserCenterVo>
|
||||
*/
|
||||
@GetMapping("/center")
|
||||
public Object center() {
|
||||
public AjaxResult<UserCenterVo> center() {
|
||||
UserCenterVo vo = iUserService.center(LikeFrontThreadLocal.getUserId());
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
@@ -40,10 +40,10 @@ public class UserController {
|
||||
* 个人信息
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @return AjaxResult<UserInfoVo>
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
public Object info() {
|
||||
public AjaxResult<UserInfoVo> info() {
|
||||
UserInfoVo vo = iUserService.info(LikeFrontThreadLocal.getUserId());
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
@@ -53,10 +53,10 @@ public class UserController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@RequestBody Map<String, String> params) {
|
||||
public AjaxResult<Object> edit(@RequestBody Map<String, String> params) {
|
||||
Assert.notNull(params.get("field"), "field参数缺失");
|
||||
Assert.notNull(params.get("value"), "value参数缺失");
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
@@ -69,10 +69,10 @@ public class UserController {
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/changePwd")
|
||||
public Object changePwd(@RequestBody Map<String, String> params) {
|
||||
public AjaxResult<Object> changePwd(@RequestBody Map<String, String> params) {
|
||||
Assert.notNull(params.get("password"), "password参数缺失");
|
||||
if(!Pattern.matches("^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$", params.get("password"))){
|
||||
throw new OperateException("密码必须是6-20字母+数字组合!");
|
||||
@@ -86,10 +86,11 @@ public class UserController {
|
||||
* 绑定手机号
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @param params 参数
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/bindMobile")
|
||||
public Object bindMobile(@RequestBody Map<String, String> params) {
|
||||
public AjaxResult<Object> bindMobile(@RequestBody Map<String, String> params) {
|
||||
Assert.notNull(params.get("type"), "type参数缺失");
|
||||
Assert.notNull(params.get("mobile"), "mobile参数缺失");
|
||||
Assert.notNull(params.get("code"), "code参数缺失");
|
||||
@@ -108,10 +109,11 @@ public class UserController {
|
||||
* 微信手机号
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
* @param params 参数
|
||||
* @return AjaxResult<Object>
|
||||
*/
|
||||
@PostMapping("/mnpMobile")
|
||||
public Object mnpMobile(@RequestBody Map<String, String> params) {
|
||||
public AjaxResult<Object> mnpMobile(@RequestBody Map<String, String> params) {
|
||||
Assert.notNull(params.get("code"), "code参数缺失");
|
||||
iUserService.mnpMobile(params.get("code").trim());
|
||||
return AjaxResult.success();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mdd.front.service;
|
||||
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.front.validate.PageParam;
|
||||
import com.mdd.front.validate.PageValidate;
|
||||
import com.mdd.front.vo.article.ArticleCateVo;
|
||||
import com.mdd.front.vo.article.ArticleCollectVo;
|
||||
import com.mdd.front.vo.article.ArticleDetailVo;
|
||||
@@ -26,12 +26,12 @@ public interface IArticleService {
|
||||
* 文章分类
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param pageValidate 分页参数
|
||||
* @param cid 分类ID
|
||||
* @param userId 用户ID
|
||||
* @return PageResult<ArticleListVo>
|
||||
*/
|
||||
PageResult<ArticleListVo> list(PageParam pageParam, Integer cid, Integer userId);
|
||||
PageResult<ArticleListVo> list(PageValidate pageValidate, Integer cid, Integer userId);
|
||||
|
||||
/**
|
||||
* 文章详情
|
||||
@@ -47,11 +47,11 @@ public interface IArticleService {
|
||||
* 文章收藏
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param pageValidate 分页参数
|
||||
* @param userId 用户ID
|
||||
* @return PageResult<ArticleListVo>
|
||||
*/
|
||||
PageResult<ArticleCollectVo> collect(PageParam pageParam, Integer userId);
|
||||
PageResult<ArticleCollectVo> collect(PageValidate pageValidate, Integer userId);
|
||||
|
||||
/**
|
||||
* 加入收藏
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mdd.front.service;
|
||||
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.front.validate.PageParam;
|
||||
import com.mdd.front.validate.PageValidate;
|
||||
import com.mdd.front.vo.article.ArticleListVo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -57,9 +57,9 @@ public interface IIndexService {
|
||||
* 搜索
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param pageValidate 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<ArticleListVo>
|
||||
*/
|
||||
PageResult<ArticleListVo> search(PageParam pageParam, Map<String, String> params);
|
||||
PageResult<ArticleListVo> search(PageValidate pageValidate, Map<String, String> params);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mdd.front.service;
|
||||
|
||||
import com.mdd.front.validate.RegParam;
|
||||
import com.mdd.front.validate.RegValidate;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -13,9 +13,9 @@ public interface ILoginService {
|
||||
* 账号注册
|
||||
*
|
||||
* @author fzr
|
||||
* @param regParam 参数
|
||||
* @param regValidate 参数
|
||||
*/
|
||||
void register(RegParam regParam);
|
||||
void register(RegValidate regValidate);
|
||||
|
||||
/**
|
||||
* 微信登录
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.article.Article;
|
||||
import com.mdd.common.entity.article.ArticleCategory;
|
||||
import com.mdd.common.entity.article.ArticleCollect;
|
||||
import com.mdd.common.entity.server.Sys;
|
||||
import com.mdd.common.mapper.article.ArticleCategoryMapper;
|
||||
import com.mdd.common.mapper.article.ArticleCollectMapper;
|
||||
import com.mdd.common.mapper.article.ArticleMapper;
|
||||
@@ -18,12 +17,11 @@ import com.mdd.common.utils.StringUtil;
|
||||
import com.mdd.common.utils.TimeUtil;
|
||||
import com.mdd.common.utils.UrlUtil;
|
||||
import com.mdd.front.service.IArticleService;
|
||||
import com.mdd.front.validate.PageParam;
|
||||
import com.mdd.front.validate.PageValidate;
|
||||
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.ArticleListVo;
|
||||
import net.sf.jsqlparser.statement.create.table.Index;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -76,15 +74,15 @@ public class ArticleServiceImpl implements IArticleService {
|
||||
* 文章列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param pageValidate 分页参数
|
||||
* @param cid 分类ID
|
||||
* @param userId 用户ID
|
||||
* @return PageResult<ArticleListVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<ArticleListVo> list(PageParam pageParam, Integer cid, Integer userId) {
|
||||
Integer pageNo = pageParam.getPageNo();
|
||||
Integer pageSize = pageParam.getPageSize();
|
||||
public PageResult<ArticleListVo> list(PageValidate pageValidate, Integer cid, Integer userId) {
|
||||
Integer pageNo = pageValidate.getPageNo();
|
||||
Integer pageSize = pageValidate.getPageSize();
|
||||
|
||||
QueryWrapper<Article> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id,title,image,intro,visit,create_time");
|
||||
@@ -171,14 +169,14 @@ public class ArticleServiceImpl implements IArticleService {
|
||||
* 收藏列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param pageValidate 分页参数
|
||||
* @param userId 用户ID
|
||||
* @return PageResult<ArticleCollectVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<ArticleCollectVo> collect(PageParam pageParam, Integer userId) {
|
||||
Integer pageNo = pageParam.getPageNo();
|
||||
Integer pageSize = pageParam.getPageSize();
|
||||
public PageResult<ArticleCollectVo> collect(PageValidate pageValidate, Integer userId) {
|
||||
Integer pageNo = pageValidate.getPageNo();
|
||||
Integer pageSize = pageValidate.getPageSize();
|
||||
|
||||
MPJQueryWrapper<ArticleCollect> mpjQueryWrapper = new MPJQueryWrapper<>();
|
||||
mpjQueryWrapper.select("t.id,t.article_id,a.title,a.image,a.intro,a.visit,a.create_time")
|
||||
|
||||
@@ -8,16 +8,16 @@ import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.article.Article;
|
||||
import com.mdd.common.entity.decorate.DecoratePage;
|
||||
import com.mdd.common.entity.decorate.DecorateTabbar;
|
||||
import com.mdd.common.entity.DecoratePage;
|
||||
import com.mdd.common.entity.DecorateTabbar;
|
||||
import com.mdd.common.entity.setting.HotSearch;
|
||||
import com.mdd.common.mapper.article.ArticleMapper;
|
||||
import com.mdd.common.mapper.decorate.DecoratePageMapper;
|
||||
import com.mdd.common.mapper.decorate.DecorateTabbarMapper;
|
||||
import com.mdd.common.mapper.DecoratePageMapper;
|
||||
import com.mdd.common.mapper.DecorateTabbarMapper;
|
||||
import com.mdd.common.mapper.setting.HotSearchMapper;
|
||||
import com.mdd.common.utils.*;
|
||||
import com.mdd.front.service.IIndexService;
|
||||
import com.mdd.front.validate.PageParam;
|
||||
import com.mdd.front.validate.PageValidate;
|
||||
import com.mdd.front.vo.article.ArticleListVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -211,13 +211,13 @@ public class IndexServiceImpl implements IIndexService {
|
||||
* 搜索
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param pageValidate 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<ArticleListVo>
|
||||
*/
|
||||
public PageResult<ArticleListVo> search(PageParam pageParam, Map<String, String> params) {
|
||||
Integer pageNo = pageParam.getPageNo();
|
||||
Integer pageSize = pageParam.getPageSize();
|
||||
public PageResult<ArticleListVo> search(PageValidate pageValidate, Map<String, String> params) {
|
||||
Integer pageNo = pageValidate.getPageNo();
|
||||
Integer pageSize = pageValidate.getPageSize();
|
||||
|
||||
MPJQueryWrapper<Article> mpjQueryWrapper = new MPJQueryWrapper<Article>()
|
||||
.selectAll(Article.class)
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mdd.front.service.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
@@ -16,7 +15,7 @@ import com.mdd.common.mapper.user.UserMapper;
|
||||
import com.mdd.common.utils.*;
|
||||
import com.mdd.front.config.FrontConfig;
|
||||
import com.mdd.front.service.ILoginService;
|
||||
import com.mdd.front.validate.RegParam;
|
||||
import com.mdd.front.validate.RegValidate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
|
||||
@@ -47,13 +46,13 @@ public class LoginServiceImpl implements ILoginService {
|
||||
* 注册账号
|
||||
*
|
||||
* @author fzr
|
||||
* @param regParam 参数
|
||||
* @param regValidate 参数
|
||||
*/
|
||||
@Override
|
||||
public void register(RegParam regParam) {
|
||||
public void register(RegValidate regValidate) {
|
||||
User model = userMapper.selectOne(new QueryWrapper<User>()
|
||||
.select("id,sn,username")
|
||||
.eq("username", regParam.getUsername())
|
||||
.eq("username", regValidate.getUsername())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
@@ -61,16 +60,16 @@ public class LoginServiceImpl implements ILoginService {
|
||||
|
||||
Integer sn = this.randMakeSn();
|
||||
String salt = ToolsUtil.randomString(5);
|
||||
String pwd = ToolsUtil.makeMd5(regParam.getPassword()+salt);
|
||||
String pwd = ToolsUtil.makeMd5(regValidate.getPassword()+salt);
|
||||
|
||||
User user = new User();
|
||||
user.setSn(sn);
|
||||
user.setNickname("用户"+sn);
|
||||
user.setUsername(regParam.getUsername());
|
||||
user.setUsername(regValidate.getUsername());
|
||||
user.setPassword(pwd);
|
||||
user.setSalt(salt);
|
||||
user.setAvatar("/api/static/default_avatar.png");
|
||||
user.setChannel(regParam.getClient());
|
||||
user.setChannel(regValidate.getClient());
|
||||
user.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
user.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
userMapper.insert(user);
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.mdd.front.validate;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class BaseParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
public interface change{}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.mdd.front.validate;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.DecimalMax;
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
@@ -12,9 +10,9 @@ import java.io.Serializable;
|
||||
* 分页参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class PageParam extends BaseParam {
|
||||
public class PageValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// 当前分页
|
||||
@DecimalMin(value = "1", message = "pageNo参数必须大于0的数字")
|
||||
@@ -2,8 +2,6 @@ package com.mdd.front.validate;
|
||||
|
||||
import com.mdd.common.validator.annotation.IntegerContains;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
@@ -15,9 +13,9 @@ import java.io.Serializable;
|
||||
* 注册参数类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class RegParam extends BaseParam {
|
||||
public class RegValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "username参数缺失")
|
||||
@NotEmpty(message = "账号不能为空")
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.mdd.front.validate;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
@@ -11,9 +9,9 @@ import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SmsParam extends BaseParam {
|
||||
public class SmsValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "scene参数缺失")
|
||||
@NotEmpty(message = "场景不能为空")
|
||||
Reference in New Issue
Block a user