From 7870f79674cd05be9e6ac119686b39834d574656 Mon Sep 17 00:00:00 2001 From: perry <292303709@qq.com> Date: Wed, 17 May 2023 21:50:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/user/AdminUserController.java | 9 +++ .../vo/MemberUserUpdatePasswordReqVO.java | 23 ++++++++ .../app/auth/vo/AppAuthSmsLoginReqVO.java | 5 ++ .../app/user/AppUserController.java | 13 ++++- .../service/auth/MemberAuthServiceImpl.java | 2 +- .../service/promoter/PromoterService.java | 9 +++ .../service/promoter/PromoterServiceImpl.java | 11 ++++ .../service/user/MemberUserService.java | 18 +++++- .../service/user/MemberUserServiceImpl.java | 44 ++++++++++++++- .../app/tenant/AppTenantController.java | 25 +++------ .../app/tenant/vo/TenantRespVO.java | 56 ++++++++++++++++--- .../src/main/resources/application.yaml | 1 + yudao-ui-admin/.env.dev | 4 +- yudao-ui-admin/.env.prod | 5 +- 14 files changed, 190 insertions(+), 35 deletions(-) create mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdatePasswordReqVO.java diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/AdminUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/AdminUserController.java index 2928eec17..7a8febc99 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/AdminUserController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/AdminUserController.java @@ -8,6 +8,8 @@ import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.module.member.controller.admin.user.dto.AdminUserQueryDTO; import cn.iocoder.yudao.module.member.controller.admin.user.vo.AdminUserInfoRespVO; import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUpdateStatusReqVO; +import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdatePasswordReqVO; +import cn.iocoder.yudao.module.member.controller.app.auth.vo.AppAuthResetPasswordReqVO; import cn.iocoder.yudao.module.member.convert.user.UserConvert; import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; import cn.iocoder.yudao.module.member.service.user.MemberUserService; @@ -60,6 +62,12 @@ public class AdminUserController { String avatar = userService.updateUserAvatar(getLoginUserId(), file.getInputStream()); return success(avatar); } + @PostMapping("/update-password") + @Operation(summary = "修改密码", description = "修改密码") + public CommonResult resetPassword(@RequestBody @Valid MemberUserUpdatePasswordReqVO reqVO) { + userService.updateUserPassword(reqVO.getId(),reqVO.getPassword()); + return success(true); + } @PutMapping("/update-status") @Operation(summary = "修改用户状态") @PreAuthorize("@ss.hasPermission('system:user:update')") @@ -67,6 +75,7 @@ public class AdminUserController { userService.updateUserStatus(reqVO.getId(), reqVO.getStatus()); return success(true); } + @GetMapping("/get") @Operation(summary = "获得基本信息") @PreAuthorize("@ss.hasPermission('member:user:query')") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdatePasswordReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdatePasswordReqVO.java new file mode 100644 index 000000000..fe433cba7 --- /dev/null +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdatePasswordReqVO.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.member.controller.admin.user.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 用户更新密码 Request VO") +@Data +public class MemberUserUpdatePasswordReqVO { + + @Schema(description = "用户编号", required = true, example = "1024") + @NotNull(message = "用户编号不能为空") + private Long id; + + @Schema(description = "密码", required = true, example = "123456") + @NotEmpty(message = "密码不能为空") + @Length(min = 4, max = 16, message = "密码长度为 4-16 位") + private String password; + +} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java index ba9b540aa..4421d09b0 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java @@ -30,6 +30,11 @@ public class AppAuthSmsLoginReqVO { @NotEmpty(message = "手机号不能为空") @Mobile private String mobile; + /** + * 推广员id + */ + @Schema(description = "推广员id", required = true, example = "张三") + private Long promoterId; @Schema(description = "手机验证码", required = true, example = "1024") @NotEmpty(message = "手机验证码不能为空") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.java index 6ebc80c43..354c0002f 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.member.controller.app.user; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoReqVO; @@ -9,6 +10,7 @@ import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoRespVO; import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserUpdateMobileReqVO; import cn.iocoder.yudao.module.member.convert.user.UserConvert; import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.member.service.promoter.PromoterService; import cn.iocoder.yudao.module.member.service.user.MemberUserService; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; @@ -35,6 +37,9 @@ public class AppUserController { @Resource private MemberUserService userService; + @Resource + private PromoterService promoterService; + @PutMapping("/update-nickname") @Operation(summary = "修改用户昵称") @PreAuthenticated @@ -59,7 +64,13 @@ public class AppUserController { @PreAuthenticated public CommonResult getUserInfo() { MemberUserDO user = userService.getUser(getLoginUserId()); - return success(UserConvert.INSTANCE.convert(user)); + AppUserInfoRespVO appUserInfoRespVO = UserConvert.INSTANCE.convert(user); + if(promoterService.checkIsPromoterByUserId(getLoginUserId())){ + appUserInfoRespVO.setUserType(UserTypeEnum.PROMOTER); + }else{ + appUserInfoRespVO.setUserType(UserTypeEnum.MEMBER); + } + return success(appUserInfoRespVO); } @PostMapping("/update-mobile") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java index 08bc7879a..b93e6ce5a 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java @@ -130,7 +130,7 @@ public class MemberAuthServiceImpl implements MemberAuthService { if (user != null) { throw new ServiceException(ErrorCodeConstants.AUTH_MOBILE_EXISTS); } - MemberUserDO memberUserDO = userService.createUserIfAbsent(reqVO.getMobile(),reqVO.getRealName(), userIp); + MemberUserDO memberUserDO = userService.createUserIfAbsent(reqVO.getMobile(),reqVO.getRealName(), userIp,reqVO.getPromoterId()); return memberUserDO.getId(); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/promoter/PromoterService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/promoter/PromoterService.java index f7adf24a0..d43e6bcae 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/promoter/PromoterService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/promoter/PromoterService.java @@ -44,6 +44,15 @@ public interface PromoterService { */ PromoterDO getPromoter(Long id); + + /** + * 获得推广员 + * + * @param id 编号 + * @return 推广员 + */ + Boolean checkIsPromoterByUserId(Long userId); + /** * 获得推广员列表 * diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/promoter/PromoterServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/promoter/PromoterServiceImpl.java index b48c169dc..2776136c0 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/promoter/PromoterServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/promoter/PromoterServiceImpl.java @@ -108,6 +108,17 @@ public class PromoterServiceImpl implements PromoterService { return promoterMapper.selectById(id); } + /** + * 获得推广员 + * + * @param userId@return 推广员 + */ + @Override + public Boolean checkIsPromoterByUserId(Long userId) { + Long count = this.promoterMapper.selectCount(Wrappers.lambdaQuery(PromoterDO.class).eq(PromoterDO::getUserId,userId)); + return count>0; + } + @Override public List getPromoterList(Collection ids) { return promoterMapper.selectBatchIds(ids); diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java index 524123442..f54817e37 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java @@ -43,6 +43,16 @@ public interface MemberUserService { */ MemberUserDO createUserIfAbsent(@Mobile String mobile, String realName,String registerIp); + /** + * 基于手机号创建用户。 + * 如果用户已经存在,则直接进行返回 + * + * @param mobile 手机号 + * @param registerIp 注册 IP + * @return 用户对象 + */ + MemberUserDO createUserIfAbsent(@Mobile String mobile, String realName,String registerIp,Long promoterId); + /** * 更新用户的最后登陆信息 * @@ -81,7 +91,13 @@ public interface MemberUserService { * @return 头像url */ String updateUserAvatar(Long userId, InputStream inputStream) throws Exception; - + /** + * 修改密码 + * + * @param id 用户编号 + * @param password 密码 + */ + void updateUserPassword(Long id, String password); void updateUserStatus(Long id, Integer status) ; /** diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java index 2709c9d10..88a3dbeca 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java @@ -68,10 +68,31 @@ public class MemberUserServiceImpl implements MemberUserService { return user; } // 用户不存在,则进行创建 - return this.createUser(mobile, realName, registerIp); + return this.createUser(mobile, realName, registerIp,null); } - private MemberUserDO createUser(String mobile,String realName, String registerIp) { + /** + * 基于手机号创建用户。 + * 如果用户已经存在,则直接进行返回 + * + * @param mobile 手机号 + * @param realName + * @param registerIp 注册 IP + * @param promoterId + * @return 用户对象 + */ + @Override + public MemberUserDO createUserIfAbsent(String mobile, String realName, String registerIp, Long promoterId) { + // 用户已经存在 + MemberUserDO user = memberUserMapper.selectByMobile(mobile); + if (user != null) { + return user; + } + // 用户不存在,则进行创建 + return this.createUser(mobile, realName, registerIp,promoterId); + } + + private MemberUserDO createUser(String mobile, String realName, String registerIp,Long promoterId) { // 生成密码 String password = IdUtil.fastSimpleUUID(); // 插入用户 @@ -81,6 +102,7 @@ public class MemberUserServiceImpl implements MemberUserService { user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 user.setPassword(encodePassword(password)); // 加密密码 user.setRegisterIp(registerIp); + user.setPromoterId(promoterId); memberUserMapper.insert(user); return user; } @@ -123,6 +145,24 @@ public class MemberUserServiceImpl implements MemberUserService { memberUserMapper.updateById(MemberUserDO.builder().id(userId).avatar(avatar).build()); return avatar; } + + /** + * 修改密码 + * + * @param id 用户编号 + * @param password 密码 + */ + @Override + public void updateUserPassword(Long id, String password) { + // 校验用户存在 + this.checkUserExists(id); + // 更新密码 + MemberUserDO userDO = new MemberUserDO(); + userDO.setId(id); + userDO.setPassword(encodePassword(password)); + memberUserMapper.updateById(userDO); + } + @Override public void updateUserStatus(Long id, Integer status) { // 校验用户存在 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/tenant/AppTenantController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/tenant/AppTenantController.java index d20a0db5d..f52ff8bf4 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/tenant/AppTenantController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/tenant/AppTenantController.java @@ -1,35 +1,25 @@ package cn.iocoder.yudao.module.system.controller.app.tenant; -import cn.hutool.core.date.LocalDateTimeUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.*; +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRespVO; import cn.iocoder.yudao.module.system.convert.tenant.TenantConvert; import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; import cn.iocoder.yudao.module.system.service.tenant.TenantService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -import javax.annotation.security.PermitAll; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; -import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -@Tag(name = "管理后台 - 租户") +@Tag(name = "用户APP - 租户") @RestController -@RequestMapping("/system/tenant") +@RequestMapping("/tenant") public class AppTenantController { @Resource @@ -40,7 +30,6 @@ public class AppTenantController { @GetMapping("/get") @Operation(summary = "获得租户") @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('system:tenant:query')") public CommonResult getTenant(@RequestParam("id") Long id) { TenantDO tenant = tenantService.getTenant(id); return success(TenantConvert.INSTANCE.convert(tenant)); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/tenant/vo/TenantRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/tenant/vo/TenantRespVO.java index bc5510881..c9f19c4be 100755 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/tenant/vo/TenantRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/tenant/vo/TenantRespVO.java @@ -1,25 +1,65 @@ package cn.iocoder.yudao.module.system.controller.app.tenant.vo; -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantBaseVO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.ToString; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - @Schema(description = "管理后台 - 租户 Response VO") @Data -@EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class TenantRespVO extends TenantBaseVO { +public class TenantRespVO { @Schema(description = "租户编号", required = true, example = "1024") private Long id; @Schema(description = "租户名", required = true, example = "芋道") - @NotNull(message = "租户名不能为空") private String name; + /** + * 简介 + */ + @Schema(description = "简介", example = "https://www.iocoder.cn") + private String introduction; + + /** + * 服务电话 + */ + @Schema(description = "服务电话", example = "https://www.iocoder.cn") + private String serviceMobile; + + /** + * 服务时间 + */ + @Schema(description = "服务时间", example = "https://www.iocoder.cn") + private String serviceTime; + + /** + * 微信客服地址 + */ + @Schema(description = "微信客服地址", example = "https://www.iocoder.cn") + private String wxKfUrl; + + /** + * 通知公告 + */ + @Schema(description = "通知公告", example = "https://www.iocoder.cn") + private String notice; + + /** + * logo + */ + @Schema(description = "logo", example = "https://www.iocoder.cn") + private String logo; + + /** + * 商品提成 + */ + @Schema(description = "商品提成") + private Integer goodsCommission; + /** + * 会员充值提成 + */ + @Schema(description = "会员充值提成") + private Integer memberCommission; + } diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index 4de32b44a..44314a38b 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -108,6 +108,7 @@ yudao: permit-all_urls: - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录 - /admin-api/notice/wxpay/** + - /app-api/tenant/get websocket: enable: true # websocket的开关 path: /websocket/message # 路径 diff --git a/yudao-ui-admin/.env.dev b/yudao-ui-admin/.env.dev index ddd0c6f76..49a1abca4 100644 --- a/yudao-ui-admin/.env.dev +++ b/yudao-ui-admin/.env.dev @@ -5,8 +5,8 @@ ENV = 'development' VUE_APP_TITLE = 创盈商户管理系统 # 芋道管理系统/开发环境 -VUE_APP_BASE_API = 'https://cmx.bskies.cc:8000/admin-api' -#VUE_APP_BASE_API = 'http://192.168.1.147:48080' +#VUE_APP_BASE_API = 'https://cmx.bskies.cc:8000/admin-api' +VUE_APP_BASE_API = 'http://192.168.2.71:48080' # 路由懒加载 VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/yudao-ui-admin/.env.prod b/yudao-ui-admin/.env.prod index 32e93cdb5..617126f3d 100644 --- a/yudao-ui-admin/.env.prod +++ b/yudao-ui-admin/.env.prod @@ -6,11 +6,12 @@ VUE_APP_TITLE = 创盈商户管理系统 # 创盈管理系统/生产环境 VUE_APP_BASE_API = 'https://cmx.bskies.cc:8000/admin-api' +#VUE_APP_BASE_API = 'http://192.168.2.71:48080' # 根据服务器或域名修改 -PUBLIC_PATH = 'https://cmx.bskies.cc:8000/cy-admin' +#PUBLIC_PATH = 'https://cmx.bskies.cc:8000/cy-admin' # 二级部署路径 -VUE_APP_APP_NAME ='cy-admin' +#VUE_APP_APP_NAME ='cy-admin' # 多租户的开关 VUE_APP_TENANT_ENABLE = true