1
This commit is contained in:
parent
c4d996a265
commit
b03f5c4663
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.staff.controller.admin;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.iocoder.yudao.common.CommonErrorCodeConstants;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
@ -9,10 +10,14 @@ import cn.iocoder.yudao.framework.security.config.SecurityProperties;
|
|||||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.label.entity.Label;
|
import cn.iocoder.yudao.module.label.entity.Label;
|
||||||
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
|
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
|
||||||
|
import cn.iocoder.yudao.module.staff.service.ApiAppLoginService;
|
||||||
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
|
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
|
||||||
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 cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO;
|
||||||
|
import cn.iocoder.yudao.module.staff.vo.StaffLoginBody;
|
||||||
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
|
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
|
import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@ -21,6 +26,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -35,6 +41,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,6 +62,8 @@ public class CompanyStaffController {
|
|||||||
private SecurityProperties securityProperties;
|
private SecurityProperties securityProperties;
|
||||||
@Resource
|
@Resource
|
||||||
private AdminAuthService loginService;
|
private AdminAuthService loginService;
|
||||||
|
@Autowired
|
||||||
|
private ApiAppLoginService apiAppLoginService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
@ -295,4 +304,27 @@ public class CompanyStaffController {
|
|||||||
}
|
}
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工登录方法
|
||||||
|
* @author vinjor-M
|
||||||
|
* @date 15:17 2024/10/16
|
||||||
|
* @param loginBody 登录请求体
|
||||||
|
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult
|
||||||
|
**/
|
||||||
|
@PostMapping("/loginApp")
|
||||||
|
public CommonResult<?> loginApp(@RequestBody StaffLoginBody loginBody) throws Exception {
|
||||||
|
try {
|
||||||
|
AdminUserDO user = apiAppLoginService.loginApp(loginBody);
|
||||||
|
AuthLoginReqVO authLoginReqVO = new AuthLoginReqVO();
|
||||||
|
authLoginReqVO.setUsername(loginBody.getUsername());
|
||||||
|
authLoginReqVO.setPassword(loginBody.getPassword());
|
||||||
|
Map<String,Object> rtnMap = new HashMap<>();
|
||||||
|
rtnMap.put("userinfo",user);
|
||||||
|
rtnMap.put("loginResult",loginService.loginApp(authLoginReqVO,loginBody.getTenantId()));
|
||||||
|
return success(rtnMap);
|
||||||
|
}catch (Exception e){
|
||||||
|
return error(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.staff.controller.app;
|
package cn.iocoder.yudao.module.staff.controller.app;
|
||||||
|
|
||||||
import cn.iocoder.yudao.common.CommonErrorCodeConstants;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.module.staff.service.ApiAppLoginService;
|
import cn.iocoder.yudao.module.staff.service.ApiAppLoginService;
|
||||||
import cn.iocoder.yudao.module.staff.vo.StaffLoginBody;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
||||||
import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
|
|
||||||
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.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
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;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工APP端登录通用接口
|
* 员工APP端登录通用接口
|
||||||
* @author vinjor-M
|
* @author vinjor-M
|
||||||
@ -32,8 +19,6 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
public class ApiAppLoginController {
|
public class ApiAppLoginController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiAppLoginService apiAppLoginService;
|
private ApiAppLoginService apiAppLoginService;
|
||||||
@Resource
|
|
||||||
private AdminAuthService loginService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录获取验证码
|
* 登录获取验证码
|
||||||
@ -48,26 +33,5 @@ public class ApiAppLoginController {
|
|||||||
return apiAppLoginService.loginSmsCode(phone,sysCode);
|
return apiAppLoginService.loginSmsCode(phone,sysCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 员工登录方法
|
|
||||||
* @author vinjor-M
|
|
||||||
* @date 15:17 2024/10/16
|
|
||||||
* @param loginBody 登录请求体
|
|
||||||
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult
|
|
||||||
**/
|
|
||||||
@PostMapping("/loginApp")
|
|
||||||
public CommonResult<?> loginApp(@RequestBody StaffLoginBody loginBody) throws Exception {
|
|
||||||
try {
|
|
||||||
AdminUserDO user = apiAppLoginService.loginApp(loginBody);
|
|
||||||
AuthLoginReqVO authLoginReqVO = new AuthLoginReqVO();
|
|
||||||
authLoginReqVO.setUsername(loginBody.getUsername());
|
|
||||||
authLoginReqVO.setPassword(loginBody.getPassword());
|
|
||||||
Map<String,Object> rtnMap = new HashMap<>();
|
|
||||||
rtnMap.put("userinfo",user);
|
|
||||||
rtnMap.put("loginResult",loginService.login(authLoginReqVO));
|
|
||||||
return success(rtnMap);
|
|
||||||
}catch (Exception e){
|
|
||||||
return error(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -80,58 +80,58 @@ public class ApiAppLoginServiceImpl implements ApiAppLoginService {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public AdminUserDO loginApp(StaffLoginBody loginBody) {
|
public AdminUserDO loginApp(StaffLoginBody loginBody) {
|
||||||
String userName = loginBody.getUsername();
|
|
||||||
AdminUserDO user = new AdminUserDO();
|
AdminUserDO user = new AdminUserDO();
|
||||||
if(StringUtils.isNotEmpty(userName)){
|
String userName = loginBody.getUsername();
|
||||||
|
if (StringUtils.isNotEmpty(userName)) {
|
||||||
//手机号密码登录
|
//手机号密码登录
|
||||||
user = userService.getUserByUsername(userName);
|
user = userService.getUserByUsername(userName,loginBody.getTenantId());
|
||||||
if (ObjectUtil.isEmpty(user)) {
|
} else {
|
||||||
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
|
|
||||||
}
|
|
||||||
// 获取登录用户的角色信息
|
|
||||||
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId());
|
|
||||||
if (ObjectUtil.isEmpty(roleIdsByUserId) || roleIdsByUserId.size() == 0) {
|
|
||||||
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
|
|
||||||
}
|
|
||||||
List<RoleReqDTO> roleList = roleApi.getRoleList();
|
|
||||||
//所拥有的角色code集和
|
|
||||||
List<String> roleCodeList = new ArrayList<>();
|
|
||||||
//所拥有的角色名称集和
|
|
||||||
List<String> roleNames = new ArrayList<>();
|
|
||||||
for (RoleReqDTO item:roleList){
|
|
||||||
if(roleIdsByUserId.contains(item.getId())){
|
|
||||||
roleCodeList.add(item.getCode());
|
|
||||||
roleNames.add(item.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//默认无权限登录
|
|
||||||
boolean flag = false;
|
|
||||||
if(SystemEnum.REPAIR.getCode().equals(loginBody.getSysCode())){
|
|
||||||
//维修业务系统
|
|
||||||
flag = this.checkRepairCanLogin(user,roleCodeList);
|
|
||||||
}else if(SystemEnum.INSPECTION.getCode().equals(loginBody.getSysCode())){
|
|
||||||
//检测业务系统
|
|
||||||
|
|
||||||
}else if(SystemEnum.SCHOOL.getCode().equals(loginBody.getSysCode())){
|
|
||||||
//驾校业务系统
|
|
||||||
|
|
||||||
}else if(SystemEnum.RESCUE.getCode().equals(loginBody.getSysCode())){
|
|
||||||
//救援业务系统
|
|
||||||
flag = (loginBody.getType().equals("0") && roleNames.contains("调度中心")) || (loginBody.getType().equals("0") && roleNames.contains("交警大队"));
|
|
||||||
}else if(SystemEnum.INSURE.getCode().equals(loginBody.getSysCode())){
|
|
||||||
//保险业务系统
|
|
||||||
|
|
||||||
}else {
|
|
||||||
//错误的业务系统标识
|
|
||||||
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
|
|
||||||
}
|
|
||||||
// 角色是否可以登录
|
|
||||||
if (!flag) {
|
|
||||||
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
//验证码登录--TODO 先不管
|
//验证码登录--TODO 先不管
|
||||||
}
|
}
|
||||||
|
if (ObjectUtil.isEmpty(user)) {
|
||||||
|
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
|
||||||
|
}
|
||||||
|
// 获取登录用户的角色信息
|
||||||
|
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId());
|
||||||
|
if (ObjectUtil.isEmpty(roleIdsByUserId) || roleIdsByUserId.size() == 0) {
|
||||||
|
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
|
||||||
|
}
|
||||||
|
List<RoleReqDTO> roleList = roleApi.getRoleList();
|
||||||
|
//所拥有的角色code集和
|
||||||
|
List<String> roleCodeList = new ArrayList<>();
|
||||||
|
//所拥有的角色名称集和
|
||||||
|
List<String> roleNames = new ArrayList<>();
|
||||||
|
for (RoleReqDTO item : roleList) {
|
||||||
|
if (roleIdsByUserId.contains(item.getId())) {
|
||||||
|
roleCodeList.add(item.getCode());
|
||||||
|
roleNames.add(item.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//默认无权限登录
|
||||||
|
boolean flag = false;
|
||||||
|
if (SystemEnum.REPAIR.getCode().equals(loginBody.getSysCode())) {
|
||||||
|
//维修业务系统
|
||||||
|
flag = this.checkRepairCanLogin(user, roleCodeList);
|
||||||
|
} else if (SystemEnum.INSPECTION.getCode().equals(loginBody.getSysCode())) {
|
||||||
|
//检测业务系统
|
||||||
|
|
||||||
|
} else if (SystemEnum.SCHOOL.getCode().equals(loginBody.getSysCode())) {
|
||||||
|
//驾校业务系统
|
||||||
|
|
||||||
|
} else if (SystemEnum.RESCUE.getCode().equals(loginBody.getSysCode())) {
|
||||||
|
//救援业务系统
|
||||||
|
flag = (loginBody.getType().equals("0") && roleNames.contains("调度中心")) || (loginBody.getType().equals("0") && roleNames.contains("交警大队"));
|
||||||
|
} else if (SystemEnum.INSURE.getCode().equals(loginBody.getSysCode())) {
|
||||||
|
//保险业务系统
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//错误的业务系统标识
|
||||||
|
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
|
||||||
|
}
|
||||||
|
// 角色是否可以登录
|
||||||
|
if (!flag) {
|
||||||
|
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
|
||||||
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,4 +38,8 @@ public class StaffLoginBody {
|
|||||||
* 系统标识
|
* 系统标识
|
||||||
*/
|
*/
|
||||||
private String sysCode;
|
private String sysCode;
|
||||||
|
/**
|
||||||
|
* 租户id
|
||||||
|
*/
|
||||||
|
private Long tenantId;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.tickets.controller.admin;
|
|||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
|
||||||
import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService;
|
import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService;
|
||||||
import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemReqVO;
|
import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemReqVO;
|
||||||
import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemRespVO;
|
import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemRespVO;
|
||||||
@ -10,7 +11,9 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.ok;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,6 +73,20 @@ public class DlRepairTitemController {
|
|||||||
return success(dlRepairTitemService.updateRepairAndSale(dlRepairTitemReqVO));
|
return success(dlRepairTitemService.updateRepairAndSale(dlRepairTitemReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新工单子表,维修项目配件的单价、数量、折扣、单项总价等
|
||||||
|
* @author vinjor-M
|
||||||
|
* @date 16:10 2024/10/31
|
||||||
|
* @param itemList 工单子表列表
|
||||||
|
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
|
||||||
|
**/
|
||||||
|
@PutMapping("/updateRepairItem")
|
||||||
|
@Operation(summary = "修改维修工单子表的维修人员和销售人员信息")
|
||||||
|
public CommonResult<?> updateRepairItem(@RequestBody List<DlRepairTitem> itemList){
|
||||||
|
dlRepairTitemService.updateRepairItem(itemList);
|
||||||
|
return ok();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查看单个维修子表的数据
|
* 查看单个维修子表的数据
|
||||||
*
|
*
|
||||||
|
@ -67,4 +67,11 @@ public interface DlRepairTitemService extends IService<DlRepairTitem> {
|
|||||||
* @param id 工单子项ID
|
* @param id 工单子项ID
|
||||||
**/
|
**/
|
||||||
void removeItemById(String id);
|
void removeItemById(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新工单子表,维修项目配件的单价、数量、折扣、单项总价等
|
||||||
|
* @author vinjor-M
|
||||||
|
* @date 16:11 2024/10/31
|
||||||
|
**/
|
||||||
|
void updateRepairItem(List<DlRepairTitem> itemList);
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,20 @@ public class DlRepairTitemServiceImpl extends ServiceImpl<DlRepairTitemMapper, D
|
|||||||
// 更新主表
|
// 更新主表
|
||||||
repairTicketsService.computeTicket(titem.getTicketId());
|
repairTicketsService.computeTicket(titem.getTicketId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新工单子表,维修项目配件的单价、数量、折扣、单项总价等
|
||||||
|
*
|
||||||
|
* @param itemList
|
||||||
|
* @author vinjor-M
|
||||||
|
* @date 16:11 2024/10/31
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateRepairItem(List<DlRepairTitem> itemList) {
|
||||||
|
this.updateBatchById(itemList);
|
||||||
|
//重新计划工单价格
|
||||||
|
repairTicketsService.computeTicket(itemList.get(0).getTicketId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.dal.mysql.user;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.app.user.UserInfoVO;
|
import cn.iocoder.yudao.module.system.controller.app.user.UserInfoVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
@ -20,6 +21,9 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
|||||||
default AdminUserDO selectByUsername(String username) {
|
default AdminUserDO selectByUsername(String username) {
|
||||||
return selectOne(AdminUserDO::getUsername, username);
|
return selectOne(AdminUserDO::getUsername, username);
|
||||||
}
|
}
|
||||||
|
default AdminUserDO selectByUsername(String username,Long tenantId) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<AdminUserDO>().eq(AdminUserDO::getUsername, username).eq(TenantBaseDO::getTenantId,tenantId)).get(0);
|
||||||
|
}
|
||||||
|
|
||||||
default AdminUserDO selectByEmail(String email) {
|
default AdminUserDO selectByEmail(String email) {
|
||||||
return selectOne(AdminUserDO::getEmail, email);
|
return selectOne(AdminUserDO::getEmail, email);
|
||||||
|
@ -22,6 +22,14 @@ public interface AdminAuthService {
|
|||||||
* @return 用户
|
* @return 用户
|
||||||
*/
|
*/
|
||||||
AdminUserDO authenticate(String username, String password);
|
AdminUserDO authenticate(String username, String password);
|
||||||
|
/**
|
||||||
|
* 验证账号 + 密码。如果通过,则返回用户
|
||||||
|
*
|
||||||
|
* @param username 账号
|
||||||
|
* @param password 密码
|
||||||
|
* @return 用户
|
||||||
|
*/
|
||||||
|
AdminUserDO authenticateApp(String username, String password,Long tenantId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号登录
|
* 账号登录
|
||||||
@ -30,6 +38,13 @@ public interface AdminAuthService {
|
|||||||
* @return 登录结果
|
* @return 登录结果
|
||||||
*/
|
*/
|
||||||
AuthLoginRespVO login(@Valid AuthLoginReqVO reqVO);
|
AuthLoginRespVO login(@Valid AuthLoginReqVO reqVO);
|
||||||
|
/**
|
||||||
|
* 账号登录
|
||||||
|
*
|
||||||
|
* @param reqVO 登录信息
|
||||||
|
* @return 登录结果
|
||||||
|
*/
|
||||||
|
AuthLoginRespVO loginApp(@Valid AuthLoginReqVO reqVO,Long tenantId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基于 token 退出登录
|
* 基于 token 退出登录
|
||||||
|
@ -105,6 +105,26 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public AdminUserDO authenticateApp(String username, String password,Long tenantId) {
|
||||||
|
final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_USERNAME;
|
||||||
|
// 校验账号是否存在
|
||||||
|
AdminUserDO user = userService.getUserByUsername(username,tenantId);
|
||||||
|
if (user == null) {
|
||||||
|
createLoginLog(null, username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
|
||||||
|
throw exception(AUTH_LOGIN_BAD_CREDENTIALS);
|
||||||
|
}
|
||||||
|
if (!userService.isPasswordMatch(password, user.getPassword())) {
|
||||||
|
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
|
||||||
|
throw exception(AUTH_LOGIN_BAD_CREDENTIALS);
|
||||||
|
}
|
||||||
|
// 校验是否禁用
|
||||||
|
if (CommonStatusEnum.isDisable(user.getStatus())) {
|
||||||
|
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_DISABLED);
|
||||||
|
throw exception(AUTH_LOGIN_USER_DISABLED);
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthLoginRespVO login(AuthLoginReqVO reqVO) {
|
public AuthLoginRespVO login(AuthLoginReqVO reqVO) {
|
||||||
@ -122,6 +142,20 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
// 创建 Token 令牌,记录登录日志
|
// 创建 Token 令牌,记录登录日志
|
||||||
return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME);
|
return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public AuthLoginRespVO loginApp(AuthLoginReqVO reqVO,Long tenantId) {
|
||||||
|
// 校验验证码
|
||||||
|
validateCaptcha(reqVO);
|
||||||
|
// 使用账号密码,进行登录
|
||||||
|
AdminUserDO user = authenticateApp(reqVO.getUsername(), reqVO.getPassword(),tenantId);
|
||||||
|
// 如果 socialType 非空,说明需要绑定社交用户
|
||||||
|
if (reqVO.getSocialType() != null) {
|
||||||
|
socialUserService.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(),
|
||||||
|
reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState()));
|
||||||
|
}
|
||||||
|
// 创建 Token 令牌,记录登录日志
|
||||||
|
return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendSmsCode(AuthSmsSendReqVO reqVO) {
|
public void sendSmsCode(AuthSmsSendReqVO reqVO) {
|
||||||
|
@ -123,6 +123,13 @@ public interface AdminUserService extends IService<AdminUserDO> {
|
|||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
AdminUserDO getUserByUsername(String username);
|
AdminUserDO getUserByUsername(String username);
|
||||||
|
/**
|
||||||
|
* 通过用户名查询用户
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @return 用户对象信息
|
||||||
|
*/
|
||||||
|
AdminUserDO getUserByUsername(String username,Long tenantId);
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户---不带租户ID
|
* 通过用户名查询用户---不带租户ID
|
||||||
*
|
*
|
||||||
|
@ -282,6 +282,10 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
|||||||
public AdminUserDO getUserByUsername(String username) {
|
public AdminUserDO getUserByUsername(String username) {
|
||||||
return userMapper.selectByUsername(username);
|
return userMapper.selectByUsername(username);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public AdminUserDO getUserByUsername(String username,Long tenantId) {
|
||||||
|
return userMapper.selectByUsername(username,tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@TenantIgnore
|
@TenantIgnore
|
||||||
|
@ -239,6 +239,7 @@ yudao:
|
|||||||
- /admin-api/payApi/payNotify
|
- /admin-api/payApi/payNotify
|
||||||
- /repair/tickets/print/**
|
- /repair/tickets/print/**
|
||||||
- /admin-api/repair/tickets/print/**
|
- /admin-api/repair/tickets/print/**
|
||||||
|
- /admin-api/company/staff/loginApp
|
||||||
websocket:
|
websocket:
|
||||||
enable: true # websocket的开关
|
enable: true # websocket的开关
|
||||||
path: /infra/ws # 路径
|
path: /infra/ws # 路径
|
||||||
|
Loading…
Reference in New Issue
Block a user