优化代码
This commit is contained in:
parent
e211426c1a
commit
bd97df6f7b
|
|
@ -8,6 +8,7 @@ import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.common.enums.AlbumEnum;
|
import com.mdd.common.enums.AlbumEnum;
|
||||||
import com.mdd.common.exception.OperateException;
|
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.utils.StringUtil;
|
import com.mdd.common.utils.StringUtil;
|
||||||
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;
|
||||||
|
|
@ -24,7 +25,7 @@ import java.util.Map;
|
||||||
* 上传管理
|
* 上传管理
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("api/common/upload")
|
@RequestMapping("api/upload")
|
||||||
public class UploadController {
|
public class UploadController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -35,43 +36,38 @@ public class UploadController {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param request 请求对象
|
* @param request 请求对象
|
||||||
* @return AjaxResult<Object>
|
* @return AjaxResult<UploadFilesVo>
|
||||||
*/
|
*/
|
||||||
@Log(title = "上传图片", requestType = RequestType.File)
|
@Log(title = "上传图片", requestType = RequestType.File)
|
||||||
@PostMapping("/image")
|
@PostMapping("/image")
|
||||||
public AjaxResult<Object> image(HttpServletRequest request) {
|
public AjaxResult<UploadFilesVo> image(HttpServletRequest request) {
|
||||||
MultipartFile multipartFile;
|
MultipartFile multipartFile;
|
||||||
try {
|
try {
|
||||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return AjaxResult.failed("请正确选择上传图片");
|
throw new OperateException("请正确选择上传图片!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (multipartFile == null) {
|
if (multipartFile == null) {
|
||||||
return AjaxResult.failed("请选择上传图片");
|
throw new OperateException("请选择上传图片!");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
StorageDriver storageDriver = new StorageDriver();
|
||||||
StorageDriver storageDriver = new StorageDriver();
|
UploadFilesVo vo = storageDriver.upload(multipartFile, "image", AlbumEnum.IMAGE.getCode());
|
||||||
Map<String, Object> map = storageDriver.upload(multipartFile, "image", AlbumEnum.IMAGE.getCode());
|
String cid = StringUtil.isNotEmpty(request.getParameter("cid")) ? request.getParameter("cid") : "0";
|
||||||
String cid = StringUtil.isNotEmpty(request.getParameter("cid")) ? request.getParameter("cid") : "0";
|
|
||||||
|
|
||||||
Map<String, String> album = new LinkedHashMap<>();
|
Map<String, String> album = new LinkedHashMap<>();
|
||||||
album.put("aid", String.valueOf(LikeAdminThreadLocal.getAdminId()));
|
album.put("aid", String.valueOf(LikeAdminThreadLocal.getAdminId()));
|
||||||
album.put("cid", cid);
|
album.put("cid", cid);
|
||||||
album.put("type", String.valueOf(AlbumEnum.IMAGE.getCode()));
|
album.put("type", String.valueOf(AlbumEnum.IMAGE.getCode()));
|
||||||
album.put("size", map.get("size").toString());
|
album.put("size", vo.getSize().toString());
|
||||||
album.put("ext", map.get("ext").toString());
|
album.put("ext", vo.getExt());
|
||||||
album.put("url", map.get("url").toString());
|
album.put("url", vo.getUrl());
|
||||||
album.put("name", map.get("name").toString());
|
album.put("name", vo.getName());
|
||||||
Integer id = iAlbumsService.albumAdd(album);
|
Integer id = iAlbumsService.albumAdd(album);
|
||||||
|
|
||||||
map.put("id", id);
|
vo.setId(id);
|
||||||
|
return AjaxResult.success(vo);
|
||||||
return AjaxResult.success(map);
|
|
||||||
} catch (OperateException e) {
|
|
||||||
return AjaxResult.failed(e.getMsg());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -79,43 +75,38 @@ public class UploadController {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param request 请求对象
|
* @param request 请求对象
|
||||||
* @return AjaxResult<Object>
|
* @return AjaxResult<UploadFilesVo>
|
||||||
*/
|
*/
|
||||||
@Log(title = "上传视频", requestType = RequestType.File)
|
@Log(title = "上传视频", requestType = RequestType.File)
|
||||||
@PostMapping("/video")
|
@PostMapping("/video")
|
||||||
public AjaxResult<Object> video(HttpServletRequest request) {
|
public AjaxResult<UploadFilesVo> video(HttpServletRequest request) {
|
||||||
MultipartFile multipartFile;
|
MultipartFile multipartFile;
|
||||||
try {
|
try {
|
||||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return AjaxResult.failed("请正确选择上传视频");
|
throw new OperateException("请选择上传视频!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (multipartFile == null) {
|
if (multipartFile == null) {
|
||||||
return AjaxResult.failed("请选择上传视频");
|
throw new OperateException("请选择上传视频!");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
StorageDriver storageDriver = new StorageDriver();
|
||||||
StorageDriver storageDriver = new StorageDriver();
|
UploadFilesVo vo = storageDriver.upload(multipartFile, "video", AlbumEnum.Video.getCode());
|
||||||
Map<String, Object> map = storageDriver.upload(multipartFile, "video", AlbumEnum.Video.getCode());
|
String cid = StringUtil.isNotEmpty(request.getParameter("cid")) ? request.getParameter("cid") : "0";
|
||||||
String cid = StringUtil.isNotEmpty(request.getParameter("cid")) ? request.getParameter("cid") : "0";
|
|
||||||
|
|
||||||
Map<String, String> album = new LinkedHashMap<>();
|
Map<String, String> album = new LinkedHashMap<>();
|
||||||
album.put("cid", cid);
|
album.put("cid", cid);
|
||||||
album.put("aid", String.valueOf(LikeAdminThreadLocal.getAdminId()));
|
album.put("aid", String.valueOf(LikeAdminThreadLocal.getAdminId()));
|
||||||
album.put("type", String.valueOf(AlbumEnum.Video.getCode()));
|
album.put("type", String.valueOf(AlbumEnum.Video.getCode()));
|
||||||
album.put("ext", map.get("ext").toString());
|
album.put("ext", vo.getExt());
|
||||||
album.put("size", map.get("size").toString());
|
album.put("size", vo.getSize().toString());
|
||||||
album.put("url", map.get("url").toString());
|
album.put("url", vo.getUrl());
|
||||||
album.put("name", map.get("name").toString());
|
album.put("name", vo.getName());
|
||||||
Integer id = iAlbumsService.albumAdd(album);
|
Integer id = iAlbumsService.albumAdd(album);
|
||||||
|
|
||||||
map.put("id", id);
|
vo.setId(id);
|
||||||
|
return AjaxResult.success(vo);
|
||||||
return AjaxResult.success(map);
|
|
||||||
} catch (OperateException e) {
|
|
||||||
return AjaxResult.failed(e.getMsg());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public class SmsNotice {
|
||||||
// 通知类型: [1=业务, 2=验证码]
|
// 通知类型: [1=业务, 2=验证码]
|
||||||
if (smsTemplate.getType().equals(2) && StringUtil.isNotNull(params.get("code"))) {
|
if (smsTemplate.getType().equals(2) && StringUtil.isNotNull(params.get("code"))) {
|
||||||
String code = params.get("code").toLowerCase();
|
String code = params.get("code").toLowerCase();
|
||||||
RedisUtil.set(GlobalConfig.redisSmsCode+scene+":"+mobile, code);
|
RedisUtil.set(GlobalConfig.redisSmsCode+scene+":"+mobile, code, 900);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,13 @@ public class StorageDriver {
|
||||||
public StorageDriver() {
|
public StorageDriver() {
|
||||||
this.engine = ConfigUtil.get("storage", "default", "local");
|
this.engine = ConfigUtil.get("storage", "default", "local");
|
||||||
|
|
||||||
Map<String, String> config1;
|
Map<String, String> config;
|
||||||
config1 = ConfigUtil.getMap("storage", this.engine);
|
config = ConfigUtil.getMap("storage", this.engine);
|
||||||
if (config1 == null) {
|
if (config == null) {
|
||||||
config1 = new HashMap<>();
|
config = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config = config1;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -47,8 +47,9 @@ public class StorageDriver {
|
||||||
* @param multipartFile 文件对象
|
* @param multipartFile 文件对象
|
||||||
* @param folder 文件夹
|
* @param folder 文件夹
|
||||||
* @param type 类型: 10=图片, 20=视频
|
* @param type 类型: 10=图片, 20=视频
|
||||||
|
* @return UploadFilesVo
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> upload(MultipartFile multipartFile, String folder, Integer type) {
|
public UploadFilesVo upload(MultipartFile multipartFile, String folder, Integer type) {
|
||||||
this.checkFile(multipartFile, type);
|
this.checkFile(multipartFile, type);
|
||||||
String key = this.buildSaveName(multipartFile);
|
String key = this.buildSaveName(multipartFile);
|
||||||
switch (this.engine) {
|
switch (this.engine) {
|
||||||
|
|
@ -74,14 +75,22 @@ public class StorageDriver {
|
||||||
String origFileExt = origFileName.substring(origFileName.lastIndexOf(".")).replace(".", "");
|
String origFileExt = origFileName.substring(origFileName.lastIndexOf(".")).replace(".", "");
|
||||||
String newFileName = folder + "/" + key;
|
String newFileName = folder + "/" + key;
|
||||||
|
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
UploadFilesVo vo = new UploadFilesVo();
|
||||||
map.put("id", 0);
|
vo.setId(0);
|
||||||
map.put("name", multipartFile.getOriginalFilename());
|
vo.setName(multipartFile.getOriginalFilename());
|
||||||
map.put("size", multipartFile.getSize());
|
vo.setSize(multipartFile.getSize());
|
||||||
map.put("ext", origFileExt.toLowerCase());
|
vo.setExt(origFileExt.toLowerCase());
|
||||||
map.put("url", newFileName);
|
vo.setUrl(newFileName);
|
||||||
map.put("path", UrlUtil.toAbsoluteUrl(newFileName));
|
vo.setPath(UrlUtil.toAbsoluteUrl(newFileName));
|
||||||
return map;
|
|
||||||
|
// Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
// map.put("id", 0);
|
||||||
|
// map.put("name", multipartFile.getOriginalFilename());
|
||||||
|
// map.put("size", multipartFile.getSize());
|
||||||
|
// map.put("ext", origFileExt.toLowerCase());
|
||||||
|
// map.put("url", newFileName);
|
||||||
|
// map.put("path", UrlUtil.toAbsoluteUrl(newFileName));
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.mdd.common.plugin.storage;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UploadFilesVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private Long size;
|
||||||
|
private String ext;
|
||||||
|
private String url;
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,22 +1,21 @@
|
||||||
package com.mdd.front.controller;
|
package com.mdd.front.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
||||||
import com.mdd.common.core.AjaxResult;
|
import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.common.core.PageResult;
|
import com.mdd.common.core.PageResult;
|
||||||
import com.mdd.common.validator.annotation.IDMust;
|
import com.mdd.common.validator.annotation.IDMust;
|
||||||
import com.mdd.front.LikeFrontThreadLocal;
|
import com.mdd.front.LikeFrontThreadLocal;
|
||||||
import com.mdd.front.service.IArticleService;
|
import com.mdd.front.service.IArticleService;
|
||||||
import com.mdd.front.validate.PageValidate;
|
import com.mdd.front.validate.ArticleCollectValidate;
|
||||||
|
import com.mdd.front.validate.commons.PageValidate;
|
||||||
import com.mdd.front.vo.article.ArticleCateVo;
|
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.ArticleListVo;
|
import com.mdd.front.vo.article.ArticleListedVo;
|
||||||
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;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章管理
|
* 文章管理
|
||||||
|
|
@ -47,10 +46,10 @@ public class ArticleController {
|
||||||
* @return AjaxResult<PageResult<ArticleListVo>>
|
* @return AjaxResult<PageResult<ArticleListVo>>
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult<PageResult<ArticleListVo>> list(@Validated PageValidate pageValidate,
|
public AjaxResult<PageResult<ArticleListedVo>> list(@Validated PageValidate pageValidate,
|
||||||
@RequestParam(value = "cid", defaultValue = "0") Integer cid) {
|
@RequestParam(value = "cid", defaultValue = "0") Integer cid) {
|
||||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||||
PageResult<ArticleListVo> list = iArticleService.list(pageValidate, cid, userId);
|
PageResult<ArticleListedVo> list = iArticleService.list(pageValidate, cid, userId);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,13 +84,12 @@ public class ArticleController {
|
||||||
* 加入收藏
|
* 加入收藏
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param collectValidate 参数
|
||||||
* @return AjaxResult<Object>
|
* @return AjaxResult<Object>
|
||||||
*/
|
*/
|
||||||
@PostMapping("/addCollect")
|
@PostMapping("/addCollect")
|
||||||
public AjaxResult<Object> addCollect(@RequestBody Map<String, String> params) {
|
public AjaxResult<Object> addCollect(@Validated @RequestBody ArticleCollectValidate collectValidate) {
|
||||||
Assert.notNull(params.get("articleId"), "articleId参数缺失");
|
Integer articleId = collectValidate.getArticleId();
|
||||||
Integer articleId = Integer.parseInt(params.get("articleId"));
|
|
||||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||||
iArticleService.addCollect(articleId, userId);
|
iArticleService.addCollect(articleId, userId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
|
|
@ -101,13 +99,12 @@ public class ArticleController {
|
||||||
* 取消收藏
|
* 取消收藏
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param collectValidate 参数
|
||||||
* @return AjaxResult<Object>
|
* @return AjaxResult<Object>
|
||||||
*/
|
*/
|
||||||
@PostMapping("/cancelCollect")
|
@PostMapping("/cancelCollect")
|
||||||
public AjaxResult<Object> cancelCollect(@RequestBody Map<String, String> params) {
|
public AjaxResult<Object> cancelCollect(@Validated @RequestBody ArticleCollectValidate collectValidate) {
|
||||||
Assert.notNull(params.get("articleId"), "id参数缺失");
|
Integer articleId = collectValidate.getArticleId();
|
||||||
Integer articleId = Integer.parseInt(params.get("articleId"));
|
|
||||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||||
iArticleService.cancelCollect(articleId, userId);
|
iArticleService.cancelCollect(articleId, userId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.common.core.PageResult;
|
import com.mdd.common.core.PageResult;
|
||||||
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.PageValidate;
|
import com.mdd.front.validate.commons.PageValidate;
|
||||||
import com.mdd.front.vo.article.ArticleListVo;
|
import com.mdd.front.vo.article.ArticleListedVo;
|
||||||
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;
|
||||||
|
|
@ -97,9 +97,9 @@ public class IndexController {
|
||||||
* @return AjaxResult<PageResult<ArticleListVo>>
|
* @return AjaxResult<PageResult<ArticleListVo>>
|
||||||
*/
|
*/
|
||||||
@GetMapping("/search")
|
@GetMapping("/search")
|
||||||
public AjaxResult<PageResult<ArticleListVo>> search(@Validated PageValidate pageValidate,
|
public AjaxResult<PageResult<ArticleListedVo>> search(@Validated PageValidate pageValidate,
|
||||||
@RequestParam Map<String, String> params) {
|
@RequestParam Map<String, String> params) {
|
||||||
PageResult<ArticleListVo> list = iIndexService.search(pageValidate, params);
|
PageResult<ArticleListedVo> list = iIndexService.search(pageValidate, params);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@ package com.mdd.front.controller;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||||
import com.mdd.common.core.AjaxResult;
|
import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.front.service.ILoginService;
|
import com.mdd.front.service.ILoginService;
|
||||||
import com.mdd.front.validate.RegValidate;
|
import com.mdd.front.validate.UserRegisterValidate;
|
||||||
|
import com.mdd.front.vo.LoginCodesVo;
|
||||||
|
import com.mdd.front.vo.LoginTokenVo;
|
||||||
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.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -27,12 +28,12 @@ public class LoginController {
|
||||||
* 注册账号
|
* 注册账号
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param regValidate 参数
|
* @param userRegisterValidate 参数
|
||||||
* @return AjaxResult<Object>
|
* @return AjaxResult<Object>
|
||||||
*/
|
*/
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
public AjaxResult<Object> register(@Validated @RequestBody RegValidate regValidate) {
|
public AjaxResult<Object> register(@Validated @RequestBody UserRegisterValidate userRegisterValidate) {
|
||||||
iLoginService.register(regValidate);
|
iLoginService.register(userRegisterValidate);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,24 +42,24 @@ public class LoginController {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param params 参数
|
||||||
* @return AjaxResult<Map<String, Object>>
|
* @return AjaxResult<LoginTokenVo>
|
||||||
*/
|
*/
|
||||||
@PostMapping("/check")
|
@PostMapping("/check")
|
||||||
public AjaxResult<Map<String, Object>> check(@RequestBody Map<String, String> params) {
|
public AjaxResult<LoginTokenVo> check(@RequestBody Map<String, String> params) {
|
||||||
Assert.notNull(params.get("scene"), "scene参数缺失!");
|
Assert.notNull(params.get("scene"), "scene参数缺失!");
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
LoginTokenVo vo = new LoginTokenVo();
|
||||||
switch (params.get("scene")) {
|
switch (params.get("scene")) {
|
||||||
case "mnp":
|
case "mnp":
|
||||||
map = iLoginService.mnpLogin(params);
|
vo = iLoginService.mnpLogin(params);
|
||||||
break;
|
break;
|
||||||
case "mobile":
|
case "mobile":
|
||||||
map = iLoginService.mobileLogin(params);
|
vo = iLoginService.mobileLogin(params);
|
||||||
break;
|
break;
|
||||||
case "account":
|
case "account":
|
||||||
map = iLoginService.accountLogin(params);
|
vo = iLoginService.accountLogin(params);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return AjaxResult.success(map);
|
return AjaxResult.success(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,12 +67,12 @@ public class LoginController {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param params 参数
|
||||||
* @return AjaxResult<Map<String, Object>>
|
* @return AjaxResult<LoginTokenVo>
|
||||||
*/
|
*/
|
||||||
@GetMapping("/oaLogin")
|
@GetMapping("/oaLogin")
|
||||||
public AjaxResult<Map<String, Object>> oaLogin(@RequestParam Map<String, String> params) {
|
public AjaxResult<LoginTokenVo> oaLogin(@RequestParam Map<String, String> params) {
|
||||||
Map<String, Object> map = iLoginService.officeLogin(params);
|
LoginTokenVo vo = iLoginService.officeLogin(params);
|
||||||
return AjaxResult.success(map);
|
return AjaxResult.success(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -79,15 +80,15 @@ public class LoginController {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param url 连接
|
* @param url 连接
|
||||||
* @return AjaxResult<Map<String, String>>
|
* @return AjaxResult<LoginCodesVo>
|
||||||
*/
|
*/
|
||||||
@GetMapping("/codeUrl")
|
@GetMapping("/codeUrl")
|
||||||
public AjaxResult<Map<String, String>> codeUrl(@RequestParam String url) {
|
public AjaxResult<LoginCodesVo> codeUrl(@RequestParam String url) {
|
||||||
Assert.notNull(url, "url参数不能为空");
|
Assert.notNull(url, "url参数不能为空");
|
||||||
String uri = iLoginService.codeUrl(url);
|
|
||||||
Map<String, String> response = new LinkedHashMap<>();
|
LoginCodesVo vo = new LoginCodesVo();
|
||||||
response.put("url", uri);
|
vo.setUrl(iLoginService.codeUrl(url));
|
||||||
return AjaxResult.success(response);
|
return AjaxResult.success(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import com.mdd.common.plugin.notice.NoticeDriver;
|
||||||
import com.mdd.common.plugin.notice.NoticeParams;
|
import com.mdd.common.plugin.notice.NoticeParams;
|
||||||
import com.mdd.common.utils.StringUtil;
|
import com.mdd.common.utils.StringUtil;
|
||||||
import com.mdd.common.utils.ToolsUtil;
|
import com.mdd.common.utils.ToolsUtil;
|
||||||
import com.mdd.front.validate.SmsValidate;
|
import com.mdd.front.validate.commons.SmsValidate;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ package com.mdd.front.controller;
|
||||||
|
|
||||||
import com.mdd.common.core.AjaxResult;
|
import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.common.enums.AlbumEnum;
|
import com.mdd.common.enums.AlbumEnum;
|
||||||
|
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.utils.StringUtil;
|
import com.mdd.common.utils.StringUtil;
|
||||||
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;
|
||||||
|
|
@ -11,7 +13,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartRequest;
|
import org.springframework.web.multipart.MultipartRequest;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传管理
|
* 上传管理
|
||||||
|
|
@ -25,19 +26,19 @@ public class UploadController {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param request 请求对象
|
* @param request 请求对象
|
||||||
* @return AjaxResult<Object>
|
* @return AjaxResult<UploadFilesVo>
|
||||||
*/
|
*/
|
||||||
@PostMapping("/image")
|
@PostMapping("/image")
|
||||||
public AjaxResult<Object> image(HttpServletRequest request) {
|
public AjaxResult<UploadFilesVo> image(HttpServletRequest request) {
|
||||||
MultipartFile multipartFile;
|
MultipartFile multipartFile;
|
||||||
try {
|
try {
|
||||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return AjaxResult.failed("请正确选择上传图片");
|
throw new OperateException("请正确选择上传图片!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (multipartFile == null) {
|
if (multipartFile == null) {
|
||||||
return AjaxResult.failed("请选择上传图片");
|
throw new OperateException("请选择上传图片!");
|
||||||
}
|
}
|
||||||
|
|
||||||
String folder = "image";
|
String folder = "image";
|
||||||
|
|
@ -46,8 +47,8 @@ public class UploadController {
|
||||||
}
|
}
|
||||||
|
|
||||||
StorageDriver storageDriver = new StorageDriver();
|
StorageDriver storageDriver = new StorageDriver();
|
||||||
Map<String, Object> map = storageDriver.upload(multipartFile, folder, AlbumEnum.IMAGE.getCode());
|
UploadFilesVo vo = storageDriver.upload(multipartFile, folder, AlbumEnum.IMAGE.getCode());
|
||||||
return AjaxResult.success(map);
|
return AjaxResult.success(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
package com.mdd.front.controller;
|
package com.mdd.front.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
||||||
import com.mdd.common.core.AjaxResult;
|
import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.common.exception.OperateException;
|
|
||||||
import com.mdd.front.LikeFrontThreadLocal;
|
import com.mdd.front.LikeFrontThreadLocal;
|
||||||
import com.mdd.front.service.IUserService;
|
import com.mdd.front.service.IUserService;
|
||||||
import com.mdd.front.vo.user.UserCenterVo;
|
import com.mdd.front.validate.UserBindMobileValidate;
|
||||||
import com.mdd.front.vo.user.UserInfoVo;
|
import com.mdd.front.validate.UserMnpMobileValidate;
|
||||||
|
import com.mdd.front.validate.UserPasswordValidate;
|
||||||
|
import com.mdd.front.validate.UserUpdateValidate;
|
||||||
|
import com.mdd.front.vo.users.UserCenterVo;
|
||||||
|
import com.mdd.front.vo.users.UserInfoVo;
|
||||||
|
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.Arrays;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户管理表
|
* 用户管理表
|
||||||
|
|
@ -52,15 +52,13 @@ public class UserController {
|
||||||
* 编辑信息
|
* 编辑信息
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param updateValidate 参数
|
||||||
* @return AjaxResult<Object>
|
* @return AjaxResult<Object>
|
||||||
*/
|
*/
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
public AjaxResult<Object> edit(@RequestBody Map<String, String> params) {
|
public AjaxResult<Object> edit(@Validated @RequestBody UserUpdateValidate updateValidate) {
|
||||||
Assert.notNull(params.get("field"), "field参数缺失");
|
|
||||||
Assert.notNull(params.get("value"), "value参数缺失");
|
|
||||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||||
iUserService.edit(params, userId);
|
iUserService.edit(updateValidate, userId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,17 +66,13 @@ public class UserController {
|
||||||
* 修改密码
|
* 修改密码
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param passwordValidate 参数
|
||||||
* @return AjaxResult<Object>
|
* @return AjaxResult<Object>
|
||||||
*/
|
*/
|
||||||
@PostMapping("/changePwd")
|
@PostMapping("/changePwd")
|
||||||
public AjaxResult<Object> changePwd(@RequestBody Map<String, String> params) {
|
public AjaxResult<Object> changePwd(@Validated @RequestBody UserPasswordValidate passwordValidate) {
|
||||||
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字母+数字组合!");
|
|
||||||
}
|
|
||||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||||
iUserService.changePwd(params.get("password"), params.getOrDefault("oldPassword", null), userId);
|
iUserService.changePwd(passwordValidate.getPassword(), passwordValidate.getOldPassword(), userId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,22 +80,13 @@ public class UserController {
|
||||||
* 绑定手机号
|
* 绑定手机号
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param mobileValidate 参数
|
||||||
* @return AjaxResult<Object>
|
* @return AjaxResult<Object>
|
||||||
*/
|
*/
|
||||||
@PostMapping("/bindMobile")
|
@PostMapping("/bindMobile")
|
||||||
public AjaxResult<Object> bindMobile(@RequestBody Map<String, String> params) {
|
public AjaxResult<Object> bindMobile(@Validated @RequestBody UserBindMobileValidate mobileValidate) {
|
||||||
Assert.notNull(params.get("type"), "type参数缺失");
|
|
||||||
Assert.notNull(params.get("mobile"), "mobile参数缺失");
|
|
||||||
Assert.notNull(params.get("code"), "code参数缺失");
|
|
||||||
boolean type = Arrays.asList("bind", "change").contains(params.get("type"));
|
|
||||||
Assert.isTrue(type, "type类型只能是[bind/change]");
|
|
||||||
if(!Pattern.matches("^[1][3,4,5,6,7,8,9][0-9]{9}$", params.get("mobile"))){
|
|
||||||
throw new OperateException("手机号格式不正确!");
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||||
iUserService.bindMobile(params, userId);
|
iUserService.bindMobile(mobileValidate, userId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,13 +94,12 @@ public class UserController {
|
||||||
* 微信手机号
|
* 微信手机号
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param mobileValidate 参数
|
||||||
* @return AjaxResult<Object>
|
* @return AjaxResult<Object>
|
||||||
*/
|
*/
|
||||||
@PostMapping("/mnpMobile")
|
@PostMapping("/mnpMobile")
|
||||||
public AjaxResult<Object> mnpMobile(@RequestBody Map<String, String> params) {
|
public AjaxResult<Object> mnpMobile(@Validated @RequestBody UserMnpMobileValidate mobileValidate) {
|
||||||
Assert.notNull(params.get("code"), "code参数缺失");
|
iUserService.mnpMobile(mobileValidate.getCode().trim());
|
||||||
iUserService.mnpMobile(params.get("code").trim());
|
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package com.mdd.front.service;
|
package com.mdd.front.service;
|
||||||
|
|
||||||
import com.mdd.common.core.PageResult;
|
import com.mdd.common.core.PageResult;
|
||||||
import com.mdd.front.validate.PageValidate;
|
import com.mdd.front.validate.commons.PageValidate;
|
||||||
import com.mdd.front.vo.article.ArticleCateVo;
|
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.ArticleListVo;
|
import com.mdd.front.vo.article.ArticleListedVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ public interface IArticleService {
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return PageResult<ArticleListVo>
|
* @return PageResult<ArticleListVo>
|
||||||
*/
|
*/
|
||||||
PageResult<ArticleListVo> list(PageValidate pageValidate, Integer cid, Integer userId);
|
PageResult<ArticleListedVo> list(PageValidate pageValidate, Integer cid, Integer userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章详情
|
* 文章详情
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package com.mdd.front.service;
|
package com.mdd.front.service;
|
||||||
|
|
||||||
import com.mdd.common.core.PageResult;
|
import com.mdd.common.core.PageResult;
|
||||||
import com.mdd.front.validate.PageValidate;
|
import com.mdd.front.validate.commons.PageValidate;
|
||||||
import com.mdd.front.vo.article.ArticleListVo;
|
import com.mdd.front.vo.article.ArticleListedVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -61,5 +61,5 @@ public interface IIndexService {
|
||||||
* @param params 搜索参数
|
* @param params 搜索参数
|
||||||
* @return PageResult<ArticleListVo>
|
* @return PageResult<ArticleListVo>
|
||||||
*/
|
*/
|
||||||
PageResult<ArticleListVo> search(PageValidate pageValidate, Map<String, String> params);
|
PageResult<ArticleListedVo> search(PageValidate pageValidate, Map<String, String> params);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.mdd.front.service;
|
package com.mdd.front.service;
|
||||||
|
|
||||||
import com.mdd.front.validate.RegValidate;
|
import com.mdd.front.validate.UserRegisterValidate;
|
||||||
|
import com.mdd.front.vo.LoginTokenVo;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -13,45 +14,45 @@ public interface ILoginService {
|
||||||
* 账号注册
|
* 账号注册
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param regValidate 参数
|
* @param userRegisterValidate 参数
|
||||||
*/
|
*/
|
||||||
void register(RegValidate regValidate);
|
void register(UserRegisterValidate userRegisterValidate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信登录
|
* 微信登录
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param params 参数
|
||||||
* @return Map<String, Object>
|
* @return LoginTokenVo
|
||||||
*/
|
*/
|
||||||
Map<String, Object> mnpLogin(Map<String, String> params);
|
LoginTokenVo mnpLogin(Map<String, String> params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机登录
|
* 手机登录
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param params 参数
|
||||||
* @return Map<String, Object>
|
* @return LoginTokenVo
|
||||||
*/
|
*/
|
||||||
Map<String, Object> mobileLogin(Map<String, String> params);
|
LoginTokenVo mobileLogin(Map<String, String> params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号登录
|
* 账号登录
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param params 参数
|
||||||
* @return Map<String, Object>
|
* @return LoginTokenVo
|
||||||
*/
|
*/
|
||||||
Map<String, Object> accountLogin(Map<String, String> params);
|
LoginTokenVo accountLogin(Map<String, String> params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公众号登录
|
* 公众号登录
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param params 参数
|
||||||
* @return Map<String, Object>
|
* @return LoginTokenVo
|
||||||
*/
|
*/
|
||||||
Map<String, Object> officeLogin(Map<String, String> params);
|
LoginTokenVo officeLogin(Map<String, String> params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公众号跳转url
|
* 公众号跳转url
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package com.mdd.front.service;
|
package com.mdd.front.service;
|
||||||
|
|
||||||
import com.mdd.front.vo.user.UserCenterVo;
|
import com.mdd.front.validate.UserBindMobileValidate;
|
||||||
import com.mdd.front.vo.user.UserInfoVo;
|
import com.mdd.front.validate.UserUpdateValidate;
|
||||||
|
import com.mdd.front.vo.users.UserCenterVo;
|
||||||
import java.util.Map;
|
import com.mdd.front.vo.users.UserInfoVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户服务接口类
|
* 用户服务接口类
|
||||||
|
|
@ -32,10 +32,10 @@ public interface IUserService {
|
||||||
* 编辑信息
|
* 编辑信息
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param updateValidate 参数
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
void edit(Map<String, String> params, Integer userId);
|
void edit(UserUpdateValidate updateValidate, Integer userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改密码
|
* 修改密码
|
||||||
|
|
@ -51,10 +51,10 @@ public interface IUserService {
|
||||||
* 绑定手机
|
* 绑定手机
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param mobileValidate 参数
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
void bindMobile(Map<String, String> params, Integer userId);
|
void bindMobile(UserBindMobileValidate mobileValidate, Integer userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信手机
|
* 微信手机
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@ import com.mdd.common.utils.StringUtil;
|
||||||
import com.mdd.common.utils.TimeUtil;
|
import com.mdd.common.utils.TimeUtil;
|
||||||
import com.mdd.common.utils.UrlUtil;
|
import com.mdd.common.utils.UrlUtil;
|
||||||
import com.mdd.front.service.IArticleService;
|
import com.mdd.front.service.IArticleService;
|
||||||
import com.mdd.front.validate.PageValidate;
|
import com.mdd.front.validate.commons.PageValidate;
|
||||||
import com.mdd.front.vo.article.ArticleCateVo;
|
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.ArticleListVo;
|
import com.mdd.front.vo.article.ArticleListedVo;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ public class ArticleServiceImpl implements IArticleService {
|
||||||
* @return PageResult<ArticleListVo>
|
* @return PageResult<ArticleListVo>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResult<ArticleListVo> list(PageValidate pageValidate, Integer cid, Integer userId) {
|
public PageResult<ArticleListedVo> list(PageValidate pageValidate, Integer cid, Integer userId) {
|
||||||
Integer pageNo = pageValidate.getPageNo();
|
Integer pageNo = pageValidate.getPageNo();
|
||||||
Integer pageSize = pageValidate.getPageSize();
|
Integer pageSize = pageValidate.getPageSize();
|
||||||
|
|
||||||
|
|
@ -96,9 +96,9 @@ public class ArticleServiceImpl implements IArticleService {
|
||||||
IPage<Article> iPage = articleMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
IPage<Article> iPage = articleMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||||
|
|
||||||
List<Integer> ids = new LinkedList<>();
|
List<Integer> ids = new LinkedList<>();
|
||||||
List<ArticleListVo> list = new LinkedList<>();
|
List<ArticleListedVo> list = new LinkedList<>();
|
||||||
for (Article article : iPage.getRecords()) {
|
for (Article article : iPage.getRecords()) {
|
||||||
ArticleListVo vo = new ArticleListVo();
|
ArticleListedVo vo = new ArticleListedVo();
|
||||||
BeanUtils.copyProperties(article, vo);
|
BeanUtils.copyProperties(article, vo);
|
||||||
vo.setCollect(false);
|
vo.setCollect(false);
|
||||||
vo.setImage(UrlUtil.toAbsoluteUrl(article.getImage()));
|
vo.setImage(UrlUtil.toAbsoluteUrl(article.getImage()));
|
||||||
|
|
@ -120,7 +120,7 @@ public class ArticleServiceImpl implements IArticleService {
|
||||||
collects.add(c.getArticleId());
|
collects.add(c.getArticleId());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ArticleListVo vo : list) {
|
for (ArticleListedVo vo : list) {
|
||||||
vo.setCollect(collects.contains(vo.getId()));
|
vo.setCollect(collects.contains(vo.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ import com.mdd.common.mapper.DecorateTabbarMapper;
|
||||||
import com.mdd.common.mapper.setting.HotSearchMapper;
|
import com.mdd.common.mapper.setting.HotSearchMapper;
|
||||||
import com.mdd.common.utils.*;
|
import com.mdd.common.utils.*;
|
||||||
import com.mdd.front.service.IIndexService;
|
import com.mdd.front.service.IIndexService;
|
||||||
import com.mdd.front.validate.PageValidate;
|
import com.mdd.front.validate.commons.PageValidate;
|
||||||
import com.mdd.front.vo.article.ArticleListVo;
|
import com.mdd.front.vo.article.ArticleListedVo;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
@ -215,7 +215,7 @@ public class IndexServiceImpl implements IIndexService {
|
||||||
* @param params 搜索参数
|
* @param params 搜索参数
|
||||||
* @return PageResult<ArticleListVo>
|
* @return PageResult<ArticleListVo>
|
||||||
*/
|
*/
|
||||||
public PageResult<ArticleListVo> search(PageValidate pageValidate, Map<String, String> params) {
|
public PageResult<ArticleListedVo> search(PageValidate pageValidate, Map<String, String> params) {
|
||||||
Integer pageNo = pageValidate.getPageNo();
|
Integer pageNo = pageValidate.getPageNo();
|
||||||
Integer pageSize = pageValidate.getPageSize();
|
Integer pageSize = pageValidate.getPageSize();
|
||||||
|
|
||||||
|
|
@ -227,12 +227,12 @@ public class IndexServiceImpl implements IIndexService {
|
||||||
.like("t.title", params.get("keyword"))
|
.like("t.title", params.get("keyword"))
|
||||||
.orderByDesc(Arrays.asList("t.sort", "t.id"));
|
.orderByDesc(Arrays.asList("t.sort", "t.id"));
|
||||||
|
|
||||||
IPage<ArticleListVo> iPage = articleMapper.selectJoinPage(
|
IPage<ArticleListedVo> iPage = articleMapper.selectJoinPage(
|
||||||
new Page<>(pageNo, pageSize),
|
new Page<>(pageNo, pageSize),
|
||||||
ArticleListVo.class,
|
ArticleListedVo.class,
|
||||||
mpjQueryWrapper);
|
mpjQueryWrapper);
|
||||||
|
|
||||||
for (ArticleListVo vo : iPage.getRecords()) {
|
for (ArticleListedVo vo : iPage.getRecords()) {
|
||||||
vo.setCollect(false);
|
vo.setCollect(false);
|
||||||
vo.setImage(UrlUtil.toAbsoluteUrl(vo.getImage()));
|
vo.setImage(UrlUtil.toAbsoluteUrl(vo.getImage()));
|
||||||
vo.setCreateTime(TimeUtil.timestampToDate(vo.getCreateTime()));
|
vo.setCreateTime(TimeUtil.timestampToDate(vo.getCreateTime()));
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ import com.mdd.common.mapper.user.UserMapper;
|
||||||
import com.mdd.common.utils.*;
|
import com.mdd.common.utils.*;
|
||||||
import com.mdd.front.config.FrontConfig;
|
import com.mdd.front.config.FrontConfig;
|
||||||
import com.mdd.front.service.ILoginService;
|
import com.mdd.front.service.ILoginService;
|
||||||
import com.mdd.front.validate.RegValidate;
|
import com.mdd.front.validate.UserRegisterValidate;
|
||||||
|
import com.mdd.front.vo.LoginTokenVo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import me.chanjar.weixin.common.api.WxConsts;
|
import me.chanjar.weixin.common.api.WxConsts;
|
||||||
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
|
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
|
||||||
|
|
@ -26,7 +27,6 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,13 +46,13 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
* 注册账号
|
* 注册账号
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param regValidate 参数
|
* @param userRegisterValidate 参数
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void register(RegValidate regValidate) {
|
public void register(UserRegisterValidate userRegisterValidate) {
|
||||||
User model = userMapper.selectOne(new QueryWrapper<User>()
|
User model = userMapper.selectOne(new QueryWrapper<User>()
|
||||||
.select("id,sn,username")
|
.select("id,sn,username")
|
||||||
.eq("username", regValidate.getUsername())
|
.eq("username", userRegisterValidate.getUsername())
|
||||||
.eq("is_delete", 0)
|
.eq("is_delete", 0)
|
||||||
.last("limit 1"));
|
.last("limit 1"));
|
||||||
|
|
||||||
|
|
@ -60,16 +60,16 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
|
|
||||||
Integer sn = this.randMakeSn();
|
Integer sn = this.randMakeSn();
|
||||||
String salt = ToolsUtil.randomString(5);
|
String salt = ToolsUtil.randomString(5);
|
||||||
String pwd = ToolsUtil.makeMd5(regValidate.getPassword()+salt);
|
String pwd = ToolsUtil.makeMd5(userRegisterValidate.getPassword()+salt);
|
||||||
|
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setSn(sn);
|
user.setSn(sn);
|
||||||
user.setNickname("用户"+sn);
|
user.setNickname("用户"+sn);
|
||||||
user.setUsername(regValidate.getUsername());
|
user.setUsername(userRegisterValidate.getUsername());
|
||||||
user.setPassword(pwd);
|
user.setPassword(pwd);
|
||||||
user.setSalt(salt);
|
user.setSalt(salt);
|
||||||
user.setAvatar("/api/static/default_avatar.png");
|
user.setAvatar("/api/static/default_avatar.png");
|
||||||
user.setChannel(regValidate.getClient());
|
user.setChannel(userRegisterValidate.getClient());
|
||||||
user.setCreateTime(System.currentTimeMillis() / 1000);
|
user.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
user.setUpdateTime(System.currentTimeMillis() / 1000);
|
user.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
userMapper.insert(user);
|
userMapper.insert(user);
|
||||||
|
|
@ -80,11 +80,11 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param params 参数
|
||||||
* @return Map<String, Object>
|
* @return LoginTokenVo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Map<String, Object> mnpLogin(Map<String, String> params) {
|
public LoginTokenVo mnpLogin(Map<String, String> params) {
|
||||||
Assert.notNull(params.get("code"), "code参数缺失!");
|
Assert.notNull(params.get("code"), "code参数缺失!");
|
||||||
String code = params.get("code");
|
String code = params.get("code");
|
||||||
String avatarUrl = params.getOrDefault("avatarUrl", "/api/static/default_avatar.png");
|
String avatarUrl = params.getOrDefault("avatarUrl", "/api/static/default_avatar.png");
|
||||||
|
|
@ -164,14 +164,13 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
|
|
||||||
String token = ToolsUtil.makeToken();
|
String token = ToolsUtil.makeToken();
|
||||||
RedisUtil.set(FrontConfig.frontendTokenKey+token, userId, 7200);
|
RedisUtil.set(FrontConfig.frontendTokenKey+token, userId, 7200);
|
||||||
|
|
||||||
String mobile = StringUtil.isNull(user.getMobile()) ? "" : user.getMobile();
|
String mobile = StringUtil.isNull(user.getMobile()) ? "" : user.getMobile();
|
||||||
|
|
||||||
Map<String, Object> response = new LinkedHashMap<>();
|
LoginTokenVo vo = new LoginTokenVo();
|
||||||
response.put("id", userId);
|
vo.setId(userId);
|
||||||
response.put("isBindMobile", !mobile.equals(""));
|
vo.setIsBindMobile(!mobile.equals(""));
|
||||||
response.put("token", token);
|
vo.setToken(token);
|
||||||
return response;
|
return vo;
|
||||||
} catch (WxErrorException e) {
|
} catch (WxErrorException e) {
|
||||||
throw new OperateException(e.getError().getErrorCode() + ", " + e.getError().getErrorMsg());
|
throw new OperateException(e.getError().getErrorCode() + ", " + e.getError().getErrorMsg());
|
||||||
}
|
}
|
||||||
|
|
@ -182,10 +181,10 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param params 参数
|
||||||
* @return Map<String, Object>
|
* @return LoginTokenVo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> mobileLogin(Map<String, String> params) {
|
public LoginTokenVo mobileLogin(Map<String, String> params) {
|
||||||
Assert.notNull(params.get("mobile"), "mobile参数缺失!");
|
Assert.notNull(params.get("mobile"), "mobile参数缺失!");
|
||||||
Assert.notNull(params.get("code"), "code参数缺失!");
|
Assert.notNull(params.get("code"), "code参数缺失!");
|
||||||
String mobile = params.get("mobile");
|
String mobile = params.get("mobile");
|
||||||
|
|
@ -199,7 +198,7 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除验证码
|
// 删除验证码
|
||||||
RedisUtil.del(GlobalConfig.redisSmsCode+"101:"+mobile);
|
RedisUtil.del(GlobalConfig.redisSmsCode+typeCode+":"+mobile);
|
||||||
|
|
||||||
// 查询手机号
|
// 查询手机号
|
||||||
User user = userMapper.selectOne(new QueryWrapper<User>()
|
User user = userMapper.selectOne(new QueryWrapper<User>()
|
||||||
|
|
@ -219,11 +218,11 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
String token = ToolsUtil.makeToken();
|
String token = ToolsUtil.makeToken();
|
||||||
RedisUtil.set(FrontConfig.frontendTokenKey+token, user.getId(), 7200);
|
RedisUtil.set(FrontConfig.frontendTokenKey+token, user.getId(), 7200);
|
||||||
|
|
||||||
Map<String, Object> response = new LinkedHashMap<>();
|
LoginTokenVo vo = new LoginTokenVo();
|
||||||
response.put("id", user.getId());
|
vo.setId(user.getId());
|
||||||
response.put("isBindMobile", !user.getMobile().equals(""));
|
vo.setIsBindMobile(!user.getMobile().equals(""));
|
||||||
response.put("token", token);
|
vo.setToken(token);
|
||||||
return response;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -231,10 +230,10 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param params 参数
|
||||||
* @return Map<String, Object>
|
* @return LoginTokenVo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> accountLogin(Map<String, String> params) {
|
public LoginTokenVo accountLogin(Map<String, String> params) {
|
||||||
Assert.notNull(params.get("username"), "username参数缺失!");
|
Assert.notNull(params.get("username"), "username参数缺失!");
|
||||||
Assert.notNull(params.get("password"), "password参数缺失!");
|
Assert.notNull(params.get("password"), "password参数缺失!");
|
||||||
String username = params.get("username");
|
String username = params.get("username");
|
||||||
|
|
@ -259,21 +258,21 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
String token = ToolsUtil.makeToken();
|
String token = ToolsUtil.makeToken();
|
||||||
RedisUtil.set(FrontConfig.frontendTokenKey+token, user.getId(), 7201);
|
RedisUtil.set(FrontConfig.frontendTokenKey+token, user.getId(), 7201);
|
||||||
|
|
||||||
Map<String, Object> response = new LinkedHashMap<>();
|
LoginTokenVo vo = new LoginTokenVo();
|
||||||
response.put("id", user.getId());
|
vo.setId(user.getId());
|
||||||
response.put("isBindMobile", !user.getMobile().equals(""));
|
vo.setIsBindMobile(!user.getMobile().equals(""));
|
||||||
response.put("token", token);
|
vo.setToken(token);
|
||||||
return response;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公众号登录
|
* 公众号登录
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @return Map<String, Object>
|
* @return LoginTokenVo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> officeLogin(Map<String, String> params) {
|
public LoginTokenVo officeLogin(Map<String, String> params) {
|
||||||
Assert.notNull(params.get("code"), "code参数缺失!");
|
Assert.notNull(params.get("code"), "code参数缺失!");
|
||||||
String code = params.get("code");
|
String code = params.get("code");
|
||||||
|
|
||||||
|
|
@ -343,12 +342,11 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
String token = ToolsUtil.makeToken();
|
String token = ToolsUtil.makeToken();
|
||||||
RedisUtil.set(FrontConfig.frontendTokenKey+token, userId, 7201);
|
RedisUtil.set(FrontConfig.frontendTokenKey+token, userId, 7201);
|
||||||
|
|
||||||
Map<String, Object> response = new LinkedHashMap<>();
|
LoginTokenVo vo = new LoginTokenVo();
|
||||||
response.put("id", userId);
|
vo.setId(user.getId());
|
||||||
response.put("isBindMobile", !user.getMobile().equals(""));
|
vo.setIsBindMobile(!user.getMobile().equals(""));
|
||||||
response.put("token", token);
|
vo.setToken(token);
|
||||||
|
return vo;
|
||||||
return response;
|
|
||||||
} catch (WxErrorException e) {
|
} catch (WxErrorException e) {
|
||||||
throw new OperateException(e.getError().getErrorCode() + ", " + e.getError().getErrorMsg());
|
throw new OperateException(e.getError().getErrorCode() + ", " + e.getError().getErrorMsg());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,10 @@ import com.mdd.common.mapper.user.UserMapper;
|
||||||
import com.mdd.common.utils.*;
|
import com.mdd.common.utils.*;
|
||||||
import com.mdd.front.LikeFrontThreadLocal;
|
import com.mdd.front.LikeFrontThreadLocal;
|
||||||
import com.mdd.front.service.IUserService;
|
import com.mdd.front.service.IUserService;
|
||||||
import com.mdd.front.vo.user.UserCenterVo;
|
import com.mdd.front.validate.UserBindMobileValidate;
|
||||||
import com.mdd.front.vo.user.UserInfoVo;
|
import com.mdd.front.validate.UserUpdateValidate;
|
||||||
|
import com.mdd.front.vo.users.UserCenterVo;
|
||||||
|
import com.mdd.front.vo.users.UserInfoVo;
|
||||||
import me.chanjar.weixin.common.error.WxErrorException;
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -106,13 +108,13 @@ public class UserServiceImpl implements IUserService {
|
||||||
* 编辑信息
|
* 编辑信息
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param updateValidate 参数
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void edit(Map<String, String> params, Integer userId) {
|
public void edit(UserUpdateValidate updateValidate, Integer userId) {
|
||||||
String field = params.getOrDefault("field", "").trim();
|
String field = updateValidate.getField();
|
||||||
String value = params.getOrDefault("value", "").trim();
|
String value = updateValidate.getValue();
|
||||||
|
|
||||||
switch (field) {
|
switch (field) {
|
||||||
case "avatar":
|
case "avatar":
|
||||||
|
|
@ -202,14 +204,14 @@ public class UserServiceImpl implements IUserService {
|
||||||
* 绑定手机
|
* 绑定手机
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param params 参数
|
* @param mobileValidate 参数
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void bindMobile(Map<String, String> params, Integer userId) {
|
public void bindMobile(UserBindMobileValidate mobileValidate, Integer userId) {
|
||||||
String type = params.getOrDefault("type", "");
|
String type = mobileValidate.getType();
|
||||||
String mobile = params.getOrDefault("mobile", "");
|
String mobile = mobileValidate.getMobile();
|
||||||
String code = params.getOrDefault("code", "").toLowerCase();
|
String code = mobileValidate.getCode().toLowerCase();
|
||||||
|
|
||||||
// 校验验证码
|
// 校验验证码
|
||||||
int typeCode = type.equals("bind") ? NoticeEnum.SMS_BIND_MOBILE_CODE.getCode() : NoticeEnum.SMS_CHANGE_MOBILE_CODE.getCode() ;
|
int typeCode = type.equals("bind") ? NoticeEnum.SMS_BIND_MOBILE_CODE.getCode() : NoticeEnum.SMS_CHANGE_MOBILE_CODE.getCode() ;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.mdd.front.validate;
|
||||||
|
|
||||||
|
import com.mdd.common.validator.annotation.IDMust;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章收藏参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ArticleCollectValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "articleId参数缺失")
|
||||||
|
@IDMust(message = "articleId参数必须大于0")
|
||||||
|
private Integer articleId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.mdd.front.validate;
|
||||||
|
|
||||||
|
import com.mdd.common.validator.annotation.StringContains;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定或修改手机参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserBindMobileValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "type参数缺失")
|
||||||
|
@StringContains(values = {"bind", "change"})
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@NotNull(message = "mobile参数缺失")
|
||||||
|
@NotEmpty(message = "手机号不能为空")
|
||||||
|
@Length(min = 11, max = 11, message = "手机号只能为11位")
|
||||||
|
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@NotNull(message = "code参数缺失")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.mdd.front.validate;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取微信手机号参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserMnpMobileValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "code参数缺失")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.mdd.front.validate;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户修改密码参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserPasswordValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "password参数缺失")
|
||||||
|
@Pattern(message = "密码必须是6-20字母+数字组合!", regexp="^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@NotNull(message = "oldPassword参数缺失")
|
||||||
|
private String oldPassword;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ import java.io.Serializable;
|
||||||
* 注册参数类
|
* 注册参数类
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RegValidate implements Serializable {
|
public class UserRegisterValidate implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.mdd.front.validate;
|
||||||
|
|
||||||
|
import com.mdd.common.validator.annotation.StringContains;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户更新参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserUpdateValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "field参数缺失")
|
||||||
|
@StringContains(values = {"avatar", "username", "nickname", "sex"})
|
||||||
|
private String field;
|
||||||
|
|
||||||
|
@NotNull(message = "value参数缺失")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.mdd.front.validate;
|
package com.mdd.front.validate.commons;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.mdd.front.validate;
|
package com.mdd.front.validate.commons;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mdd.front.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公众号跳转url
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LoginCodesVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.mdd.front.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统登录Vo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LoginTokenVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private Boolean isBindMobile;
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ import lombok.Data;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ArticleListVo implements Serializable {
|
public class ArticleListedVo implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.mdd.front.vo.user;
|
package com.mdd.front.vo.users;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.mdd.front.vo.user;
|
package com.mdd.front.vo.users;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
Loading…
Reference in New Issue