From fd660ac6558a2b781b2f10f17648b3ae55c597c1 Mon Sep 17 00:00:00 2001 From: lbw Date: Wed, 21 Jun 2023 08:01:08 +0800 Subject: [PATCH] :art: Improving structure / format of the code. --- .../pigx/app/api/dto/AppUserDTO.java | 24 +- .../api/entity/AppArticleCollectEntity.java | 104 +++---- .../pigx/app/api/entity/AppArticleEntity.java | 175 ++++++------ .../AppArticleCollectController.java | 163 ++++++----- .../app/controller/AppArticleController.java | 157 +++++----- .../app/controller/AppPageController.java | 35 ++- .../app/controller/AppRoleController.java | 1 - .../app/controller/AppTabbarController.java | 41 ++- .../app/controller/AppUserController.java | 267 +++++++++--------- .../pigx/app/handler/SmsLoginHandler.java | 104 ++++--- .../pigx/app/service/AppArticleService.java | 14 +- .../pigx/app/service/AppRoleService.java | 1 - .../pigx/app/service/AppUserService.java | 1 + .../impl/AppArticleCollectServiceImpl.java | 5 +- .../service/impl/AppArticleServiceImpl.java | 51 ++-- .../service/impl/AppMobileServiceImpl.java | 41 +-- .../app/service/impl/AppRoleServiceImpl.java | 5 +- .../app/service/impl/AppUserServiceImpl.java | 16 +- 18 files changed, 589 insertions(+), 616 deletions(-) diff --git a/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/dto/AppUserDTO.java b/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/dto/AppUserDTO.java index ef2366638..70c8484f6 100644 --- a/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/dto/AppUserDTO.java +++ b/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/dto/AppUserDTO.java @@ -12,19 +12,19 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) public class AppUserDTO extends AppUser { - /** - * 角色ID - */ - @Schema(description = "角色id集合") - private List role; + /** + * 角色ID + */ + @Schema(description = "角色id集合") + private List role; - /** - * 新密码 - */ - @Schema(description = "新密码") - private String newpassword1; + /** + * 新密码 + */ + @Schema(description = "新密码") + private String newpassword1; - @Schema(description = "验证码") - private String mobileCode; + @Schema(description = "验证码") + private String mobileCode; } diff --git a/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/entity/AppArticleCollectEntity.java b/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/entity/AppArticleCollectEntity.java index 295d27933..fe1a28b02 100644 --- a/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/entity/AppArticleCollectEntity.java +++ b/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/entity/AppArticleCollectEntity.java @@ -20,65 +20,65 @@ import java.time.LocalDateTime; @Schema(description = "文章收藏表") public class AppArticleCollectEntity extends Model { + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description = "主键") + private Long id; - /** - * 主键 - */ - @TableId(type = IdType.ASSIGN_ID) - @Schema(description = "主键") - private Long id; + /** + * 用户ID + */ + @Schema(description = "用户ID") + private Long userId; - /** - * 用户ID - */ - @Schema(description = "用户ID") - private Long userId; + /** + * 文章ID + */ + @Schema(description = "文章ID") + private Long articleId; - /** - * 文章ID - */ - @Schema(description = "文章ID") - private Long articleId; + /** + * 文章标题 + */ + @TableField(exist = false) + private String title; - /** - * 文章标题 - */ - @TableField(exist = false) - private String title; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; - /** - * 创建人 - */ - @TableField(fill = FieldFill.INSERT) - @Schema(description = "创建人") - private String createBy; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") + private LocalDateTime createTime; - /** - * 创建时间 - */ - @TableField(fill = FieldFill.INSERT) - @Schema(description = "创建时间") - private LocalDateTime createTime; + /** + * 更新人 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description = "更新人") + private String updateBy; - /** - * 更新人 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - @Schema(description = "更新人") - private String updateBy; + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description = "更新时间") + private LocalDateTime updateTime; - /** - * 更新时间 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - @Schema(description = "更新时间") - private LocalDateTime updateTime; + /** + * 是否删除 + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "是否删除") + private String delFlag; - /** - * 是否删除 - */ - @TableLogic - @TableField(fill = FieldFill.INSERT) - @Schema(description = "是否删除") - private String delFlag; } diff --git a/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/entity/AppArticleEntity.java b/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/entity/AppArticleEntity.java index a40a662cb..3e0364b72 100644 --- a/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/entity/AppArticleEntity.java +++ b/pigx-app-server/pigx-app-server-api/src/main/java/com/pig4cloud/pigx/app/api/entity/AppArticleEntity.java @@ -20,106 +20,107 @@ import java.time.LocalDateTime; @Schema(description = "文章资讯") public class AppArticleEntity extends Model { - /** - * 主键 - */ - @TableId(type = IdType.ASSIGN_ID) - @Schema(description = "主键") - private Long id; + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description = "主键") + private Long id; - /** - * 分类 - */ - @Schema(description = "分类") - private Long cid; + /** + * 分类 + */ + @Schema(description = "分类") + private Long cid; - /** - * 标题 - */ - @Schema(description = "标题") - private String title; + /** + * 标题 + */ + @Schema(description = "标题") + private String title; - /** - * 简介 - */ - @Schema(description = "简介") - private String intro; + /** + * 简介 + */ + @Schema(description = "简介") + private String intro; - /** - * 摘要 - */ - @Schema(description = "摘要") - private String summary; + /** + * 摘要 + */ + @Schema(description = "摘要") + private String summary; - /** - * 封面 - */ - @Schema(description = "封面") - private String image; + /** + * 封面 + */ + @Schema(description = "封面") + private String image; - /** - * 内容 - */ - @Schema(description = "内容") - private String content; + /** + * 内容 + */ + @Schema(description = "内容") + private String content; - /** - * 作者 - */ - @Schema(description = "作者") - private String author; + /** + * 作者 + */ + @Schema(description = "作者") + private String author; - /** - * 浏览 - */ - @Schema(description = "浏览") - private Integer visit; + /** + * 浏览 + */ + @Schema(description = "浏览") + private Integer visit; - /** - * 排序 - */ - @Schema(description = "排序") - private Integer sort; + /** + * 排序 + */ + @Schema(description = "排序") + private Integer sort; - /** - * 创建人 - */ - @TableField(fill = FieldFill.INSERT) - @Schema(description = "创建人") - private String createBy; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; - /** - * 创建时间 - */ - @TableField(fill = FieldFill.INSERT) - @Schema(description = "创建时间") - private LocalDateTime createTime; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") + private LocalDateTime createTime; - /** - * 更新人 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - @Schema(description = "更新人") - private String updateBy; + /** + * 更新人 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description = "更新人") + private String updateBy; - /** - * 更新时间 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - @Schema(description = "更新时间") - private LocalDateTime updateTime; + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description = "更新时间") + private LocalDateTime updateTime; - /** - * 删除时间 - */ - @TableLogic - @TableField(fill = FieldFill.INSERT) - @Schema(description = "删除标志") - private String delFlag; + /** + * 删除时间 + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标志") + private String delFlag; + + /** + * 当前用户是否已收藏 + */ + @TableField(exist = false) + private boolean collect; - /** - * 当前用户是否已收藏 - */ - @TableField(exist = false) - private boolean collect; } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppArticleCollectController.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppArticleCollectController.java index c5c184887..fddaac866 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppArticleCollectController.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppArticleCollectController.java @@ -35,96 +35,91 @@ import java.util.List; @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class AppArticleCollectController { - private final AppArticleCollectService appArticleCollectService; + private final AppArticleCollectService appArticleCollectService; - /** - * 分页查询 - * - * @param page 分页对象 - * @param appArticleCollect 文章收藏表 - * @return - */ - @Operation(summary = "分页查询", description = "分页查询") - @GetMapping("/page") - public R getAppArticleCollectPage(@ParameterObject Page page) { - MPJLambdaWrapper wrapper = new MPJLambdaWrapper().selectAll(AppArticleCollectEntity.class).select(AppArticleEntity::getTitle).leftJoin(AppArticleEntity.class, AppArticleEntity::getId, AppArticleCollectEntity::getArticleId); - return R.ok(appArticleCollectService.selectJoinListPage(page, AppArticleCollectEntity.class, wrapper)); - } + /** + * 分页查询 + * @param page 分页对象 + * @param appArticleCollect 文章收藏表 + * @return + */ + @Operation(summary = "分页查询", description = "分页查询") + @GetMapping("/page") + public R getAppArticleCollectPage(@ParameterObject Page page) { + MPJLambdaWrapper wrapper = new MPJLambdaWrapper() + .selectAll(AppArticleCollectEntity.class).select(AppArticleEntity::getTitle) + .leftJoin(AppArticleEntity.class, AppArticleEntity::getId, AppArticleCollectEntity::getArticleId); + return R.ok(appArticleCollectService.selectJoinListPage(page, AppArticleCollectEntity.class, wrapper)); + } + /** + * 通过id查询文章收藏表 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/{id}") + public R getById(@PathVariable("id") Long id) { + return R.ok(appArticleCollectService.getById(id)); + } - /** - * 通过id查询文章收藏表 - * - * @param id id - * @return R - */ - @Operation(summary = "通过id查询", description = "通过id查询") - @GetMapping("/{id}") - public R getById(@PathVariable("id") Long id) { - return R.ok(appArticleCollectService.getById(id)); - } + /** + * 新增文章收藏表 + * @param appArticleCollect 文章收藏表 + * @return R + */ + @Operation(summary = "新增文章收藏表", description = "新增文章收藏表") + @SysLog("新增文章收藏表") + @PostMapping + public R save(@RequestBody AppArticleCollectEntity appArticleCollect) { + Long id = SecurityUtils.getUser().getId(); + appArticleCollect.setUserId(id); + return R.ok(appArticleCollectService.save(appArticleCollect)); + } - /** - * 新增文章收藏表 - * - * @param appArticleCollect 文章收藏表 - * @return R - */ - @Operation(summary = "新增文章收藏表", description = "新增文章收藏表") - @SysLog("新增文章收藏表") - @PostMapping - public R save(@RequestBody AppArticleCollectEntity appArticleCollect) { - Long id = SecurityUtils.getUser().getId(); - appArticleCollect.setUserId(id); - return R.ok(appArticleCollectService.save(appArticleCollect)); - } + /** + * 修改文章收藏表 + * @param appArticleCollect 文章收藏表 + * @return R + */ + @Operation(summary = "修改文章收藏表", description = "修改文章收藏表") + @SysLog("修改文章收藏表") + @PutMapping + public R updateById(@RequestBody AppArticleCollectEntity appArticleCollect) { + return R.ok(appArticleCollectService.updateById(appArticleCollect)); + } - /** - * 修改文章收藏表 - * - * @param appArticleCollect 文章收藏表 - * @return R - */ - @Operation(summary = "修改文章收藏表", description = "修改文章收藏表") - @SysLog("修改文章收藏表") - @PutMapping - public R updateById(@RequestBody AppArticleCollectEntity appArticleCollect) { - return R.ok(appArticleCollectService.updateById(appArticleCollect)); - } + /** + * 通过id删除文章收藏表 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除文章收藏表", description = "通过id删除文章收藏表") + @SysLog("通过id删除文章收藏表") + @DeleteMapping + public R removeById(@RequestBody Long[] ids) { + return R.ok(appArticleCollectService.removeBatchByIds(CollUtil.toList(ids))); + } - /** - * 通过id删除文章收藏表 - * - * @param ids id列表 - * @return R - */ - @Operation(summary = "通过id删除文章收藏表", description = "通过id删除文章收藏表") - @SysLog("通过id删除文章收藏表") - @DeleteMapping - public R removeById(@RequestBody Long[] ids) { - return R.ok(appArticleCollectService.removeBatchByIds(CollUtil.toList(ids))); - } + @Operation(summary = "通过文章id删除文章收藏表", description = "通过文章id删除文章收藏表") + @SysLog("通过文章id删除文章收藏表") + @DeleteMapping("/{articleId}") + public R removeByArticleId(@PathVariable String articleId) { + Long id = SecurityUtils.getUser().getId(); + return R.ok(appArticleCollectService.remove(Wrappers.lambdaQuery() + .eq(AppArticleCollectEntity::getUserId, id).eq(AppArticleCollectEntity::getArticleId, articleId))); + } + /** + * 导出excel 表格 + * @param appArticleCollect 查询条件 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('app_collect_export')") + public List export(AppArticleCollectEntity appArticleCollect) { + return appArticleCollectService.list(Wrappers.query(appArticleCollect)); + } - @Operation(summary = "通过文章id删除文章收藏表", description = "通过文章id删除文章收藏表") - @SysLog("通过文章id删除文章收藏表") - @DeleteMapping("/{articleId}") - public R removeByArticleId(@PathVariable String articleId) { - Long id = SecurityUtils.getUser().getId(); - return R.ok(appArticleCollectService.remove(Wrappers.lambdaQuery().eq(AppArticleCollectEntity::getUserId, id).eq(AppArticleCollectEntity::getArticleId, articleId))); - } - - - /** - * 导出excel 表格 - * - * @param appArticleCollect 查询条件 - * @return excel 文件流 - */ - @ResponseExcel - @GetMapping("/export") - @PreAuthorize("@pms.hasPermission('app_collect_export')") - public List export(AppArticleCollectEntity appArticleCollect) { - return appArticleCollectService.list(Wrappers.query(appArticleCollect)); - } } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppArticleController.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppArticleController.java index 628a88443..493a5c346 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppArticleController.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppArticleController.java @@ -36,93 +36,86 @@ import java.util.Objects; @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class AppArticleController { - private final AppArticleService appArticleService; + private final AppArticleService appArticleService; - /** - * 分页查询 - * - * @param page 分页对象 - * @param appArticle 文章资讯 - * @return - */ - @Operation(summary = "分页查询", description = "分页查询") - @Inner(value = false) - @GetMapping("/page") - public R getAppArticlePage(@ParameterObject Page page, @ParameterObject AppArticleEntity appArticle) { - LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); - wrapper.like(StrUtil.isNotBlank(appArticle.getAuthor()), AppArticleEntity::getAuthor, appArticle.getAuthor()); - wrapper.like(StrUtil.isNotBlank(appArticle.getTitle()), AppArticleEntity::getTitle, appArticle.getTitle()); - wrapper.eq(Objects.nonNull(appArticle.getCid()), AppArticleEntity::getCid, appArticle.getCid()); - return R.ok(appArticleService.page(page, wrapper)); - } + /** + * 分页查询 + * @param page 分页对象 + * @param appArticle 文章资讯 + * @return + */ + @Operation(summary = "分页查询", description = "分页查询") + @Inner(value = false) + @GetMapping("/page") + public R getAppArticlePage(@ParameterObject Page page, @ParameterObject AppArticleEntity appArticle) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.like(StrUtil.isNotBlank(appArticle.getAuthor()), AppArticleEntity::getAuthor, appArticle.getAuthor()); + wrapper.like(StrUtil.isNotBlank(appArticle.getTitle()), AppArticleEntity::getTitle, appArticle.getTitle()); + wrapper.eq(Objects.nonNull(appArticle.getCid()), AppArticleEntity::getCid, appArticle.getCid()); + return R.ok(appArticleService.page(page, wrapper)); + } - /** - * 通过id查询文章资讯 - * - * @param id id - * @return R - */ - @Inner(value = false) - @Operation(summary = "通过id查询", description = "通过id查询") - @GetMapping("/details/{id}/{userId}") - public R getById(@PathVariable("id") Long id, @PathVariable(required = false) Long userId) { - return R.ok(appArticleService.getArticleAndIncrById(id, userId)); - } + /** + * 通过id查询文章资讯 + * @param id id + * @return R + */ + @Inner(value = false) + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/details/{id}/{userId}") + public R getById(@PathVariable("id") Long id, @PathVariable(required = false) Long userId) { + return R.ok(appArticleService.getArticleAndIncrById(id, userId)); + } - /** - * 新增文章资讯 - * - * @param appArticle 文章资讯 - * @return R - */ - @Operation(summary = "新增文章资讯", description = "新增文章资讯") - @SysLog("新增文章资讯") - @PostMapping - @PreAuthorize("@pms.hasPermission('app_appArticle_add')") - public R save(@RequestBody AppArticleEntity appArticle) { - return R.ok(appArticleService.save(appArticle)); - } + /** + * 新增文章资讯 + * @param appArticle 文章资讯 + * @return R + */ + @Operation(summary = "新增文章资讯", description = "新增文章资讯") + @SysLog("新增文章资讯") + @PostMapping + @PreAuthorize("@pms.hasPermission('app_appArticle_add')") + public R save(@RequestBody AppArticleEntity appArticle) { + return R.ok(appArticleService.save(appArticle)); + } - /** - * 修改文章资讯 - * - * @param appArticle 文章资讯 - * @return R - */ - @Operation(summary = "修改文章资讯", description = "修改文章资讯") - @SysLog("修改文章资讯") - @PutMapping - @PreAuthorize("@pms.hasPermission('app_appArticle_edit')") - public R updateById(@RequestBody AppArticleEntity appArticle) { - return R.ok(appArticleService.updateById(appArticle)); - } + /** + * 修改文章资讯 + * @param appArticle 文章资讯 + * @return R + */ + @Operation(summary = "修改文章资讯", description = "修改文章资讯") + @SysLog("修改文章资讯") + @PutMapping + @PreAuthorize("@pms.hasPermission('app_appArticle_edit')") + public R updateById(@RequestBody AppArticleEntity appArticle) { + return R.ok(appArticleService.updateById(appArticle)); + } - /** - * 通过id删除文章资讯 - * - * @param ids id列表 - * @return R - */ - @Operation(summary = "通过id删除文章资讯", description = "通过id删除文章资讯") - @SysLog("通过id删除文章资讯") - @DeleteMapping - @PreAuthorize("@pms.hasPermission('app_appArticle_del')") - public R removeById(@RequestBody Long[] ids) { - return R.ok(appArticleService.removeBatchByIds(CollUtil.toList(ids))); - } + /** + * 通过id删除文章资讯 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除文章资讯", description = "通过id删除文章资讯") + @SysLog("通过id删除文章资讯") + @DeleteMapping + @PreAuthorize("@pms.hasPermission('app_appArticle_del')") + public R removeById(@RequestBody Long[] ids) { + return R.ok(appArticleService.removeBatchByIds(CollUtil.toList(ids))); + } - - /** - * 导出excel 表格 - * - * @param appArticle 查询条件 - * @return excel 文件流 - */ - @ResponseExcel - @GetMapping("/export") - @PreAuthorize("@pms.hasPermission('app_appArticle_export')") - public List export(AppArticleEntity appArticle) { - return appArticleService.list(Wrappers.query(appArticle)); - } + /** + * 导出excel 表格 + * @param appArticle 查询条件 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('app_appArticle_export')") + public List export(AppArticleEntity appArticle) { + return appArticleService.list(Wrappers.query(appArticle)); + } } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppPageController.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppPageController.java index 51d324937..3146fcdfb 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppPageController.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppPageController.java @@ -23,26 +23,23 @@ import org.springframework.web.bind.annotation.*; @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class AppPageController { - private final AppPageService pageService; + private final AppPageService pageService; + /** + * 通过id查询文章资讯 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/{id}") + public R getById(@PathVariable("id") Long id) { + return R.ok(pageService.getById(id)); + } - /** - * 通过id查询文章资讯 - * - * @param id id - * @return R - */ - @Operation(summary = "通过id查询", description = "通过id查询") - @GetMapping("/{id}") - public R getById(@PathVariable("id") Long id) { - return R.ok(pageService.getById(id)); - } - - - @Operation(summary = "更新页面", description = "更新页面") - @PutMapping - public R update(@RequestBody AppPageEntity page) { - return R.ok(pageService.updateById(page)); - } + @Operation(summary = "更新页面", description = "更新页面") + @PutMapping + public R update(@RequestBody AppPageEntity page) { + return R.ok(pageService.updateById(page)); + } } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppRoleController.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppRoleController.java index 6f103d3ad..ca90d1217 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppRoleController.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppRoleController.java @@ -148,7 +148,6 @@ public class AppRoleController { return R.ok(appRoleService.deleteRoleByIds(ids)); } - /** * 导出excel 表格 * @param appRole 查询条件 diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppTabbarController.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppTabbarController.java index a4c100146..a7ceee904 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppTabbarController.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppTabbarController.java @@ -27,29 +27,26 @@ import java.util.stream.Collectors; @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class AppTabbarController { - private final AppTabbarService tabbarService; + private final AppTabbarService tabbarService; + /** + * 查询导航列表 + * @return R + */ + @Operation(summary = "查询导航列表", description = "查询导航列表") + @GetMapping("/list") + public R list() { + return R.ok(tabbarService.list()); + } - /** - * 查询导航列表 - * - * @return R - */ - @Operation(summary = "查询导航列表", description = "查询导航列表") - @GetMapping("/list") - public R list() { - return R.ok(tabbarService.list()); - } - - - @Operation(summary = "更新导航", description = "更新导航") - @PutMapping - public R update(@RequestBody List tabbarEntityList) { - // 删除不在新增范围的导航菜单 - List idList = tabbarService.list().stream().map(AppTabbarEntity::getId).collect(Collectors.toList()); - List newIdList = tabbarEntityList.stream().map(AppTabbarEntity::getId).collect(Collectors.toList()); - tabbarService.removeBatchByIds(CollUtil.subtractToList(idList, newIdList)); - return R.ok(tabbarService.saveOrUpdateBatch(tabbarEntityList)); - } + @Operation(summary = "更新导航", description = "更新导航") + @PutMapping + public R update(@RequestBody List tabbarEntityList) { + // 删除不在新增范围的导航菜单 + List idList = tabbarService.list().stream().map(AppTabbarEntity::getId).collect(Collectors.toList()); + List newIdList = tabbarEntityList.stream().map(AppTabbarEntity::getId).collect(Collectors.toList()); + tabbarService.removeBatchByIds(CollUtil.subtractToList(idList, newIdList)); + return R.ok(tabbarService.saveOrUpdateBatch(tabbarEntityList)); + } } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppUserController.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppUserController.java index b179d5cd0..2af86e9ee 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppUserController.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppUserController.java @@ -58,154 +58,147 @@ import java.util.List; @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class AppUserController { - private final AppUserService appUserService; + private final AppUserService appUserService; - @Inner - @GetMapping("/info/{username}") - public R info(@PathVariable String username) { - AppUser user = appUserService.getOne(Wrappers.query().lambda().eq(AppUser::getUsername, username).or().eq(AppUser::getPhone, username)); - if (user == null) { - return R.failed(MsgUtils.getMessage(ErrorCodes.APP_USER_USERINFO_EMPTY, username)); - } - return R.ok(appUserService.findUserInfo(user)); - } + @Inner + @GetMapping("/info/{username}") + public R info(@PathVariable String username) { + AppUser user = appUserService.getOne(Wrappers.query().lambda().eq(AppUser::getUsername, username).or() + .eq(AppUser::getPhone, username)); + if (user == null) { + return R.failed(MsgUtils.getMessage(ErrorCodes.APP_USER_USERINFO_EMPTY, username)); + } + return R.ok(appUserService.findUserInfo(user)); + } - /** - * 获取当前用户全部信息 - * - * @return 用户信息 - */ - @GetMapping(value = {"/info"}) - public R info() { - String username = SecurityUtils.getUser().getUsername(); - AppUser user = appUserService.getOne(Wrappers.query().lambda().eq(AppUser::getUsername, username)); - if (user == null) { - return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_QUERY_ERROR)); - } - return R.ok(appUserService.findUserInfo(user)); - } + /** + * 获取当前用户全部信息 + * @return 用户信息 + */ + @GetMapping(value = { "/info" }) + public R info() { + String username = SecurityUtils.getUser().getUsername(); + AppUser user = appUserService.getOne(Wrappers.query().lambda().eq(AppUser::getUsername, username)); + if (user == null) { + return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_QUERY_ERROR)); + } + return R.ok(appUserService.findUserInfo(user)); + } - /** - * 分页查询 - * - * @param page 分页对象 - * @param appUserDTO app用户表 - * @return - */ - @Operation(summary = "分页查询", description = "分页查询") - @GetMapping("/page") - public R getAppUserPage(Page page, AppUserDTO appUserDTO) { - return R.ok(appUserService.getUsersWithRolePage(page, appUserDTO)); - } + /** + * 分页查询 + * @param page 分页对象 + * @param appUserDTO app用户表 + * @return + */ + @Operation(summary = "分页查询", description = "分页查询") + @GetMapping("/page") + public R getAppUserPage(Page page, AppUserDTO appUserDTO) { + return R.ok(appUserService.getUsersWithRolePage(page, appUserDTO)); + } - /** - * 通过id查询app用户表 - * - * @param userId id - * @return R - */ - @Operation(summary = "通过id查询", description = "通过id查询") - @GetMapping("/details/{userId}") - public R getById(@PathVariable("userId") Long userId) { - return R.ok(appUserService.selectUserVoById(userId)); - } + /** + * 通过id查询app用户表 + * @param userId id + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/details/{userId}") + public R getById(@PathVariable("userId") Long userId) { + return R.ok(appUserService.selectUserVoById(userId)); + } - /** - * @return R - */ - @Operation(summary = "通过userName查询", description = "通过userName查询") - @GetMapping("/details") - public R getByUserName(AppUser user) { - AppUser one = appUserService.getOne(Wrappers.query(user), false); - return R.ok(one == null ? null : CommonConstants.SUCCESS); - } + /** + * @return R + */ + @Operation(summary = "通过userName查询", description = "通过userName查询") + @GetMapping("/details") + public R getByUserName(AppUser user) { + AppUser one = appUserService.getOne(Wrappers.query(user), false); + return R.ok(one == null ? null : CommonConstants.SUCCESS); + } - /** - * 新增app用户表 - * - * @param appUser app用户表 - * @return R - */ - @Operation(summary = "新增app用户表", description = "新增app用户表") - @SysLog("新增app用户表") - @PostMapping - @PreAuthorize("@pms.hasPermission('app_appuser_add')") - public R save(@RequestBody AppUserDTO appUser) { - appUserService.saveUser(appUser); - return R.ok(); - } + /** + * 新增app用户表 + * @param appUser app用户表 + * @return R + */ + @Operation(summary = "新增app用户表", description = "新增app用户表") + @SysLog("新增app用户表") + @PostMapping + @PreAuthorize("@pms.hasPermission('app_appuser_add')") + public R save(@RequestBody AppUserDTO appUser) { + appUserService.saveUser(appUser); + return R.ok(); + } - /** - * 修改app用户表 - * - * @param appUser app用户表 - * @return R - */ - @Operation(summary = "修改app用户表", description = "修改app用户表") - @SysLog("修改app用户表") - @PutMapping - @PreAuthorize("@pms.hasPermission('app_appuser_edit')") - public R updateById(@RequestBody AppUserDTO appUser) { - return R.ok(appUserService.updateUser(appUser)); - } + /** + * 修改app用户表 + * @param appUser app用户表 + * @return R + */ + @Operation(summary = "修改app用户表", description = "修改app用户表") + @SysLog("修改app用户表") + @PutMapping + @PreAuthorize("@pms.hasPermission('app_appuser_edit')") + public R updateById(@RequestBody AppUserDTO appUser) { + return R.ok(appUserService.updateUser(appUser)); + } - /** - * 通过id删除app用户表 - * - * @param ids userIds - * @return R - */ - @Operation(summary = "通过ids删除app用户表", description = "通过ids删除app用户表") - @SysLog("通过id删除app用户表") - @DeleteMapping - @PreAuthorize("@pms.hasPermission('app_appuser_del')") - public R removeById(@RequestBody Long[] ids) { - return R.ok(appUserService.deleteAppUserByIds(ids)); - } + /** + * 通过id删除app用户表 + * @param ids userIds + * @return R + */ + @Operation(summary = "通过ids删除app用户表", description = "通过ids删除app用户表") + @SysLog("通过id删除app用户表") + @DeleteMapping + @PreAuthorize("@pms.hasPermission('app_appuser_del')") + public R removeById(@RequestBody Long[] ids) { + return R.ok(appUserService.deleteAppUserByIds(ids)); + } - /** - * 导出excel 表格 - * - * @param appUser 查询条件 - * @return excel 文件流 - */ - @ResponseExcel - @GetMapping("/export") - @PreAuthorize("@pms.hasPermission('app_appuser_export')") - public List export(AppUserDTO appUser) { - return appUserService.listUser(appUser); - } + /** + * 导出excel 表格 + * @param appUser 查询条件 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('app_appuser_export')") + public List export(AppUserDTO appUser) { + return appUserService.listUser(appUser); + } - @SysLog("修改个人信息") - @PutMapping("/edit") - public R updateUserInfo(@Valid @RequestBody AppUserDTO userDto) { - if (UserTypeEnum.TOC.getStatus().equals(SecurityUtils.getUser().getUserType())) { - userDto.setUserId(SecurityUtils.getUser().getId()); - // TOC 以手机号为key - userDto.setUsername(SecurityUtils.getUser().getUsername()); - } - return appUserService.updateUserInfo(userDto); - } + @SysLog("修改个人信息") + @PutMapping("/edit") + public R updateUserInfo(@Valid @RequestBody AppUserDTO userDto) { + if (UserTypeEnum.TOC.getStatus().equals(SecurityUtils.getUser().getUserType())) { + userDto.setUserId(SecurityUtils.getUser().getId()); + // TOC 以手机号为key + userDto.setUsername(SecurityUtils.getUser().getUsername()); + } + return appUserService.updateUserInfo(userDto); + } - /** - * 导入用户 - * - * @param excelVOList 用户列表 - * @param bindingResult 错误信息列表 - * @return R - */ - @PostMapping("/import") - @PreAuthorize("@pms.hasPermission('app_appuser_export')") - public R importUser(@RequestExcel List excelVOList, BindingResult bindingResult) { - return appUserService.importUser(excelVOList, bindingResult); - } + /** + * 导入用户 + * @param excelVOList 用户列表 + * @param bindingResult 错误信息列表 + * @return R + */ + @PostMapping("/import") + @PreAuthorize("@pms.hasPermission('app_appuser_export')") + public R importUser(@RequestExcel List excelVOList, BindingResult bindingResult) { + return appUserService.importUser(excelVOList, bindingResult); + } - @Operation(summary = "注册app用户表", description = "注册app用户表") - @SysLog("注册app用户表") - @Inner(value = false) - @PostMapping("/register") - public R register(@RequestBody AppUserDTO appUser) { - return appUserService.registerAppUser(appUser); - } + @Operation(summary = "注册app用户表", description = "注册app用户表") + @SysLog("注册app用户表") + @Inner(value = false) + @PostMapping("/register") + public R register(@RequestBody AppUserDTO appUser) { + return appUserService.registerAppUser(appUser); + } } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/handler/SmsLoginHandler.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/handler/SmsLoginHandler.java index c0cf6362f..311cf195a 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/handler/SmsLoginHandler.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/handler/SmsLoginHandler.java @@ -34,65 +34,61 @@ import org.springframework.stereotype.Component; @AllArgsConstructor public class SmsLoginHandler extends AbstractLoginHandler { - private final AppUserService appUserService; + private final AppUserService appUserService; - /** - * 验证码登录传入为手机号 不用不处理 - * - * @param mobile - * @return - */ - @Override - public String identify(String mobile) { - return mobile; - } + /** + * 验证码登录传入为手机号 不用不处理 + * @param mobile + * @return + */ + @Override + public String identify(String mobile) { + return mobile; + } - /** - * 通过mobile 获取用户信息 - * - * @param identify - * @return - */ - @Override - public AppUserInfo info(String identify) { - AppUser user = appUserService.getOne(Wrappers.query().lambda().eq(AppUser::getPhone, identify)); + /** + * 通过mobile 获取用户信息 + * @param identify + * @return + */ + @Override + public AppUserInfo info(String identify) { + AppUser user = appUserService.getOne(Wrappers.query().lambda().eq(AppUser::getPhone, identify)); - if (user == null) { - log.info("手机号未注册:{}", identify); - return createAndSaveAppUserInfo(identify); - } - return appUserService.findUserInfo(user); - } + if (user == null) { + log.info("手机号未注册:{}", identify); + return createAndSaveAppUserInfo(identify); + } + return appUserService.findUserInfo(user); + } - /** - * 创建并插入用户 - * - * @param identify - * @return - */ - private AppUserInfo createAndSaveAppUserInfo(String phone) { - AppUser appUser = new AppUser(); - appUser.setUsername(phone); - appUser.setPhone(phone); - appUserService.saveOrUpdate(appUser, Wrappers.lambdaQuery().eq(AppUser::getPhone, phone)); + /** + * 创建并插入用户 + * @param identify + * @return + */ + private AppUserInfo createAndSaveAppUserInfo(String phone) { + AppUser appUser = new AppUser(); + appUser.setUsername(phone); + appUser.setPhone(phone); + appUserService.saveOrUpdate(appUser, Wrappers.lambdaQuery().eq(AppUser::getPhone, phone)); - AppUserInfo appUserDTO = new AppUserInfo(); - appUserDTO.setAppUser(appUser); - return appUserDTO; - } + AppUserInfo appUserDTO = new AppUserInfo(); + appUserDTO.setAppUser(appUser); + return appUserDTO; + } - /** - * 绑定逻辑 - * - * @param user 用户实体 - * @param identify 渠道返回唯一标识 - * @return - */ - @Override - public Boolean bind(AppUser user, String identify) { - user.setPhone(identify); - appUserService.updateById(user); - return true; - } + /** + * 绑定逻辑 + * @param user 用户实体 + * @param identify 渠道返回唯一标识 + * @return + */ + @Override + public Boolean bind(AppUser user, String identify) { + user.setPhone(identify); + appUserService.updateById(user); + return true; + } } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppArticleService.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppArticleService.java index 38665d9e8..e23a07aeb 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppArticleService.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppArticleService.java @@ -5,11 +5,11 @@ import com.pig4cloud.pigx.app.api.entity.AppArticleEntity; public interface AppArticleService extends IService { - /** - * 获取文章并使阅读数+1 - * - * @param id id - * @return - */ - AppArticleEntity getArticleAndIncrById(Long id, Long userId); + /** + * 获取文章并使阅读数+1 + * @param id id + * @return + */ + AppArticleEntity getArticleAndIncrById(Long id, Long userId); + } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppRoleService.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppRoleService.java index f6b769415..a1cb464d4 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppRoleService.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppRoleService.java @@ -33,7 +33,6 @@ import java.util.List; */ public interface AppRoleService extends IService { - List findRolesByUserId(Long userId); /** diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppUserService.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppUserService.java index aadfcef26..66655130a 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppUserService.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppUserService.java @@ -57,4 +57,5 @@ public interface AppUserService extends IService { R importUser(List excelVOList, BindingResult bindingResult); R registerAppUser(AppUserDTO appUser); + } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppArticleCollectServiceImpl.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppArticleCollectServiceImpl.java index fe44289a7..a4b9f5177 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppArticleCollectServiceImpl.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppArticleCollectServiceImpl.java @@ -5,6 +5,7 @@ import com.pig4cloud.pigx.app.api.entity.AppArticleCollectEntity; import com.pig4cloud.pigx.app.mapper.AppArticleCollectMapper; import com.pig4cloud.pigx.app.service.AppArticleCollectService; import org.springframework.stereotype.Service; + /** * 文章收藏表 * @@ -12,5 +13,7 @@ import org.springframework.stereotype.Service; * @date 2023-06-16 14:33:41 */ @Service -public class AppArticleCollectServiceImpl extends ServiceImpl implements AppArticleCollectService { +public class AppArticleCollectServiceImpl extends ServiceImpl + implements AppArticleCollectService { + } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppArticleServiceImpl.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppArticleServiceImpl.java index 711a7dedf..a0f5ff3bf 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppArticleServiceImpl.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppArticleServiceImpl.java @@ -20,33 +20,34 @@ import java.util.Objects; */ @Service @RequiredArgsConstructor -public class AppArticleServiceImpl extends ServiceImpl implements AppArticleService { +public class AppArticleServiceImpl extends ServiceImpl + implements AppArticleService { - private final AppArticleCollectMapper collectMapper; + private final AppArticleCollectMapper collectMapper; + /** + * 获取文章并使阅读数+1 + * @param id id + * @return + */ + @Override + public AppArticleEntity getArticleAndIncrById(Long id, Long userId) { + AppArticleEntity appArticleEntity = baseMapper.selectById(id); + // 查询是否收藏了 + if (Objects.nonNull(userId)) { + boolean exists = collectMapper.exists(Wrappers.lambdaQuery()// + .eq(AppArticleCollectEntity::getArticleId, appArticleEntity.getId())// + .eq(AppArticleCollectEntity::getUserId, userId)); + appArticleEntity.setCollect(exists); + } - /** - * 获取文章并使阅读数+1 - * - * @param id id - * @return - */ - @Override - public AppArticleEntity getArticleAndIncrById(Long id, Long userId) { - AppArticleEntity appArticleEntity = baseMapper.selectById(id); - // 查询是否收藏了 - if (Objects.nonNull(userId)) { - boolean exists = collectMapper.exists(Wrappers.lambdaQuery()// - .eq(AppArticleCollectEntity::getArticleId, appArticleEntity.getId())// - .eq(AppArticleCollectEntity::getUserId, userId)); - appArticleEntity.setCollect(exists); - } + // TODO 更新条件需要根据其他指数限制 + Integer nowVisit = appArticleEntity.getVisit(); + appArticleEntity.setVisit(nowVisit + 1); + // 乐观锁 + baseMapper.update(appArticleEntity, Wrappers.lambdaQuery().eq(AppArticleEntity::getId, id) + .eq(AppArticleEntity::getVisit, nowVisit)); + return appArticleEntity; + } - //TODO 更新条件需要根据其他指数限制 - Integer nowVisit = appArticleEntity.getVisit(); - appArticleEntity.setVisit(nowVisit + 1); - // 乐观锁 - baseMapper.update(appArticleEntity, Wrappers.lambdaQuery().eq(AppArticleEntity::getId, id).eq(AppArticleEntity::getVisit, nowVisit)); - return appArticleEntity; - } } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppMobileServiceImpl.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppMobileServiceImpl.java index 8e441d179..580795371 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppMobileServiceImpl.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppMobileServiceImpl.java @@ -44,28 +44,29 @@ import java.util.concurrent.TimeUnit; @AllArgsConstructor public class AppMobileServiceImpl implements AppMobileService { - private final RedisTemplate redisTemplate; + private final RedisTemplate redisTemplate; + /** + * 发送手机验证码 TODO: 调用短信网关发送验证码,测试返回前端 + * @param mobile mobile + * @return code + */ + @Override + public R sendSmsCode(String mobile) { + Object codeObj = redisTemplate.opsForValue() + .get(CacheConstants.DEFAULT_CODE_KEY + LoginTypeEnum.APPSMS.getType() + StringPool.AT + mobile); - /** - * 发送手机验证码 TODO: 调用短信网关发送验证码,测试返回前端 - * - * @param mobile mobile - * @return code - */ - @Override - public R sendSmsCode(String mobile) { - Object codeObj = redisTemplate.opsForValue().get(CacheConstants.DEFAULT_CODE_KEY + LoginTypeEnum.APPSMS.getType() + StringPool.AT + mobile); + if (codeObj != null) { + log.info("手机号验证码未过期:{},{}", mobile, codeObj); + return R.ok(Boolean.FALSE, MsgUtils.getMessage(ErrorCodes.SYS_APP_SMS_OFTEN)); + } - if (codeObj != null) { - log.info("手机号验证码未过期:{},{}", mobile, codeObj); - return R.ok(Boolean.FALSE, MsgUtils.getMessage(ErrorCodes.SYS_APP_SMS_OFTEN)); - } - - String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE)); - log.debug("手机号生成验证码成功:{},{}", mobile, code); - redisTemplate.opsForValue().set(CacheConstants.DEFAULT_CODE_KEY + LoginTypeEnum.APPSMS.getType() + StringPool.AT + mobile, code, SecurityConstants.CODE_TIME, TimeUnit.SECONDS); - return R.ok(Boolean.TRUE, code); - } + String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE)); + log.debug("手机号生成验证码成功:{},{}", mobile, code); + redisTemplate.opsForValue().set( + CacheConstants.DEFAULT_CODE_KEY + LoginTypeEnum.APPSMS.getType() + StringPool.AT + mobile, code, + SecurityConstants.CODE_TIME, TimeUnit.SECONDS); + return R.ok(Boolean.TRUE, code); + } } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppRoleServiceImpl.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppRoleServiceImpl.java index b4a8293a4..0bc16fffd 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppRoleServiceImpl.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppRoleServiceImpl.java @@ -77,9 +77,8 @@ public class AppRoleServiceImpl extends ServiceImpl impl for (AppRoleExcelVO excel : excelVOList) { Set errorMsg = new HashSet<>(); // 检验角色名称或者角色编码是否存在 - boolean existRole = roleList.stream() - .anyMatch(appRole -> excel.getRoleName().equals(appRole.getRoleName()) - || excel.getRoleCode().equals(appRole.getRoleCode())); + boolean existRole = roleList.stream().anyMatch(appRole -> excel.getRoleName().equals(appRole.getRoleName()) + || excel.getRoleCode().equals(appRole.getRoleCode())); if (existRole) { errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(), diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppUserServiceImpl.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppUserServiceImpl.java index 82603ba2c..5d725fb2a 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppUserServiceImpl.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppUserServiceImpl.java @@ -159,10 +159,8 @@ public class AppUserServiceImpl extends ServiceImpl impl AppUserInfo info = new AppUserInfo(); info.setAppUser(user); // 设置角色列表 (ID) - List roleIds = appRoleService.findRolesByUserId(user.getUserId()) - .stream() - .map(AppRole::getRoleId) - .collect(Collectors.toList()); + List roleIds = appRoleService.findRolesByUserId(user.getUserId()).stream().map(AppRole::getRoleId) + .collect(Collectors.toList()); info.setRoles(ArrayUtil.toArray(roleIds, Long.class)); // 设置权限列表(menu.permission) @@ -213,7 +211,7 @@ public class AppUserServiceImpl extends ServiceImpl impl } // 删除用户关联表 this.appUserRoleService - .remove(Wrappers.lambdaQuery().in(AppUserRole::getUserId, CollUtil.toList(ids))); + .remove(Wrappers.lambdaQuery().in(AppUserRole::getUserId, CollUtil.toList(ids))); this.removeBatchByIds(CollUtil.toList(ids)); @@ -224,7 +222,7 @@ public class AppUserServiceImpl extends ServiceImpl impl @Override public R registerAppUser(AppUserDTO appUser) { List appUserList = baseMapper - .selectList(Wrappers.lambdaQuery().eq(AppUser::getPhone, appUser.getPhone())); + .selectList(Wrappers.lambdaQuery().eq(AppUser::getPhone, appUser.getPhone())); if (CollUtil.isNotEmpty(appUserList)) { return R.failed("手机号已注册,请使用验证码直接登录"); @@ -266,7 +264,7 @@ public class AppUserServiceImpl extends ServiceImpl impl Set errorMsg = new HashSet<>(); // 校验用户名是否存在 boolean exsitUserName = userList.stream() - .anyMatch(sysUser -> excel.getUsername().equals(sysUser.getUsername())); + .anyMatch(sysUser -> excel.getUsername().equals(sysUser.getUsername())); if (exsitUserName) { errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, excel.getUsername())); @@ -275,8 +273,8 @@ public class AppUserServiceImpl extends ServiceImpl impl // 判断输入的角色名称列表是否合法 List roleNameList = StrUtil.split(excel.getRoleNameList(), StrUtil.COMMA); List roleCollList = roleList.stream() - .filter(role -> roleNameList.stream().anyMatch(name -> role.getRoleName().equals(name))) - .collect(Collectors.toList()); + .filter(role -> roleNameList.stream().anyMatch(name -> role.getRoleName().equals(name))) + .collect(Collectors.toList()); if (roleCollList.size() != roleNameList.size()) { errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_ROLENAME_INEXISTENCE, excel.getRoleNameList()));