🎨 Improving structure / format of the code.
This commit is contained in:
1 parent
fceb882670
commit
fd660ac655
18 files changed
+589
-616
No files matched your search
+12
-12
@@ -12,19 +12,19 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AppUserDTO extends AppUser {
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@Schema(description = "角色id集合")
|
||||
private List<Long> role;
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@Schema(description = "角色id集合")
|
||||
private List<Long> role;
|
||||
|
||||
/**
|
||||
* 新密码
|
||||
*/
|
||||
@Schema(description = "新密码")
|
||||
private String newpassword1;
|
||||
/**
|
||||
* 新密码
|
||||
*/
|
||||
@Schema(description = "新密码")
|
||||
private String newpassword1;
|
||||
|
||||
@Schema(description = "验证码")
|
||||
private String mobileCode;
|
||||
@Schema(description = "验证码")
|
||||
private String mobileCode;
|
||||
|
||||
}
|
||||
+52
-52
@@ -20,65 +20,65 @@ import java.time.LocalDateTime;
|
||||
@Schema(description = "文章收藏表")
|
||||
public class AppArticleCollectEntity extends Model<AppArticleCollectEntity> {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
+88
-87
@@ -20,106 +20,107 @@ import java.time.LocalDateTime;
|
||||
@Schema(description = "文章资讯")
|
||||
public class AppArticleEntity extends Model<AppArticleEntity> {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
+79
-84
@@ -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<AppArticleCollectEntity> wrapper = new MPJLambdaWrapper<AppArticleCollectEntity>().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<AppArticleCollectEntity> wrapper = new MPJLambdaWrapper<AppArticleCollectEntity>()
|
||||
.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.<AppArticleCollectEntity>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<AppArticleCollectEntity> 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.<AppArticleCollectEntity>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<AppArticleCollectEntity> export(AppArticleCollectEntity appArticleCollect) {
|
||||
return appArticleCollectService.list(Wrappers.query(appArticleCollect));
|
||||
}
|
||||
}
|
||||
+75
-82
@@ -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<AppArticleEntity> 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<AppArticleEntity> 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<AppArticleEntity> 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<AppArticleEntity> export(AppArticleEntity appArticle) {
|
||||
return appArticleService.list(Wrappers.query(appArticle));
|
||||
}
|
||||
|
||||
}
|
||||
+16
-19
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -148,7 +148,6 @@ public class AppRoleController {
|
||||
return R.ok(appRoleService.deleteRoleByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param appRole 查询条件
|
||||
|
||||
+19
-22
@@ -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<AppTabbarEntity> tabbarEntityList) {
|
||||
// 删除不在新增范围的导航菜单
|
||||
List<Long> idList = tabbarService.list().stream().map(AppTabbarEntity::getId).collect(Collectors.toList());
|
||||
List<Long> 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<AppTabbarEntity> tabbarEntityList) {
|
||||
// 删除不在新增范围的导航菜单
|
||||
List<Long> idList = tabbarService.list().stream().map(AppTabbarEntity::getId).collect(Collectors.toList());
|
||||
List<Long> newIdList = tabbarEntityList.stream().map(AppTabbarEntity::getId).collect(Collectors.toList());
|
||||
tabbarService.removeBatchByIds(CollUtil.subtractToList(idList, newIdList));
|
||||
return R.ok(tabbarService.saveOrUpdateBatch(tabbarEntityList));
|
||||
}
|
||||
|
||||
}
|
||||
+130
-137
@@ -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.<AppUser>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.<AppUser>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.<AppUser>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.<AppUser>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<AppUserExcelVO> export(AppUserDTO appUser) {
|
||||
return appUserService.listUser(appUser);
|
||||
}
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param appUser 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('app_appuser_export')")
|
||||
public List<AppUserExcelVO> 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<AppUserExcelVO> 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<AppUserExcelVO> 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);
|
||||
}
|
||||
|
||||
}
|
||||
+50
-54
@@ -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.<AppUser>query().lambda().eq(AppUser::getPhone, identify));
|
||||
/**
|
||||
* 通过mobile 获取用户信息
|
||||
* @param identify
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AppUserInfo info(String identify) {
|
||||
AppUser user = appUserService.getOne(Wrappers.<AppUser>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.<AppUser>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.<AppUser>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;
|
||||
}
|
||||
|
||||
}
|
||||
+7
-7
@@ -5,11 +5,11 @@ import com.pig4cloud.pigx.app.api.entity.AppArticleEntity;
|
||||
|
||||
public interface AppArticleService extends IService<AppArticleEntity> {
|
||||
|
||||
/**
|
||||
* 获取文章并使阅读数+1
|
||||
*
|
||||
* @param id id
|
||||
* @return
|
||||
*/
|
||||
AppArticleEntity getArticleAndIncrById(Long id, Long userId);
|
||||
/**
|
||||
* 获取文章并使阅读数+1
|
||||
* @param id id
|
||||
* @return
|
||||
*/
|
||||
AppArticleEntity getArticleAndIncrById(Long id, Long userId);
|
||||
|
||||
}
|
||||
-1
@@ -33,7 +33,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface AppRoleService extends IService<AppRole> {
|
||||
|
||||
|
||||
List<AppRole> findRolesByUserId(Long userId);
|
||||
|
||||
/**
|
||||
|
||||
+1
@@ -57,4 +57,5 @@ public interface AppUserService extends IService<AppUser> {
|
||||
R importUser(List<AppUserExcelVO> excelVOList, BindingResult bindingResult);
|
||||
|
||||
R registerAppUser(AppUserDTO appUser);
|
||||
|
||||
}
|
||||
+4
-1
@@ -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<AppArticleCollectMapper, AppArticleCollectEntity> implements AppArticleCollectService {
|
||||
public class AppArticleCollectServiceImpl extends ServiceImpl<AppArticleCollectMapper, AppArticleCollectEntity>
|
||||
implements AppArticleCollectService {
|
||||
|
||||
}
|
||||
+26
-25
@@ -20,33 +20,34 @@ import java.util.Objects;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AppArticleServiceImpl extends ServiceImpl<AppArticleMapper, AppArticleEntity> implements AppArticleService {
|
||||
public class AppArticleServiceImpl extends ServiceImpl<AppArticleMapper, AppArticleEntity>
|
||||
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.<AppArticleCollectEntity>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.<AppArticleCollectEntity>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.<AppArticleEntity>lambdaQuery().eq(AppArticleEntity::getId, id)
|
||||
.eq(AppArticleEntity::getVisit, nowVisit));
|
||||
return appArticleEntity;
|
||||
}
|
||||
|
||||
//TODO 更新条件需要根据其他指数限制
|
||||
Integer nowVisit = appArticleEntity.getVisit();
|
||||
appArticleEntity.setVisit(nowVisit + 1);
|
||||
// 乐观锁
|
||||
baseMapper.update(appArticleEntity, Wrappers.<AppArticleEntity>lambdaQuery().eq(AppArticleEntity::getId, id).eq(AppArticleEntity::getVisit, nowVisit));
|
||||
return appArticleEntity;
|
||||
}
|
||||
}
|
||||
+21
-20
@@ -44,28 +44,29 @@ import java.util.concurrent.TimeUnit;
|
||||
@AllArgsConstructor
|
||||
public class AppMobileServiceImpl implements AppMobileService {
|
||||
|
||||
private final RedisTemplate<String, String> redisTemplate;
|
||||
private final RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
/**
|
||||
* 发送手机验证码 TODO: 调用短信网关发送验证码,测试返回前端
|
||||
* @param mobile mobile
|
||||
* @return code
|
||||
*/
|
||||
@Override
|
||||
public R<Boolean> 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<Boolean> 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);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-3
@@ -77,9 +77,8 @@ public class AppRoleServiceImpl extends ServiceImpl<AppRoleMapper, AppRole> impl
|
||||
for (AppRoleExcelVO excel : excelVOList) {
|
||||
Set<String> 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(),
|
||||
|
||||
+7
-9
@@ -159,10 +159,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||
AppUserInfo info = new AppUserInfo();
|
||||
info.setAppUser(user);
|
||||
// 设置角色列表 (ID)
|
||||
List<Long> roleIds = appRoleService.findRolesByUserId(user.getUserId())
|
||||
.stream()
|
||||
.map(AppRole::getRoleId)
|
||||
.collect(Collectors.toList());
|
||||
List<Long> 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<AppUserMapper, AppUser> impl
|
||||
}
|
||||
// 删除用户关联表
|
||||
this.appUserRoleService
|
||||
.remove(Wrappers.<AppUserRole>lambdaQuery().in(AppUserRole::getUserId, CollUtil.toList(ids)));
|
||||
.remove(Wrappers.<AppUserRole>lambdaQuery().in(AppUserRole::getUserId, CollUtil.toList(ids)));
|
||||
|
||||
this.removeBatchByIds(CollUtil.toList(ids));
|
||||
|
||||
@@ -224,7 +222,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||
@Override
|
||||
public R registerAppUser(AppUserDTO appUser) {
|
||||
List<AppUser> appUserList = baseMapper
|
||||
.selectList(Wrappers.<AppUser>lambdaQuery().eq(AppUser::getPhone, appUser.getPhone()));
|
||||
.selectList(Wrappers.<AppUser>lambdaQuery().eq(AppUser::getPhone, appUser.getPhone()));
|
||||
|
||||
if (CollUtil.isNotEmpty(appUserList)) {
|
||||
return R.failed("手机号已注册,请使用验证码直接登录");
|
||||
@@ -266,7 +264,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||
Set<String> 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<AppUserMapper, AppUser> impl
|
||||
// 判断输入的角色名称列表是否合法
|
||||
List<String> roleNameList = StrUtil.split(excel.getRoleNameList(), StrUtil.COMMA);
|
||||
List<AppRole> 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()));
|
||||
|
||||
Reference in new issue
Block a user