diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java index bbb18eca..564a4167 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java @@ -23,6 +23,8 @@ public class BaseConstants { public static final String TABLE_BASE_CAR_MAIN = "base_car_main"; /**新增标识*/ public static final String SIGN_CREATE = "create"; + /**邀请注册/授权给某个租户*/ + public static final String INVITE_CREATE = "invite_create"; /**编辑标识*/ public static final String SIGN_UPDATE = "update"; /**默认密码*/ diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/InviterTypeEnum.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/InviterTypeEnum.java new file mode 100644 index 00000000..8947d0c8 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/InviterTypeEnum.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.common; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 邀请者类型枚举 + * + * @author vinjor + */ +@AllArgsConstructor +@Getter +public enum InviterTypeEnum { + /** + * 员工邀请 + */ + STAFF("1","员工邀请"), + /** + * 客户邀请 + */ + CUSTOMER("2","客户邀请"); + + /** + * code + */ + private String code; + /** + * 名称 + */ + private String name; + +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/PromotionEnum.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/PromotionEnum.java new file mode 100644 index 00000000..b6e70dd9 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/PromotionEnum.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.common; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 推广渠道枚举 + * + * @author vinjor + */ +@AllArgsConstructor +@Getter +public enum PromotionEnum { + /** + * 微信小程序 + */ + WeChat("WeChat","微信小程序"); + + /** + * code + */ + private String code; + /** + * 名称 + */ + private String name; + +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/SystemEnum.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/SystemEnum.java index 40e75ac4..ba8b8191 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/SystemEnum.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/SystemEnum.java @@ -4,9 +4,9 @@ import lombok.AllArgsConstructor; import lombok.Getter; /** - * Bpm 消息的枚举 + * 系统枚举 * - * @author 芋道源码 + * @author vinjor-m */ @AllArgsConstructor @Getter diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/BasePromotionService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/BasePromotionService.java index c34384f2..d0fe09ea 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/BasePromotionService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/BasePromotionService.java @@ -22,12 +22,4 @@ public interface BasePromotionService extends IService { * @param page 分页规则 **/ IPage queryListPage(BasePromotionReqVO pageReqVO, Page page); - - /** - * 新增推广记录 - * @author 小李 - * @date 12:26 2024/8/14 - * @param promotionRespVO 新增对象 - **/ - Boolean createPromotion(BasePromotionRespVO promotionRespVO); } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/BasePromotionServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/BasePromotionServiceImpl.java index 21b96343..7153e0e5 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/BasePromotionServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/BasePromotionServiceImpl.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.custom.service.impl; -import cn.hutool.core.bean.BeanUtil; import cn.iocoder.yudao.module.custom.entity.BasePromotion; import cn.iocoder.yudao.module.custom.mapper.BasePromotionMapper; import cn.iocoder.yudao.module.custom.service.BasePromotionService; @@ -18,7 +17,6 @@ import org.springframework.stereotype.Service; **/ @Service public class BasePromotionServiceImpl extends ServiceImpl implements BasePromotionService { - /** * 分页查询推广记录 * @@ -30,17 +28,4 @@ public class BasePromotionServiceImpl extends ServiceImpl queryListPage(BasePromotionReqVO pageReqVO, Page page) { return baseMapper.queryListPage(pageReqVO, page); } - - /** - * 新增推广记录 - * @author 小李 - * @date 12:26 2024/8/14 - * @param promotionRespVO 新增对象 - **/ - @Override - public Boolean createPromotion(BasePromotionRespVO promotionRespVO){ - BasePromotion basePromotion = new BasePromotion(); - BeanUtil.copyProperties(promotionRespVO, basePromotion); - return baseMapper.insert(basePromotion) > 0; - } } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java index 9e3dce3a..3892b26b 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java @@ -34,14 +34,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import static cn.iocoder.yudao.common.BaseConstants.*; import static cn.iocoder.yudao.common.DictBaseConstants.DICT_CUS_TYPE; @@ -113,6 +114,8 @@ public class CustomerMainServiceImpl extends ServiceImpl roleCodes = new HashSet<>(); roleCodes.add(dict.getRemark()); permissionApi.assignUserRole(userId, roleCodes); + }else if(INVITE_CREATE.equals(sign)){ + //邀请注册/授权给某个租户 + //查询数据字典,根据客户类型匹配出预设角色code; + DictDataRespDTO dict = dictDataApi.getDictData(DICT_CUS_TYPE, main.getTypeCode()); + if (CUS_TYPE_CORP.equals(main.getTypeCode())) { + //查询当前登录用户所属租户的政企客户部门id(父级部门) + DeptRespDTO parentDept = deptApi.getDeptByName(DEPT_NAME_CORP_NAME); + //在部门表下新增一个部门 + DeptRespDTO deptRespDTO = new DeptRespDTO(); + deptRespDTO.setName(main.getCusName()); + deptRespDTO.setStatus(CommonStatusEnum.ENABLE.getStatus()); + //上级部门为本租户顶级部门 + deptRespDTO.setParentId(parentDept.getId()); + Long deptId = deptApi.saveDept(deptRespDTO); + //客户信息表绑定deptCode + main.setDeptCode(deptId); + }else{ + //私人客户和代办客户归属到默认的部门中 + String deptName = ""; + if(CUS_TYPE_PRIVATE.equals(main.getTypeCode())){ + deptName =DEPT_NAME_PRIVATE_NAME; + }else if(CUS_TYPE_AGENT.equals(main.getTypeCode())){ + deptName = DEPT_NAME_AGENT_NAME; + } + DeptRespDTO parentDept = deptApi.getDeptByName(deptName); + main.setDeptCode(parentDept.getId()); + } + //绑定角色 + Set roleCodes = new HashSet<>(); + roleCodes.add(dict.getRemark()); + permissionApi.assignUserRole(main.getUserId(), roleCodes); } - /*3、保存客户主表信息*/ //暂时写死会员id TODO main.setMemberLevelId("9d4567b7e68803933f4917a4aab6b745"); diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/CompanyStaffService.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/CompanyStaffService.java index 4354da58..6bc071ad 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/CompanyStaffService.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/CompanyStaffService.java @@ -1,15 +1,17 @@ package cn.iocoder.yudao.module.staff.service; -import cn.iocoder.yudao.module.staff.entity.CompanyStaff; import cn.iocoder.yudao.module.label.entity.Label; +import cn.iocoder.yudao.module.staff.entity.CompanyStaff; import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO; import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO; import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import javax.validation.Valid; +import java.util.Date; import java.util.List; /** @@ -110,4 +112,15 @@ public interface CompanyStaffService extends IService { * @date 14:53 2024/8/14 **/ List getRoleList(); + + /** + * 新增推广记录 + * @author vinjor-m + * @date 12:26 2024/8/14 + * @param uniqueCode 推广码 + * @param user 被推广用户 + * @param promotionChannel 推广渠道 + * @param registerTime 被推广用户注册的时间 + **/ + Boolean createPromotion(String uniqueCode, AdminUserDO user, String promotionChannel, Date registerTime); } diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java index 279499a4..145704c9 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java @@ -4,7 +4,14 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.common.BaseConstants; import cn.iocoder.yudao.common.CommonErrorCodeConstants; +import cn.iocoder.yudao.common.InviterTypeEnum; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; +import cn.iocoder.yudao.module.custom.entity.BasePromotion; +import cn.iocoder.yudao.module.custom.service.BasePromotionService; +import cn.iocoder.yudao.module.custom.service.CustomerMainService; +import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO; import cn.iocoder.yudao.module.label.entity.BusiLabel; import cn.iocoder.yudao.module.label.entity.Label; import cn.iocoder.yudao.module.label.service.BusiLabelService; @@ -24,13 +31,14 @@ import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.context.annotation.Lazy; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -38,10 +46,12 @@ import java.math.BigDecimal; import java.time.LocalDate; import java.time.Period; import java.time.ZoneId; +import java.util.Date; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import static cn.iocoder.yudao.common.BaseConstants.INVITE_CREATE; import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -80,6 +90,10 @@ public class CompanyStaffServiceImpl extends ServiceImpl getRoleList() { return roleApi.getRoleList(); } + + /** + * 新增推广记录---忽略租户 + * + * @param uniqueCode 推广码 + * @param user 被推广用户 + * @param promotionChannel 推广渠道 + * @param registerTime 被推广用户注册的时间 + * @author vinjor-m + * @date 12:26 2024/8/14 + **/ + @Override + @TenantIgnore + public Boolean createPromotion(String uniqueCode, AdminUserDO user, String promotionChannel, Date registerTime) { + /*1.先查是否是员工推广 */ + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(CompanyStaff::getUniqueCode,uniqueCode); + List staffList = this.list(queryWrapper); + if(!staffList.isEmpty()){ + //员工推广 + CompanyStaff staff = staffList.get(0); + // 插入推广记录 + BasePromotion basePromotion = new BasePromotion(); + basePromotion.setOldUserId(staff.getUserId()); + basePromotion.setOldUserName(staff.getName()); + basePromotion.setPromotionChannel(promotionChannel); + basePromotion.setNewUserId(user.getId()); + basePromotion.setNewUserName(user.getNickname()); + basePromotion.setRegisterTime(registerTime); + basePromotion.setUniqueCode(uniqueCode); + basePromotionService.save(basePromotion); + //取到该员工的租户,以该租户的角度去保存客户数据 + TenantUtils.execute(staff.getTenantId(), () -> { + CustomerMainSaveReqVO saveReqVO = new CustomerMainSaveReqVO(); + saveReqVO.setUserId(user.getId()); + saveReqVO.setPhoneNumber(user.getMobile()); + saveReqVO.setSex(user.getSex().toString()); + saveReqVO.setCusName(user.getNickname()); + //客户类型,统一为私人客户 + saveReqVO.setTypeCode("01"); + //客户来源,统一为04-维修 + saveReqVO.setDataFrom("04"); + //注册方式,统一为自主创建 + saveReqVO.setInviterType("01"); + //邀请者id + saveReqVO.setInviter(staff.getUserId().toString()); + //邀请者类型 + saveReqVO.setInviterType(InviterTypeEnum.STAFF.getCode()); + //邀请注册添加客户 + customerMainService.saveCustomer(saveReqVO,INVITE_CREATE); + }); + }else{ + /*2.不是员工推广,再查是否是客户推广*/ + } + return true; + } } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/wechat/controller/WechatLoginController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/wechat/controller/WechatLoginController.java similarity index 92% rename from dl-module-base/src/main/java/cn/iocoder/yudao/module/app/wechat/controller/WechatLoginController.java rename to dl-module-company/src/main/java/cn/iocoder/yudao/module/wechat/controller/WechatLoginController.java index 3029bdab..81ed8ee1 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/wechat/controller/WechatLoginController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/wechat/controller/WechatLoginController.java @@ -1,7 +1,7 @@ -package cn.iocoder.yudao.module.app.wechat.controller; +package cn.iocoder.yudao.module.wechat.controller; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.app.wechat.service.WechatService; +import cn.iocoder.yudao.module.wechat.service.WechatService; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginReqVO; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginRespVO; import cn.iocoder.yudao.module.system.service.auth.AdminAuthService; diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/wechat/service/WechatService.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/wechat/service/WechatService.java similarity index 94% rename from dl-module-base/src/main/java/cn/iocoder/yudao/module/app/wechat/service/WechatService.java rename to dl-module-company/src/main/java/cn/iocoder/yudao/module/wechat/service/WechatService.java index 29280b72..3ad779d2 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/wechat/service/WechatService.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/wechat/service/WechatService.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.app.wechat.service; +package cn.iocoder.yudao.module.wechat.service; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/wechat/service/impl/WechatServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/wechat/service/impl/WechatServiceImpl.java similarity index 91% rename from dl-module-base/src/main/java/cn/iocoder/yudao/module/app/wechat/service/impl/WechatServiceImpl.java rename to dl-module-company/src/main/java/cn/iocoder/yudao/module/wechat/service/impl/WechatServiceImpl.java index 067f087f..7781dca9 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/wechat/service/impl/WechatServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/wechat/service/impl/WechatServiceImpl.java @@ -1,10 +1,12 @@ -package cn.iocoder.yudao.module.app.wechat.service.impl; +package cn.iocoder.yudao.module.wechat.service.impl; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import cn.iocoder.yudao.common.PromotionEnum; import cn.iocoder.yudao.common.SystemEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.app.wechat.service.WechatService; +import cn.iocoder.yudao.module.staff.service.CompanyStaffService; +import cn.iocoder.yudao.module.wechat.service.WechatService; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO; @@ -18,6 +20,7 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -40,6 +43,8 @@ public class WechatServiceImpl implements WechatService { private AdminUserService userService; @Resource private PasswordEncoder passwordEncoder; + @Autowired + private CompanyStaffService companyStaffService; /** * 微信自动登录 * @@ -159,8 +164,10 @@ public class WechatServiceImpl implements WechatService { wxUser.setUsername(user.getUsername()); wxUser.setNickname(user.getNickname()); } + /*如果携带了邀请码,需要插入邀请记录并自动复制用户信息到邀请者的租户下 */ if(!StringUtils.isEmpty(inviteId)){ - //那邀请者的码查邀请者的信息 + //邀请注册,自动注册客户信息 + companyStaffService.createPromotion(inviteId,wxUser, PromotionEnum.WeChat.getCode(), new Date()); } return wxUser; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/controller/LoginController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/controller/LoginController.java index bac8b0d1..8108925a 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/controller/LoginController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/controller/LoginController.java @@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.security.config.SecurityProperties; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.module.app.vo.WxLoginBody; -import cn.iocoder.yudao.module.app.wechat.service.WechatService; +import cn.iocoder.yudao.module.wechat.service.WechatService; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginRespVO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.service.auth.AdminAuthService; diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java index bb12285e..f6bd0795 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; -import javax.validation.Valid; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -52,12 +51,19 @@ public interface AdminUserApi { AdminUserRespDTO getUserByOpenId(String openId,String tenantId); /** - * 通过用户 登录账户 查询用户 + * 通过用户 登录账户 查询用户---自动拼租户 * * @param username 用户登录账户 * @return 用户对象信息 */ AdminUserRespDTO getUserByUsername(String username); + /** + * 通过用户 登录账户 查询用户---不带租户 + * + * @param username 用户登录账户 + * @return 用户对象信息 + */ + AdminUserRespDTO getUserByUsernameNoTenantId(String username); /** * 通过用户 ID 查询用户下属 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java index a7bf43c0..719b2e4c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO; @@ -80,7 +81,7 @@ public class AdminUserApiImpl implements AdminUserApi { } /** - * 通过用户 登录账户 查询用户 + * 通过用户 登录账户 查询用户---自动拼租户 * * @param username 用户登录账户 * @return 用户对象信息 @@ -90,6 +91,18 @@ public class AdminUserApiImpl implements AdminUserApi { AdminUserDO user = userService.getUserByUsername(username); return BeanUtils.toBean(user, AdminUserRespDTO.class); } + /** + * 通过用户 登录账户 查询用户---不带租户 + * + * @param username 用户登录账户 + * @return 用户对象信息 + */ + @Override + @TenantIgnore + public AdminUserRespDTO getUserByUsernameNoTenantId(String username) { + AdminUserDO user = userService.getUserByUsernameNoTenantId(username); + return BeanUtils.toBean(user, AdminUserRespDTO.class); + } @Override public List getUserListBySubordinate(Long id) { diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java index a1c4b266..a1b23b8d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java @@ -120,6 +120,13 @@ public interface AdminUserService { * @return 用户对象信息 */ AdminUserDO getUserByUsername(String username); + /** + * 通过用户名查询用户---不带租户ID + * + * @param username 用户名 + * @return 用户对象信息 + */ + AdminUserDO getUserByUsernameNoTenantId(String username); /** * 通过手机号获取用户 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index cf55e617..0706cae2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -10,6 +10,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import cn.iocoder.yudao.module.infra.api.config.ConfigApi; import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO; @@ -278,6 +280,15 @@ public class AdminUserServiceImpl implements AdminUserService { return userMapper.selectByUsername(username); } + @Override + @TenantIgnore + public AdminUserDO getUserByUsernameNoTenantId(String username) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(AdminUserDO::getUsername,username) + .isNull(TenantBaseDO::getTenantId); + return userMapper.selectOne(queryWrapper); + } + @Override public AdminUserDO getUserByMobile(String mobile) { return userMapper.selectByMobile(mobile); diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index ed551dd6..4ed54734 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -349,6 +349,7 @@ yudao: - system_users - dl_base_notice - base_user_car + - base_car_brand ignore-caches: - permission_menu_ids - oauth_client