diff --git a/roncoo-education-feign/roncoo-education-feign-user/src/main/java/com/roncoo/education/user/feign/interfaces/vo/UsersVO.java b/roncoo-education-feign/roncoo-education-feign-user/src/main/java/com/roncoo/education/user/feign/interfaces/vo/UsersVO.java index cf68996febc7c01c23fbaceebe7100b363656791..77f37d1362ca9998c42b446958575647bb863a95 100644 --- a/roncoo-education-feign/roncoo-education-feign-user/src/main/java/com/roncoo/education/user/feign/interfaces/vo/UsersVO.java +++ b/roncoo-education-feign/roncoo-education-feign-user/src/main/java/com/roncoo/education/user/feign/interfaces/vo/UsersVO.java @@ -1,13 +1,9 @@ package com.roncoo.education.user.feign.interfaces.vo; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.experimental.Accessors; import java.io.Serializable; -import java.time.LocalDateTime; /** *

@@ -18,40 +14,20 @@ import java.time.LocalDateTime; */ @Data @Accessors(chain = true) -@ApiModel(description = "ADMIN-用户信息查看") public class UsersVO implements Serializable { private static final long serialVersionUID = 1L; - @ApiModelProperty(value = "主键") private Long id; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @ApiModelProperty(value = "创建时间") - private LocalDateTime gmtCreate; - - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @ApiModelProperty(value = "修改时间") - private LocalDateTime gmtModified; - - @ApiModelProperty(value = "状态(1:正常,0:禁用)") - private Integer statusId; - - @ApiModelProperty(value = "手机号码") private String mobile; - @ApiModelProperty(value = "昵称") private String nickname; - @ApiModelProperty(value = "用户性别(1男,2女,3保密)") private Integer userSex; - @ApiModelProperty(value = "用户年龄") private Integer userAge; - @ApiModelProperty(value = "用户头像") private String userHead; - @ApiModelProperty(value = "备注") - private String remark; } diff --git a/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/admin/biz/AdminUserCourseCommentBiz.java b/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/admin/biz/AdminUserCourseCommentBiz.java index 61f79575abc87348db28bcb59efec5eb8504755c..71d313bdcecfe516feeba472bbae364754d840e7 100644 --- a/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/admin/biz/AdminUserCourseCommentBiz.java +++ b/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/admin/biz/AdminUserCourseCommentBiz.java @@ -56,6 +56,7 @@ public class AdminUserCourseCommentBiz extends BaseBiz { if (StringUtils.hasText(req.getCommentText())) { c.andCommentTextLike(PageUtil.like(req.getCommentText())); } + example.setOrderByClause("id desc"); Page page = dao.page(req.getPageCurrent(), req.getPageSize(), example); Page respPage = PageUtil.transform(page, AdminUserCourseCommentPageResp.class); if (CollUtil.isNotEmpty(respPage.getList())) { diff --git a/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/auth/AuthUserCourseCommentController.java b/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/auth/AuthUserCourseCommentController.java index 75d7907e5e927fb3c0ca87f3d0f7b3da26c08903..6a8745db9d67fabbc116a2fcde7cf1808a6af6c4 100644 --- a/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/auth/AuthUserCourseCommentController.java +++ b/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/auth/AuthUserCourseCommentController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import javax.validation.Valid; import javax.validation.constraints.NotNull; /** @@ -51,7 +52,7 @@ public class AuthUserCourseCommentController { */ @ApiOperation(value = "课程评论添加", notes = "用户进行课程评论") @RequestMapping(value = "/add", method = RequestMethod.POST) - public Result add(@RequestBody AuthUserCourseCommentReq req) { + public Result add(@RequestBody @Valid AuthUserCourseCommentReq req) { return biz.add(req); } diff --git a/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/auth/req/AuthUserCourseCommentReq.java b/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/auth/req/AuthUserCourseCommentReq.java index 76c3e74cd3fba41d5f91326bafacc66dada9a4d0..cf9d9d634da762782e91fd7d88863a6ff7c37ff9 100644 --- a/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/auth/req/AuthUserCourseCommentReq.java +++ b/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/auth/req/AuthUserCourseCommentReq.java @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.experimental.Accessors; +import javax.validation.constraints.NotBlank; import java.io.Serializable; /** @@ -28,6 +29,7 @@ public class AuthUserCourseCommentReq implements Serializable { @ApiModelProperty(value = "评论ID,被评论的ID", required = false) private Long commentId; + @NotBlank(message = "请填写评论内容") @ApiModelProperty(value = "评论内容") private String commentText; } diff --git a/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/biz/CourseBiz.java b/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/biz/CourseBiz.java index 03bf9531572656d55c57e1d6e21d2f87695ba3cd..0786f72eca7f9295d7d9a45dc4212e65255016fa 100644 --- a/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/biz/CourseBiz.java +++ b/roncoo-education-service/roncoo-education-service-course/src/main/java/com/roncoo/education/course/service/biz/CourseBiz.java @@ -1,7 +1,9 @@ package com.roncoo.education.course.service.biz; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.DesensitizedUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.roncoo.education.common.core.base.Page; import com.roncoo.education.common.core.base.PageUtil; import com.roncoo.education.common.core.base.Result; @@ -146,7 +148,12 @@ public class CourseBiz extends BaseBiz { List userIds = userCourseCommentPage.getList().stream().map(UserCourseComment::getUserId).collect(Collectors.toList()); Map usersVOMap = feignUsers.listByIds(userIds); for (CourseCommentResp commentResp : resp.getList()) { - commentResp.setUsersVO(usersVOMap.get(commentResp.getUserId())); + UsersVO usersVO = usersVOMap.get(commentResp.getUserId()); + usersVO.setMobile(DesensitizedUtil.mobilePhone(usersVO.getMobile())); + if (StrUtil.isBlank(usersVO.getNickname())) { + usersVO.setNickname(usersVO.getMobile()); + } + commentResp.setUsersVO(usersVO); } } return Result.success(resp); diff --git a/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/api/biz/ApiUsersBiz.java b/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/api/biz/ApiUsersBiz.java index 00bc5613c4860f25f0878eb07fb1ff85f30042d7..1a5a4c0c2bedb10b86001d6bb78a3e611cb8278c 100644 --- a/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/api/biz/ApiUsersBiz.java +++ b/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/api/biz/ApiUsersBiz.java @@ -2,6 +2,7 @@ package com.roncoo.education.user.service.api.biz; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; import cn.hutool.crypto.digest.DigestUtil; import cn.hutool.extra.servlet.ServletUtil; import com.roncoo.education.common.cache.CacheRedis; @@ -129,6 +130,8 @@ public class ApiUsersBiz extends BaseBiz { user.setMobile(mobile); user.setMobileSalt(IdUtil.simpleUUID()); user.setMobilePsw(DigestUtil.sha1Hex(user.getMobileSalt() + password)); + // 默认8位随机字符串 + user.setNickname(RandomUtil.randomString(8)); userDao.save(user); return user; } diff --git a/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/auth/AuthUsersController.java b/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/auth/AuthUsersController.java index 1c1caac2707e4720cc426eb00766dd77deb00bd1..d1ed5862e1f63b00c7f6797be98c1698df8adb4e 100644 --- a/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/auth/AuthUsersController.java +++ b/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/auth/AuthUsersController.java @@ -9,6 +9,7 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; import javax.validation.constraints.NotNull; /** @@ -37,7 +38,7 @@ public class AuthUsersController { @ApiOperation(value = "更新接口", notes = "更新当前用户的基本信息") @RequestMapping(value = "/edit", method = RequestMethod.POST) - public Result update(@RequestBody AuthUsersReq req) { + public Result update(@RequestBody @Valid AuthUsersReq req) { return biz.update(req); } diff --git a/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/auth/req/AuthUsersReq.java b/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/auth/req/AuthUsersReq.java index 1d6f138d8c576a74d089719cb784ae5f4530b435..3272dfe7969b463abb6327b7432e792da01cd03b 100644 --- a/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/auth/req/AuthUsersReq.java +++ b/roncoo-education-service/roncoo-education-service-user/src/main/java/com/roncoo/education/user/service/auth/req/AuthUsersReq.java @@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.experimental.Accessors; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; /** @@ -22,12 +24,15 @@ public class AuthUsersReq implements Serializable { private static final long serialVersionUID = 1L; + @NotBlank(message = "请填写昵称") @ApiModelProperty(value = "昵称") private String nickname; + @NotNull(message = "请选择性别") @ApiModelProperty(value = "用户性别(1男,2女,3保密)") private Integer userSex; + @NotNull(message = "请填写年龄") @ApiModelProperty(value = "用户年龄") private Integer userAge;