Commit d2ed94b6 by wang_jiaxing

增加证件号码的登录

parent 90d2896e
...@@ -155,4 +155,30 @@ public class AuthController { ...@@ -155,4 +155,30 @@ public class AuthController {
return R.data(TokenUtil.createAuthInfo(userInfo)); return R.data(TokenUtil.createAuthInfo(userInfo));
} }
@PostMapping("login")
@ApiOperation(value = "登录")
@LogOper(czxxLbdm = "05", yymcJyqk = "0701", czxxJyqk = "登陆")
public R<AuthInfo> login(@ApiParam(value = "身份证号") @RequestParam(required = false) String zjhm) {
String userType = Func.toStr(WebUtil.getRequest().getHeader(TokenUtil.USER_TYPE_HEADER_KEY), TokenUtil.DEFAULT_USER_TYPE);
TokenParameter tokenParameter = new TokenParameter();
tokenParameter.getArgs().set("tenantId", "000000")
.set("zjhm", zjhm)
.set("grantType", "password")
.set("userType", userType);
ITokenGranter granter = TokenGranterBuilder.getGranter("password");
// UserInfo userInfo = granter.grant(tokenParameter);
UserInfoResult userInfo = granter.grant(tokenParameter);
if (userInfo == null || userInfo.getUser() == null) {
return R.fail(TokenUtil.USER_NOT_FOUND);
}
if (userInfo.getPermissions() == null || userInfo.getPermissions().size() == 0){
return R.fail(TokenUtil.USER_NOT_PERMISSIONS);
}
return R.data(TokenUtil.createAuthInfo(userInfo));
}
} }
...@@ -61,7 +61,7 @@ public class CaptchaTokenGranter implements ITokenGranter { ...@@ -61,7 +61,7 @@ public class CaptchaTokenGranter implements ITokenGranter {
// 获取用户类型 // 获取用户类型
String userType = tokenParameter.getArgs().getStr("userType"); String userType = tokenParameter.getArgs().getStr("userType");
// 根据不同用户类型调用对应的接口返回数据,用户可自行拓展 // 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
userInfo = userService.userInfoR(tenantId, account, DigestUtil.encrypt(password)); userInfo = userService.userInfoR(tenantId, account, DigestUtil.encrypt(password), null);
// if (userType.equals(BladeUserEnum.WEB.getName())) { // if (userType.equals(BladeUserEnum.WEB.getName())) {
// userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password)); // userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password));
......
...@@ -41,6 +41,7 @@ public class PasswordTokenGranter implements ITokenGranter { ...@@ -41,6 +41,7 @@ public class PasswordTokenGranter implements ITokenGranter {
String tenantId = tokenParameter.getArgs().getStr("tenantId"); String tenantId = tokenParameter.getArgs().getStr("tenantId");
String account = tokenParameter.getArgs().getStr("account"); String account = tokenParameter.getArgs().getStr("account");
String password = tokenParameter.getArgs().getStr("password"); String password = tokenParameter.getArgs().getStr("password");
String zjhm = tokenParameter.getArgs().getStr("zjhm");
UserInfoResult userInfo = null; UserInfoResult userInfo = null;
if (Func.isNoneBlank(account, password)) { if (Func.isNoneBlank(account, password)) {
// 获取用户类型 // 获取用户类型
...@@ -48,7 +49,7 @@ public class PasswordTokenGranter implements ITokenGranter { ...@@ -48,7 +49,7 @@ public class PasswordTokenGranter implements ITokenGranter {
// BASE64Encoder encoder = new BASE64Encoder(); // BASE64Encoder encoder = new BASE64Encoder();
// 根据不同用户类型调用对应的接口返回数据,用户可自行拓展 // 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
// userInfo = userService.userInfoR(tenantId, account, encoder.encode(password.getBytes())); // userInfo = userService.userInfoR(tenantId, account, encoder.encode(password.getBytes()));
userInfo = userService.userInfoR(tenantId, account, DigestUtil.encrypt(password)); userInfo = userService.userInfoR(tenantId, account, DigestUtil.encrypt(password), null);
// if (userType.equals(BladeUserEnum.WEB.getName())) { // if (userType.equals(BladeUserEnum.WEB.getName())) {
// userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password)); // userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password));
// } else if (userType.equals(BladeUserEnum.APP.getName())) { // } else if (userType.equals(BladeUserEnum.APP.getName())) {
...@@ -56,6 +57,8 @@ public class PasswordTokenGranter implements ITokenGranter { ...@@ -56,6 +57,8 @@ public class PasswordTokenGranter implements ITokenGranter {
// } else { // } else {
// userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password)); // userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password));
// } // }
} else if (Func.isNoneBlank(zjhm)) {
userInfo = userService.userInfoR(tenantId, account, DigestUtil.encrypt(password), zjhm);
} }
return userInfo; return userInfo;
} }
......
...@@ -84,4 +84,5 @@ public interface UserMapper extends BaseMapper<User> { ...@@ -84,4 +84,5 @@ public interface UserMapper extends BaseMapper<User> {
*/ */
List<UserExcel> exportUser(@Param("ew") Wrapper<User> queryWrapper); List<UserExcel> exportUser(@Param("ew") Wrapper<User> queryWrapper);
SysNewUser getUserNewByZjhm(String zjhm);
} }
...@@ -194,5 +194,51 @@ ...@@ -194,5 +194,51 @@
<select id="exportUser" resultType="org.springblade.modules.system.excel.UserExcel"> <select id="exportUser" resultType="org.springblade.modules.system.excel.UserExcel">
SELECT id, tenant_id, account, name, real_name, email, phone, birthday, role_id, dept_id, post_id FROM blade_user ${ew.customSqlSegment} SELECT id, tenant_id, account, name, real_name, email, phone, birthday, role_id, dept_id, post_id FROM blade_user ${ew.customSqlSegment}
</select> </select>
<select id="getUserNewByZjhm" resultType="org.springblade.modules.system.entity.SysNewUser">
SELECT
id as id,
unitcode as unitcode,
username as username,
password as password,
true_name as trueName,
open_flag as openFlag,
default_model as defaultModel,
remark as remark,
lrr as lrr,
lrsj as lrsj,
gxr as gxr,
gxsj as gxsj,
lrdwdm as lrdwdm,
lrdwmc as lrdwmc,
identitycard as identitycard,
sex as sex,
birthday as birthday,
telephone as telephone,
unitname as unitname,
scbz as scbz,
ip as ip,
grade as grade,
policemanid as policemanid,
default_desktop as defaultDesktop,
theme as theme,
lastlogintime as lastlogintime,
lastchecktime as lastchecktime,
xxzyurl as xxzyurl,
gzzm_zhy as gzzmZhy,
gzzm_ypy as gzzmYpy,
gzzm_zcy as gzzmZcy,
gzzm_play as gzzmPlay,
glybz as glybz,
tqyhbz as tqyhbz,
jgz_photo_zm as jgzPhotoZm,
jgz_photo_fm as jgzPhotoFm,
zbzx_dwdm as zbzxDwdm,
grdf as grdf
FROM sys_user
where open_flag='1' and scbz='0'
and identitycard = #{zjhm}
order by lrsj desc
limit 1
</select>
</mapper> </mapper>
...@@ -68,7 +68,7 @@ public interface IUserService extends BaseService<User> { ...@@ -68,7 +68,7 @@ public interface IUserService extends BaseService<User> {
* @return * @return
*/ */
UserInfo userInfo(String tenantId, String account, String password); UserInfo userInfo(String tenantId, String account, String password);
UserInfoResult userInfoR(String tenantId, String account, String password); UserInfoResult userInfoR(String tenantId, String account, String password, String zjhm);
/** /**
* 给用户设置角色 * 给用户设置角色
* *
......
...@@ -157,9 +157,14 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement ...@@ -157,9 +157,14 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
} }
@Override @Override
public UserInfoResult userInfoR(String tenantId, String account, String password) { public UserInfoResult userInfoR(String tenantId, String account, String password, String zjhm) {
UserInfoResult userInfo = new UserInfoResult(); UserInfoResult userInfo = new UserInfoResult();
SysNewUser userNew = baseMapper.getUserNew(account, password); SysNewUser userNew;
if (Func.isNoneBlank(zjhm)) {
userNew = baseMapper.getUserNewByZjhm(zjhm);
} else {
userNew = baseMapper.getUserNew(account, password);
}
// 查询对应的角色 // 查询对应的角色
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment