新增:getAdminsByPhone()方法
This commit is contained in:
@@ -23,6 +23,7 @@ import com.gxwebsoft.common.core.security.JwtSubject;
|
|||||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||||
|
import com.gxwebsoft.common.core.utils.JSONUtil;
|
||||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||||
import com.gxwebsoft.common.core.web.ApiResult;
|
import com.gxwebsoft.common.core.web.ApiResult;
|
||||||
import com.gxwebsoft.common.core.web.BaseController;
|
import com.gxwebsoft.common.core.web.BaseController;
|
||||||
@@ -54,7 +55,9 @@ import java.time.Instant;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录认证控制器
|
* 登录认证控制器
|
||||||
@@ -501,19 +504,27 @@ public class MainController extends BaseController {
|
|||||||
String message = "验证码不正确";
|
String message = "验证码不正确";
|
||||||
return fail(message, null);
|
return fail(message, null);
|
||||||
}
|
}
|
||||||
user = userService.getAdminByPhone(phone);
|
// 单用户登录
|
||||||
if(user == null){
|
final List<User> adminsByPhone = userService.getAdminsByPhone(param);
|
||||||
|
if(adminsByPhone.isEmpty()){
|
||||||
return fail("用户不存在",null);
|
return fail("用户不存在",null);
|
||||||
}
|
}
|
||||||
|
user = adminsByPhone.get(0);
|
||||||
// 签发token
|
// 签发token
|
||||||
String access_token = JwtUtil.buildToken(new JwtSubject(phone, user.getTenantId()),
|
String access_token = JwtUtil.buildToken(new JwtSubject(phone, user.getTenantId()),
|
||||||
tokenExpireTime, configProperties.getTokenKey());
|
tokenExpireTime, configProperties.getTokenKey());
|
||||||
|
// 同一个手机号码存在多个管理员账号
|
||||||
|
if(adminsByPhone.size() > 1){
|
||||||
|
String message = "请选择登录用户";
|
||||||
|
user.setHasAdminsByPhone(true);
|
||||||
|
return success(message, new LoginResult(access_token, user));
|
||||||
|
}
|
||||||
return success("登录成功", new LoginResult(access_token, user));
|
return success("登录成功", new LoginResult(access_token, user));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 普通用户登录
|
// 普通用户登录
|
||||||
if(tenantId == null){
|
if(tenantId == null){
|
||||||
return fail("TenantId不存在",null);
|
return fail("用户不存在",null);
|
||||||
}
|
}
|
||||||
if (!code.equals(redisUtil.get(key)) && !"789789".equals(code)) {
|
if (!code.equals(redisUtil.get(key)) && !"789789".equals(code)) {
|
||||||
String message = "验证码不正确";
|
String message = "验证码不正确";
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.gxwebsoft.common.core.security.JwtUtil;
|
|||||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||||
import com.gxwebsoft.common.core.web.*;
|
import com.gxwebsoft.common.core.web.*;
|
||||||
import com.gxwebsoft.common.system.entity.*;
|
import com.gxwebsoft.common.system.entity.*;
|
||||||
|
import com.gxwebsoft.common.system.param.LoginParam;
|
||||||
import com.gxwebsoft.common.system.param.UserImportParam;
|
import com.gxwebsoft.common.system.param.UserImportParam;
|
||||||
import com.gxwebsoft.common.system.param.UserParam;
|
import com.gxwebsoft.common.system.param.UserParam;
|
||||||
import com.gxwebsoft.common.system.result.LoginResult;
|
import com.gxwebsoft.common.system.result.LoginResult;
|
||||||
@@ -509,4 +510,10 @@ public class UserController extends BaseController {
|
|||||||
return success("统计成功", userService.orgNumInPark(param));
|
return success("统计成功", userService.orgNumInPark(param));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasAuthority('sys:auth:user')")
|
||||||
|
@ApiOperation("查询全部用户")
|
||||||
|
@GetMapping("/listAdminsByPhoneAll")
|
||||||
|
public ApiResult<List<User>> listAdminsByPhoneAll(LoginParam param){
|
||||||
|
return success(userService.getAdminsByPhone(param));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,6 +335,13 @@ public class User implements UserDetails {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Boolean hasParent;
|
private Boolean hasParent;
|
||||||
|
|
||||||
|
@ApiModelProperty("同一个手机号码存在多个管理员账号")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Boolean hasAdminsByPhone;
|
||||||
|
|
||||||
|
@ApiModelProperty("模板ID")
|
||||||
|
private Integer templateId;
|
||||||
|
|
||||||
// @ApiModelProperty("企业信息")
|
// @ApiModelProperty("企业信息")
|
||||||
// @TableField(exist = false)
|
// @TableField(exist = false)
|
||||||
// private Company companyInfo;
|
// private Company companyInfo;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.gxwebsoft.common.system.mapper;
|
package com.gxwebsoft.common.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
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.gxwebsoft.common.system.entity.User;
|
import com.gxwebsoft.common.system.entity.User;
|
||||||
@@ -58,4 +59,9 @@ public interface UserMapper extends BaseMapper<User> {
|
|||||||
|
|
||||||
@InterceptorIgnore(tenantLine = "true")
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
User selectByUserId(@Param("userId") Integer userId);
|
User selectByUserId(@Param("userId") Integer userId);
|
||||||
|
|
||||||
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
|
List<User> selectListAllRel(@Param("param") UserParam param);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,9 @@
|
|||||||
<if test="param.isAdmin != null">
|
<if test="param.isAdmin != null">
|
||||||
AND a.is_admin = #{param.isAdmin}
|
AND a.is_admin = #{param.isAdmin}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="param.templateId != null">
|
||||||
|
AND a.template_id = #{param.templateId}
|
||||||
|
</if>
|
||||||
<if test="param.isOrganizationAdmin != null">
|
<if test="param.isOrganizationAdmin != null">
|
||||||
AND a.is_organization_admin = #{param.isOrganizationAdmin}
|
AND a.is_organization_admin = #{param.isOrganizationAdmin}
|
||||||
</if>
|
</if>
|
||||||
@@ -170,6 +173,9 @@
|
|||||||
<if test="param.expertType != null">
|
<if test="param.expertType != null">
|
||||||
AND a.expert_type = #{param.expertType}
|
AND a.expert_type = #{param.expertType}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="param.tenantId != null">
|
||||||
|
AND a.tenant_id = #{param.tenantId}
|
||||||
|
</if>
|
||||||
<if test="param.keywords != null">
|
<if test="param.keywords != null">
|
||||||
AND (
|
AND (
|
||||||
a.username = #{param.keywords}
|
a.username = #{param.keywords}
|
||||||
@@ -212,12 +218,12 @@
|
|||||||
AND a.deleted = 0
|
AND a.deleted = 0
|
||||||
AND (a.username = #{username} OR a.phone = #{username} OR a.email = #{username})
|
AND (a.username = #{username} OR a.phone = #{username} OR a.email = #{username})
|
||||||
AND a.tenant_id = #{tenantId}
|
AND a.tenant_id = #{tenantId}
|
||||||
<!-- <if test="tenantId != null">-->
|
<!-- <if test="tenantId != null">-->
|
||||||
<!-- AND a.tenant_id = #{tenantId}-->
|
<!-- AND a.tenant_id = #{tenantId}-->
|
||||||
<!-- </if>-->
|
<!-- </if>-->
|
||||||
<!-- <if test="tenantId == null">-->
|
<!-- <if test="tenantId == null">-->
|
||||||
<!-- AND a.tenant_id = 1-->
|
<!-- AND a.tenant_id = 1-->
|
||||||
<!-- </if>-->
|
<!-- </if>-->
|
||||||
</where>
|
</where>
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
</select>
|
</select>
|
||||||
@@ -241,7 +247,10 @@
|
|||||||
|
|
||||||
<!-- 查询单条数据 -->
|
<!-- 查询单条数据 -->
|
||||||
<select id="getOne" resultType="com.gxwebsoft.common.system.entity.User">
|
<select id="getOne" resultType="com.gxwebsoft.common.system.entity.User">
|
||||||
SELECT * FROM sys_user WHERE user_id = #{param.userId} and deleted = 0
|
SELECT *
|
||||||
|
FROM sys_user
|
||||||
|
WHERE user_id = #{param.userId}
|
||||||
|
and deleted = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询统计数据 -->
|
<!-- 查询统计数据 -->
|
||||||
@@ -259,11 +268,15 @@
|
|||||||
|
|
||||||
<!-- 更新用户信息 -->
|
<!-- 更新用户信息 -->
|
||||||
<update id="updateByUserId">
|
<update id="updateByUserId">
|
||||||
UPDATE sys_user SET grade_id = #{param.gradeId} WHERE user_id = #{param.userId}
|
UPDATE sys_user
|
||||||
|
SET grade_id = #{param.gradeId}
|
||||||
|
WHERE user_id = #{param.userId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="selectByUserId" resultType="com.gxwebsoft.common.system.entity.User">
|
<select id="selectByUserId" resultType="com.gxwebsoft.common.system.entity.User">
|
||||||
SELECT * FROM sys_user WHERE user_id = #{userId}
|
SELECT *
|
||||||
|
FROM sys_user
|
||||||
|
WHERE user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 根据手机号码查询 -->
|
<!-- 根据手机号码查询 -->
|
||||||
@@ -273,8 +286,13 @@
|
|||||||
<where>
|
<where>
|
||||||
AND a.deleted = 0
|
AND a.deleted = 0
|
||||||
AND a.phone = #{phone}
|
AND a.phone = #{phone}
|
||||||
AND (a.username = 'superAdmin' OR a.username = 'admin')
|
AND (a.username = 'superAdmin' OR a.username = 'admin' OR a.is_admin = 1)
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectListAllRel" resultType="com.gxwebsoft.common.system.entity.User">
|
||||||
|
<include refid="selectSql"></include>
|
||||||
|
LIMIT 50
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -232,6 +232,9 @@ public class UserParam extends BaseParam {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Date settlementTime;
|
private Date settlementTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("模板id")
|
||||||
|
private Integer templateId;
|
||||||
|
|
||||||
@ApiModelProperty("报餐时间")
|
@ApiModelProperty("报餐时间")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String deliveryTime;
|
private String deliveryTime;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gxwebsoft.common.system.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.gxwebsoft.common.core.web.PageResult;
|
import com.gxwebsoft.common.core.web.PageResult;
|
||||||
import com.gxwebsoft.common.system.entity.User;
|
import com.gxwebsoft.common.system.entity.User;
|
||||||
|
import com.gxwebsoft.common.system.param.LoginParam;
|
||||||
import com.gxwebsoft.common.system.param.UserParam;
|
import com.gxwebsoft.common.system.param.UserParam;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
|
|
||||||
@@ -116,4 +117,6 @@ public interface UserService extends IService<User>, UserDetailsService {
|
|||||||
Integer userNumInPark(UserParam param);
|
Integer userNumInPark(UserParam param);
|
||||||
|
|
||||||
Integer orgNumInPark(UserParam param);
|
Integer orgNumInPark(UserParam param);
|
||||||
|
|
||||||
|
List<User> getAdminsByPhone(LoginParam param);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.gxwebsoft.common.core.web.PageParam;
|
|||||||
import com.gxwebsoft.common.core.web.PageResult;
|
import com.gxwebsoft.common.core.web.PageResult;
|
||||||
import com.gxwebsoft.common.system.entity.*;
|
import com.gxwebsoft.common.system.entity.*;
|
||||||
import com.gxwebsoft.common.system.mapper.UserMapper;
|
import com.gxwebsoft.common.system.mapper.UserMapper;
|
||||||
|
import com.gxwebsoft.common.system.param.LoginParam;
|
||||||
import com.gxwebsoft.common.system.param.UserParam;
|
import com.gxwebsoft.common.system.param.UserParam;
|
||||||
import com.gxwebsoft.common.system.service.*;
|
import com.gxwebsoft.common.system.service.*;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
@@ -277,6 +278,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||||||
return baseMapper.selectAdminByPhone(phone);
|
return baseMapper.selectAdminByPhone(phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<User> getAdminsByPhone(LoginParam param){
|
||||||
|
final UserParam userParam = new UserParam();
|
||||||
|
userParam.setPhone(param.getPhone());
|
||||||
|
userParam.setIsAdmin(true);
|
||||||
|
userParam.setTenantId(param.getTenantId());
|
||||||
|
userParam.setLimit(50L);
|
||||||
|
return baseMapper.selectListAllRel(userParam);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量查询用户的角色
|
* 批量查询用户的角色
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user