mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
code review:签到配置
This commit is contained in:
parent
4257cad46a
commit
c5e85f3bfb
@ -1640,11 +1640,11 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
|
|||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2276, '积分设置查询', 'member:point:config:get', 3, 1, 2275, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 02:07:44', '', '2023-06-10 02:07:44', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2276, '积分设置查询', 'member:point:config:get', 3, 1, 2275, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 02:07:44', '', '2023-06-10 02:07:44', b'0');
|
||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2277, '积分设置创建', 'member:point:config:save', 3, 2, 2275, '', '', '', '', 0, b'1', b'1', b'1', '', '2023-06-10 02:07:44', '1', '2023-06-27 20:32:31', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2277, '积分设置创建', 'member:point:config:save', 3, 2, 2275, '', '', '', '', 0, b'1', b'1', b'1', '', '2023-06-10 02:07:44', '1', '2023-06-27 20:32:31', b'0');
|
||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2281, '签到配置', '', 2, 2, 2300, 'sign-in-config', '', 'member/signin/config/index', 'SignInConfig', 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '1', '2023-07-02 15:04:15', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2281, '签到配置', '', 2, 2, 2300, 'sign-in-config', '', 'member/signin/config/index', 'SignInConfig', 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '1', '2023-07-02 15:04:15', b'0');
|
||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2282, '积分签到规则查询', 'member:point:sign-in-config:query', 3, 1, 2281, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '', '2023-06-10 03:26:12', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2282, '签到规则查询', 'member:point:sign-in-config:query', 3, 1, 2281, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '', '2023-06-10 03:26:12', b'0');
|
||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2283, '积分签到规则创建', 'member:point:sign-in-config:create', 3, 2, 2281, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '', '2023-06-10 03:26:12', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2283, '签到规则创建', 'member:point:sign-in-config:create', 3, 2, 2281, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '', '2023-06-10 03:26:12', b'0');
|
||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2284, '积分签到规则更新', 'member:point:sign-in-config:update', 3, 3, 2281, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '', '2023-06-10 03:26:12', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2284, '签到规则更新', 'member:point:sign-in-config:update', 3, 3, 2281, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '', '2023-06-10 03:26:12', b'0');
|
||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2285, '积分签到规则删除', 'member:point:sign-in-config:delete', 3, 4, 2281, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '', '2023-06-10 03:26:12', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2285, '签到规则删除', 'member:point:sign-in-config:delete', 3, 4, 2281, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '', '2023-06-10 03:26:12', b'0');
|
||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2286, '积分签到规则获取', 'member:point:sign-in-config:get', 3, 5, 2281, '', '', '', '', 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '1', '2023-08-19 09:48:32', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2286, '签到规则获取', 'member:point:sign-in-config:get', 3, 5, 2281, '', '', '', '', 0, b'1', b'1', b'1', '', '2023-06-10 03:26:12', '1', '2023-08-19 09:48:32', b'0');
|
||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2287, '积分记录', '', 2, 1, 2299, 'record', '', 'member/point/record/index', 'PointRecord', 0, b'1', b'1', b'1', '', '2023-06-10 04:18:50', '1', '2023-06-27 22:51:07', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2287, '积分记录', '', 2, 1, 2299, 'record', '', 'member/point/record/index', 'PointRecord', 0, b'1', b'1', b'1', '', '2023-06-10 04:18:50', '1', '2023-06-27 22:51:07', b'0');
|
||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2288, '用户积分记录查询', 'member:point:record:query', 3, 1, 2287, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 04:18:50', '', '2023-06-10 04:18:50', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2288, '用户积分记录查询', 'member:point:record:query', 3, 1, 2287, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-06-10 04:18:50', '', '2023-06-10 04:18:50', b'0');
|
||||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2293, '签到记录', '', 2, 3, 2300, 'sign-in-record', '', 'member/signin/record/index', 'SignInRecord', 0, b'1', b'1', b'1', '', '2023-06-10 04:48:22', '1', '2023-07-02 15:04:10', b'0');
|
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2293, '签到记录', '', 2, 3, 2300, 'sign-in-record', '', 'member/signin/record/index', 'SignInRecord', 0, b'1', b'1', b'1', '', '2023-06-10 04:48:22', '1', '2023-07-02 15:04:10', b'0');
|
||||||
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 积分签到规则")
|
@Tag(name = "管理后台 - 签到规则")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/member/point/sign-in-config")
|
@RequestMapping("/member/point/sign-in-config")
|
||||||
@Validated
|
@Validated
|
||||||
@ -30,14 +30,14 @@ public class MemberSignInConfigController {
|
|||||||
private MemberSignInConfigService signInConfigService;
|
private MemberSignInConfigService signInConfigService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建积分签到规则")
|
@Operation(summary = "创建签到规则")
|
||||||
@PreAuthorize("@ss.hasPermission('point:sign-in-config:create')")
|
@PreAuthorize("@ss.hasPermission('point:sign-in-config:create')")
|
||||||
public CommonResult<Long> createSignInConfig(@Valid @RequestBody MemberSignInConfigCreateReqVO createReqVO) {
|
public CommonResult<Long> createSignInConfig(@Valid @RequestBody MemberSignInConfigCreateReqVO createReqVO) {
|
||||||
return success(signInConfigService.createSignInConfig(createReqVO));
|
return success(signInConfigService.createSignInConfig(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新积分签到规则")
|
@Operation(summary = "更新签到规则")
|
||||||
@PreAuthorize("@ss.hasPermission('point:sign-in-config:update')")
|
@PreAuthorize("@ss.hasPermission('point:sign-in-config:update')")
|
||||||
public CommonResult<Boolean> updateSignInConfig(@Valid @RequestBody MemberSignInConfigUpdateReqVO updateReqVO) {
|
public CommonResult<Boolean> updateSignInConfig(@Valid @RequestBody MemberSignInConfigUpdateReqVO updateReqVO) {
|
||||||
signInConfigService.updateSignInConfig(updateReqVO);
|
signInConfigService.updateSignInConfig(updateReqVO);
|
||||||
@ -45,7 +45,7 @@ public class MemberSignInConfigController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除积分签到规则")
|
@Operation(summary = "删除签到规则")
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('point:sign-in-config:delete')")
|
@PreAuthorize("@ss.hasPermission('point:sign-in-config:delete')")
|
||||||
public CommonResult<Boolean> deleteSignInConfig(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> deleteSignInConfig(@RequestParam("id") Long id) {
|
||||||
@ -54,7 +54,7 @@ public class MemberSignInConfigController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得积分签到规则")
|
@Operation(summary = "获得签到规则")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('point:sign-in-config:query')")
|
@PreAuthorize("@ss.hasPermission('point:sign-in-config:query')")
|
||||||
public CommonResult<MemberSignInConfigRespVO> getSignInConfig(@RequestParam("id") Long id) {
|
public CommonResult<MemberSignInConfigRespVO> getSignInConfig(@RequestParam("id") Long id) {
|
||||||
@ -63,7 +63,7 @@ public class MemberSignInConfigController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "获得积分签到规则分页")
|
@Operation(summary = "获得签到规则列表")
|
||||||
@PreAuthorize("@ss.hasPermission('point:sign-in-config:query')")
|
@PreAuthorize("@ss.hasPermission('point:sign-in-config:query')")
|
||||||
public CommonResult<List<MemberSignInConfigRespVO>> getSignInConfigList() {
|
public CommonResult<List<MemberSignInConfigRespVO>> getSignInConfigList() {
|
||||||
List<MemberSignInConfigDO> pageResult = signInConfigService.getSignInConfigList();
|
List<MemberSignInConfigDO> pageResult = signInConfigService.getSignInConfigList();
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config;
|
package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分签到规则 Base VO,提供给添加、修改、详细的子 VO 使用
|
* 签到规则 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class MemberSignInConfigBaseVO {
|
public class MemberSignInConfigBaseVO {
|
||||||
|
|
||||||
@Schema(description = "签到第 x 天", requiredMode = Schema.RequiredMode.REQUIRED, example = "7")
|
@Schema(description = "签到第 x 天", requiredMode = Schema.RequiredMode.REQUIRED, example = "7")
|
||||||
@NotNull(message = "签到天数不能为空")
|
@NotNull(message = "签到天数不能为空")
|
||||||
private Integer day;
|
private Integer day;
|
||||||
@ -20,8 +22,9 @@ public class MemberSignInConfigBaseVO {
|
|||||||
@NotNull(message = "奖励积分不能为空")
|
@NotNull(message = "奖励积分不能为空")
|
||||||
private Integer point;
|
private Integer point;
|
||||||
|
|
||||||
@NotNull
|
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@NotNull(message = "状态不能为空")
|
||||||
private Boolean enable;
|
@InEnum(CommonStatusEnum.class)
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config;
|
|||||||
import lombok.*;
|
import lombok.*;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 积分签到规则创建 Request VO")
|
@Schema(description = "管理后台 - 签到规则创建 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
|
@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import lombok.*;
|
import lombok.*;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 积分签到规则 Response VO")
|
@Schema(description = "管理后台 - 签到规则 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
|
@ -5,7 +5,7 @@ import lombok.*;
|
|||||||
|
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 积分签到规则更新 Request VO")
|
@Schema(description = "管理后台 - 签到规则更新 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
|
@ -10,7 +10,7 @@ import org.mapstruct.factory.Mappers;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分签到规则 Convert
|
* 签到规则 Convert
|
||||||
*
|
*
|
||||||
* @author QingX
|
* @author QingX
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.member.dal.dataobject.signin;
|
package cn.iocoder.yudao.module.member.dal.dataobject.signin;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
@ -7,7 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分签到规则 DO
|
* 签到规则 DO
|
||||||
*
|
*
|
||||||
* @author QingX
|
* @author QingX
|
||||||
*/
|
*/
|
||||||
@ -27,7 +28,7 @@ public class MemberSignInConfigDO extends BaseDO {
|
|||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 签到第x天
|
* 签到第 x 天
|
||||||
*/
|
*/
|
||||||
private Integer day;
|
private Integer day;
|
||||||
/**
|
/**
|
||||||
@ -36,8 +37,10 @@ public class MemberSignInConfigDO extends BaseDO {
|
|||||||
private Integer point;
|
private Integer point;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否启用
|
* 状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link CommonStatusEnum}
|
||||||
*/
|
*/
|
||||||
private Boolean enable;
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分签到规则 Mapper
|
* 签到规则 Mapper
|
||||||
*
|
*
|
||||||
* @author QingX
|
* @author QingX
|
||||||
*/
|
*/
|
||||||
|
@ -8,14 +8,14 @@ import javax.validation.Valid;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分签到规则 Service 接口
|
* 签到规则 Service 接口
|
||||||
*
|
*
|
||||||
* @author QingX
|
* @author QingX
|
||||||
*/
|
*/
|
||||||
public interface MemberSignInConfigService {
|
public interface MemberSignInConfigService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建积分签到规则
|
* 创建签到规则
|
||||||
*
|
*
|
||||||
* @param createReqVO 创建信息
|
* @param createReqVO 创建信息
|
||||||
* @return 编号
|
* @return 编号
|
||||||
@ -23,31 +23,31 @@ public interface MemberSignInConfigService {
|
|||||||
Long createSignInConfig(@Valid MemberSignInConfigCreateReqVO createReqVO);
|
Long createSignInConfig(@Valid MemberSignInConfigCreateReqVO createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新积分签到规则
|
* 更新签到规则
|
||||||
*
|
*
|
||||||
* @param updateReqVO 更新信息
|
* @param updateReqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void updateSignInConfig(@Valid MemberSignInConfigUpdateReqVO updateReqVO);
|
void updateSignInConfig(@Valid MemberSignInConfigUpdateReqVO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除积分签到规则
|
* 删除签到规则
|
||||||
*
|
*
|
||||||
* @param id 编号
|
* @param id 编号
|
||||||
*/
|
*/
|
||||||
void deleteSignInConfig(Long id);
|
void deleteSignInConfig(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得积分签到规则
|
* 获得签到规则
|
||||||
*
|
*
|
||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 积分签到规则
|
* @return 签到规则
|
||||||
*/
|
*/
|
||||||
MemberSignInConfigDO getSignInConfig(Long id);
|
MemberSignInConfigDO getSignInConfig(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得积分签到规则分页
|
* 获得签到规则分页
|
||||||
*
|
*
|
||||||
* @return 积分签到规则分页
|
* @return 签到规则分页
|
||||||
*/
|
*/
|
||||||
List<MemberSignInConfigDO> getSignInConfigList();
|
List<MemberSignInConfigDO> getSignInConfigList();
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CO
|
|||||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分签到规则 Service 实现类
|
* 签到规则 Service 实现类
|
||||||
*
|
*
|
||||||
* @author QingX
|
* @author QingX
|
||||||
*/
|
*/
|
||||||
@ -73,13 +73,13 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
|
|||||||
* @param id 编号,只有更新的时候会传递
|
* @param id 编号,只有更新的时候会传递
|
||||||
*/
|
*/
|
||||||
private void validateSignInConfigDayDuplicate(Integer day, Long id) {
|
private void validateSignInConfigDayDuplicate(Integer day, Long id) {
|
||||||
MemberSignInConfigDO configDO = signInConfigMapper.selectByDay(day);
|
MemberSignInConfigDO config = signInConfigMapper.selectByDay(day);
|
||||||
// 1. 新增时,configDO 非空,则说明重复
|
// 1. 新增时,config 非空,则说明重复
|
||||||
if (id == null && configDO != null) {
|
if (id == null && config != null) {
|
||||||
throw exception(SIGN_IN_CONFIG_EXISTS);
|
throw exception(SIGN_IN_CONFIG_EXISTS);
|
||||||
}
|
}
|
||||||
// 2. 更新时,如果 configDO 非空,且 id 不相等,则说明重复
|
// 2. 更新时,如果 config 非空,且 id 不相等,则说明重复
|
||||||
if (id != null && configDO != null && !configDO.getId().equals(id)) {
|
if (id != null && config != null && !config.getId().equals(id)) {
|
||||||
throw exception(SIGN_IN_CONFIG_EXISTS);
|
throw exception(SIGN_IN_CONFIG_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,13 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|||||||
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
|
||||||
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
||||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest;
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest;
|
||||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserResetPasswordReqVO;
|
|
||||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdatePasswordReqVO;
|
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi;
|
|
||||||
import cn.iocoder.yudao.module.system.api.logger.LoginLogApi;
|
import cn.iocoder.yudao.module.system.api.logger.LoginLogApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi;
|
||||||
import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi;
|
import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi;
|
||||||
import cn.iocoder.yudao.module.system.api.social.SocialUserApi;
|
import cn.iocoder.yudao.module.system.api.social.SocialUserApi;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
@ -23,11 +20,8 @@ import javax.annotation.Resource;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||||
import static cn.hutool.core.util.RandomUtil.randomNumbers;
|
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString;
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
// TODO @芋艿:单测的 review,等逻辑都达成一致后
|
// TODO @芋艿:单测的 review,等逻辑都达成一致后
|
||||||
/**
|
/**
|
||||||
@ -61,55 +55,56 @@ public class MemberAuthServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
@Resource
|
@Resource
|
||||||
private MemberUserMapper memberUserMapper;
|
private MemberUserMapper memberUserMapper;
|
||||||
|
|
||||||
@Test
|
// TODO 芋艿:后续重构这个单测
|
||||||
public void testUpdatePassword_success(){
|
// @Test
|
||||||
// 准备参数
|
// public void testUpdatePassword_success(){
|
||||||
MemberUserDO userDO = randomUserDO();
|
// // 准备参数
|
||||||
memberUserMapper.insert(userDO);
|
// MemberUserDO userDO = randomUserDO();
|
||||||
|
// memberUserMapper.insert(userDO);
|
||||||
// 新密码
|
//
|
||||||
String newPassword = randomString();
|
// // 新密码
|
||||||
|
// String newPassword = randomString();
|
||||||
// 请求实体
|
//
|
||||||
AppMemberUserUpdatePasswordReqVO reqVO = AppMemberUserUpdatePasswordReqVO.builder()
|
// // 请求实体
|
||||||
.oldPassword(userDO.getPassword())
|
// AppMemberUserUpdatePasswordReqVO reqVO = AppMemberUserUpdatePasswordReqVO.builder()
|
||||||
.password(newPassword)
|
// .oldPassword(userDO.getPassword())
|
||||||
.build();
|
// .password(newPassword)
|
||||||
|
// .build();
|
||||||
// 测试桩
|
//
|
||||||
// 这两个相等是为了返回ture这个结果
|
// // 测试桩
|
||||||
when(passwordEncoder.matches(reqVO.getOldPassword(),reqVO.getOldPassword())).thenReturn(true);
|
// // 这两个相等是为了返回ture这个结果
|
||||||
when(passwordEncoder.encode(newPassword)).thenReturn(newPassword);
|
// when(passwordEncoder.matches(reqVO.getOldPassword(),reqVO.getOldPassword())).thenReturn(true);
|
||||||
|
// when(passwordEncoder.encode(newPassword)).thenReturn(newPassword);
|
||||||
// 更新用户密码
|
//
|
||||||
authService.updatePassword(userDO.getId(), reqVO);
|
// // 更新用户密码
|
||||||
assertEquals(memberUserMapper.selectById(userDO.getId()).getPassword(),newPassword);
|
// authService.updatePassword(userDO.getId(), reqVO);
|
||||||
}
|
// assertEquals(memberUserMapper.selectById(userDO.getId()).getPassword(),newPassword);
|
||||||
|
// }
|
||||||
@Test
|
|
||||||
public void testResetPassword_success(){
|
|
||||||
// 准备参数
|
|
||||||
MemberUserDO userDO = randomUserDO();
|
|
||||||
memberUserMapper.insert(userDO);
|
|
||||||
|
|
||||||
// 随机密码
|
|
||||||
String password = randomNumbers(11);
|
|
||||||
// 随机验证码
|
|
||||||
String code = randomNumbers(4);
|
|
||||||
|
|
||||||
// mock
|
|
||||||
when(passwordEncoder.encode(password)).thenReturn(password);
|
|
||||||
|
|
||||||
// 更新用户密码
|
|
||||||
AppMemberUserResetPasswordReqVO reqVO = new AppMemberUserResetPasswordReqVO();
|
|
||||||
reqVO.setMobile(userDO.getMobile());
|
|
||||||
reqVO.setPassword(password);
|
|
||||||
reqVO.setCode(code);
|
|
||||||
|
|
||||||
authService.resetPassword(reqVO);
|
|
||||||
assertEquals(memberUserMapper.selectById(userDO.getId()).getPassword(),password);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// TODO 芋艿:后续重构这个单测
|
||||||
|
// @Test
|
||||||
|
// public void testResetPassword_success(){
|
||||||
|
// // 准备参数
|
||||||
|
// MemberUserDO userDO = randomUserDO();
|
||||||
|
// memberUserMapper.insert(userDO);
|
||||||
|
//
|
||||||
|
// // 随机密码
|
||||||
|
// String password = randomNumbers(11);
|
||||||
|
// // 随机验证码
|
||||||
|
// String code = randomNumbers(4);
|
||||||
|
//
|
||||||
|
// // mock
|
||||||
|
// when(passwordEncoder.encode(password)).thenReturn(password);
|
||||||
|
//
|
||||||
|
// // 更新用户密码
|
||||||
|
// AppMemberUserResetPasswordReqVO reqVO = new AppMemberUserResetPasswordReqVO();
|
||||||
|
// reqVO.setMobile(userDO.getMobile());
|
||||||
|
// reqVO.setPassword(password);
|
||||||
|
// reqVO.setCode(code);
|
||||||
|
//
|
||||||
|
// authService.resetPassword(reqVO);
|
||||||
|
// assertEquals(memberUserMapper.selectById(userDO.getId()).getPassword(),password);
|
||||||
|
// }
|
||||||
|
|
||||||
// ========== 随机对象 ==========
|
// ========== 随机对象 ==========
|
||||||
|
|
||||||
|
@ -18,15 +18,12 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
|||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static cn.hutool.core.util.RandomUtil.*;
|
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||||
|
import static cn.hutool.core.util.RandomUtil.randomNumbers;
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.mockito.Mockito.eq;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
// TODO @芋艿:单测的 review,等逻辑都达成一致后
|
// TODO @芋艿:单测的 review,等逻辑都达成一致后
|
||||||
/**
|
/**
|
||||||
@ -57,41 +54,42 @@ public class MemberUserServiceImplTest extends BaseDbAndRedisUnitTest {
|
|||||||
@MockBean
|
@MockBean
|
||||||
private FileApi fileApi;
|
private FileApi fileApi;
|
||||||
|
|
||||||
@Test
|
// TODO 芋艿:后续重构这个单测
|
||||||
public void testUpdateNickName_success(){
|
// @Test
|
||||||
// mock 数据
|
// public void testUpdateNickName_success(){
|
||||||
MemberUserDO userDO = randomUserDO();
|
// // mock 数据
|
||||||
userMapper.insert(userDO);
|
// MemberUserDO userDO = randomUserDO();
|
||||||
|
// userMapper.insert(userDO);
|
||||||
// 随机昵称
|
//
|
||||||
String newNickName = randomString();
|
// // 随机昵称
|
||||||
|
// String newNickName = randomString();
|
||||||
// 调用接口修改昵称
|
//
|
||||||
memberUserService.updateUser(userDO.getId(),newNickName);
|
// // 调用接口修改昵称
|
||||||
// 查询新修改后的昵称
|
// memberUserService.updateUser(userDO.getId(),newNickName);
|
||||||
String nickname = memberUserService.getUser(userDO.getId()).getNickname();
|
// // 查询新修改后的昵称
|
||||||
// 断言
|
// String nickname = memberUserService.getUser(userDO.getId()).getNickname();
|
||||||
assertEquals(newNickName,nickname);
|
// // 断言
|
||||||
}
|
// assertEquals(newNickName,nickname);
|
||||||
|
// }
|
||||||
@Test
|
//
|
||||||
public void testUpdateAvatar_success() throws Exception {
|
// @Test
|
||||||
// mock 数据
|
// public void testUpdateAvatar_success() throws Exception {
|
||||||
MemberUserDO dbUser = randomUserDO();
|
// // mock 数据
|
||||||
userMapper.insert(dbUser);
|
// MemberUserDO dbUser = randomUserDO();
|
||||||
|
// userMapper.insert(dbUser);
|
||||||
// 准备参数
|
//
|
||||||
Long userId = dbUser.getId();
|
// // 准备参数
|
||||||
byte[] avatarFileBytes = randomBytes(10);
|
// Long userId = dbUser.getId();
|
||||||
ByteArrayInputStream avatarFile = new ByteArrayInputStream(avatarFileBytes);
|
// byte[] avatarFileBytes = randomBytes(10);
|
||||||
// mock 方法
|
// ByteArrayInputStream avatarFile = new ByteArrayInputStream(avatarFileBytes);
|
||||||
String avatar = randomString();
|
// // mock 方法
|
||||||
when(fileApi.createFile(eq(avatarFileBytes))).thenReturn(avatar);
|
// String avatar = randomString();
|
||||||
// 调用
|
// when(fileApi.createFile(eq(avatarFileBytes))).thenReturn(avatar);
|
||||||
String str = memberUserService.updateUserAvatar(userId, avatarFile);
|
// // 调用
|
||||||
// 断言
|
// String str = memberUserService.updateUserAvatar(userId, avatarFile);
|
||||||
assertEquals(avatar, str);
|
// // 断言
|
||||||
}
|
// assertEquals(avatar, str);
|
||||||
|
// }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateMobile_success(){
|
public void updateMobile_success(){
|
||||||
@ -117,7 +115,6 @@ public class MemberUserServiceImplTest extends BaseDbAndRedisUnitTest {
|
|||||||
AppMemberUserUpdateMobileReqVO reqVO = new AppMemberUserUpdateMobileReqVO();
|
AppMemberUserUpdateMobileReqVO reqVO = new AppMemberUserUpdateMobileReqVO();
|
||||||
reqVO.setMobile(newMobile);
|
reqVO.setMobile(newMobile);
|
||||||
reqVO.setCode(newCode);
|
reqVO.setCode(newCode);
|
||||||
reqVO.setOldMobile(oldMobile);
|
|
||||||
reqVO.setOldCode(oldCode);
|
reqVO.setOldCode(oldCode);
|
||||||
memberUserService.updateUserMobile(userDO.getId(),reqVO);
|
memberUserService.updateUserMobile(userDO.getId(),reqVO);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user