This commit is contained in:
Vinjor 2024-11-06 13:58:56 +08:00
parent 20b6bbe763
commit d0c0d02f97
6 changed files with 127 additions and 3 deletions

View File

@ -1,9 +1,12 @@
package cn.iocoder.yudao.module.staff.controller.app; package cn.iocoder.yudao.module.staff.controller.app;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.staff.service.ApiAppLoginService; import cn.iocoder.yudao.module.staff.service.ApiAppLoginService;
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -19,6 +22,8 @@ import org.springframework.web.bind.annotation.RestController;
public class ApiAppLoginController { public class ApiAppLoginController {
@Autowired @Autowired
private ApiAppLoginService apiAppLoginService; private ApiAppLoginService apiAppLoginService;
@Autowired
private CompanyStaffService companyStaffService;
/** /**
* 登录获取验证码 * 登录获取验证码
@ -33,5 +38,16 @@ public class ApiAppLoginController {
return apiAppLoginService.loginSmsCode(phone,sysCode); return apiAppLoginService.loginSmsCode(phone,sysCode);
} }
/**
* 客户查我的邀请人
* @author vinjor-M
* @date 10:40 2024/11/6
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@GetMapping("/getMyAdviser")
@TenantIgnore
public CommonResult<?> getMyAdviser(Long tenantId,String sysCode) {
return CommonResult.success(companyStaffService.getMyAdviser(tenantId,sysCode));
}
} }

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.staff.mapper;
import cn.iocoder.yudao.module.staff.entity.CompanyStaff; import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO; import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -17,4 +18,13 @@ import org.apache.ibatis.annotations.Param;
public interface CompanyStaffMapper extends BaseMapper<CompanyStaff> { public interface CompanyStaffMapper extends BaseMapper<CompanyStaff> {
IPage<CompanyStaff> selectListPage(@Param("map") CompanyStaffReqVO companyStaffReqVO, Page<CompanyStaff> page); IPage<CompanyStaff> selectListPage(@Param("map") CompanyStaffReqVO companyStaffReqVO, Page<CompanyStaff> page);
/**
* 客户查我的邀请人
* @author vinjor-M
* @date 11:05 2024/11/6
* @param tenantId 租户ID
* @param userId userId
* @return cn.iocoder.yudao.module.staff.entity.CompanyStaff
**/
CompanyStaffRespVO selectMyAdviser(@Param("tenantId") Long tenantId, @Param("userId") Long userId);
} }

View File

@ -131,4 +131,12 @@ public interface CompanyStaffService extends IService<CompanyStaff> {
* @date 17:23 2024/10/15 * @date 17:23 2024/10/15
**/ **/
void setStaffUnicode(); void setStaffUnicode();
/**
* 客户查我的邀请人
* @author vinjor-M
* @date 10:49 2024/11/6
* @return cn.iocoder.yudao.module.staff.entity.CompanyStaff
**/
CompanyStaffRespVO getMyAdviser(Long tenantId,String sysCode);
} }

View File

@ -3,9 +3,7 @@ package cn.iocoder.yudao.module.staff.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.BaseConstants; import cn.iocoder.yudao.common.*;
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.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
@ -40,6 +38,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -610,4 +609,80 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
this.updateBatchById(list); this.updateBatchById(list);
} }
} }
/**
* 客户查我的邀请人
*
* @return cn.iocoder.yudao.module.staff.entity.CompanyStaff
* @author vinjor-M
* @date 10:49 2024/11/6
**/
@Override
public CompanyStaffRespVO getMyAdviser(Long tenantId,String sysCode) {
if(null==tenantId){
tenantId = 180L;
}
if(StringUtils.isEmpty(sysCode)){
//默认维修业务系统标识
sysCode= SystemEnum.REPAIR.getCode();
}
Long userId = SecurityFrameworkUtils.getLoginUserId();
//员工信息
CompanyStaffRespVO staffRespVO = staffMapper.selectMyAdviser(tenantId,userId);
if(null!=staffRespVO){
//查员工的角色
if(sysCode.equals(SystemEnum.REPAIR.getCode())){
//维修系统
staffRespVO.setRoleName(getUserRoleRepair(staffRespVO.getUserId()));
}else if(sysCode.equals(SystemEnum.RESCUE.getCode())){
//救援 TODO
}else if(sysCode.equals(SystemEnum.INSPECTION.getCode())){
//检测 TODO
}
}
return staffRespVO;
}
/**
*
* @author vinjor-M
* @date 11:16 2024/11/6
* @param userId 用户ID
* @return java.lang.String
**/
private String getUserRoleRepair(Long userId) {
// 当前用户的角色信息
List<Long> byUserId = permissionApi.getRoleIdsByUserId(userId);
// 所有的角色信息
List<RoleReqDTO> roleList = roleApi.getRoleList();
// 过滤出登录用户有的角色信息
List<RoleReqDTO> collect = roleList.stream().filter(item -> byUserId.contains(item.getId())).collect(Collectors.toList());
// 取出角色名称
List<String> codes = collect.stream().map(RoleReqDTO::getCode).collect(Collectors.toList());
// 维修业务管理员--可以看所有数据但不能做操作
if (codes.contains(RepairRoleEnum.ADMIN.getCode())) {
return RepairRoleEnum.ADMIN.getName();
}
// 总检
if (codes.contains(RepairRoleEnum.INSPECTION.getCode())) {
return RepairRoleEnum.INSPECTION.getName();
}
// 服务顾问
if (codes.contains(RepairRoleEnum.ADVISOR.getCode())) {
return RepairRoleEnum.ADVISOR.getName();
}
// 维修工或班组长
if (codes.contains(RepairRoleEnum.REPAIR_STAFF.getCode())) {
return RepairRoleEnum.REPAIR_STAFF.getName();
}
// 维修仓库管理员
if (codes.contains(RepairRoleEnum.WAREHOUSE.getCode())) {
return RepairRoleEnum.WAREHOUSE.getName();
}
// 维修财务
if (codes.contains(RepairRoleEnum.WXCW.getCode())) {
return RepairRoleEnum.WXCW.getName();
}
// 啥也不是
return "";
}
} }

View File

@ -27,4 +27,8 @@ public class CompanyStaffRespVO extends CompanyStaff {
* 员工标签 * 员工标签
**/ **/
List<String> labelsArray; List<String> labelsArray;
/**
* 角色名称
**/
private String roleName;
} }

View File

@ -104,4 +104,15 @@
</if> </if>
order by cs.create_time desc order by cs.create_time desc
</select> </select>
<select id="selectMyAdviser" resultType="cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO">
SELECT
cs.*
FROM
base_customer_main bcm
LEFT JOIN company_staff cs ON bcm.inviter = cs.user_id AND cs.tenant_id = #{tenantId}
WHERE
bcm.user_id = #{userId}
AND bcm.tenant_id = #{tenantId}
LIMIT 1
</select>
</mapper> </mapper>