|
|
|
@ -13,6 +13,7 @@ import com.ibeetl.admin.core.rbac.UserLoginInfo;
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import com.ibeetl.admin.core.util.enums.DelFlagEnum;
|
|
|
|
|
import com.ibeetl.admin.core.util.enums.GeneralStateEnum;
|
|
|
|
|
import com.ibeetl.admin.core.web.query.CustomFilterByLcUser;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.beetl.sql.core.SQLManager;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -34,237 +35,239 @@ import static com.ibeetl.admin.core.util.enums.GeneralStateEnum.ENABLE;
|
|
|
|
|
@Transactional
|
|
|
|
|
@Validated
|
|
|
|
|
public class CoreUserService extends CoreBaseService<CoreUser> {
|
|
|
|
|
@Autowired
|
|
|
|
|
CoreUserDao coreUserDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
CoreOrgDao orgDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
PasswordEncryptService passwordEncryptService;
|
|
|
|
|
|
|
|
|
|
@Autowired SQLManager sqlManager;
|
|
|
|
|
|
|
|
|
|
public UserLoginInfo login(String userName,String password){
|
|
|
|
|
CoreUser query = new CoreUser();
|
|
|
|
|
query.setCode(userName);
|
|
|
|
|
query.setPassword(passwordEncryptService.password(password));
|
|
|
|
|
query.setState(ENABLE.getValue());
|
|
|
|
|
CoreUser user = coreUserDao.createLambdaQuery().andEq(CoreUser::getCode,userName).
|
|
|
|
|
andEq(CoreUser::getPassword, passwordEncryptService.password(password))
|
|
|
|
|
.andEq(CoreUser::getState, ENABLE.getValue()).single();
|
|
|
|
|
if(user==null) {
|
|
|
|
|
throw new PlatformException("用户"+userName+"不存在或者密码错误");
|
|
|
|
|
}
|
|
|
|
|
if(!user.getState().equals(ENABLE.getValue())){
|
|
|
|
|
throw new PlatformException("用户"+userName+"已经失效");
|
|
|
|
|
}
|
|
|
|
|
if(user.getDelFlag()==DelFlagEnum.DELETED.getValue()) {
|
|
|
|
|
throw new PlatformException("用户"+userName+"已经删除");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<CoreOrg> orgs = getUserOrg(user.getId(),user.getOrgId());
|
|
|
|
|
UserLoginInfo loginInfo = new UserLoginInfo();
|
|
|
|
|
loginInfo.setOrgs(orgs);
|
|
|
|
|
loginInfo.setUser(user);
|
|
|
|
|
return loginInfo;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增用户 (指定身份,不会增加权限)
|
|
|
|
|
*
|
|
|
|
|
* 创建用户,并增加权限
|
|
|
|
|
* {@link com.ibeetl.jlw.service.WebPlatformService#createUser}
|
|
|
|
|
*
|
|
|
|
|
* @param userCode 用户Code
|
|
|
|
|
* @param password 登录密码(明文传入) 为空时候,默认为123qwe
|
|
|
|
|
* @param orgId 组织ID
|
|
|
|
|
* @param jobType0 岗位
|
|
|
|
|
* @param jobType1 岗位子类型
|
|
|
|
|
*/
|
|
|
|
|
public Long createUserBySomeParams(String userCode, String password, Long orgId, MenuEnums jobType0, MenuEnums jobType1 ) {
|
|
|
|
|
Assert.notEmpty(userCode, "用户编号不能为空!");
|
|
|
|
|
Assert.notNull(orgId, "机构ID不能为空!");
|
|
|
|
|
Assert.notNull(jobType0, "岗位不能为空!");
|
|
|
|
|
Assert.notNull(jobType1, "岗位子类型不能为空!");
|
|
|
|
|
@Autowired
|
|
|
|
|
CoreUserDao coreUserDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
CoreOrgDao orgDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
PasswordEncryptService passwordEncryptService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
SQLManager sqlManager;
|
|
|
|
|
|
|
|
|
|
public UserLoginInfo login(String userName, String password) {
|
|
|
|
|
CoreUser query = new CoreUser();
|
|
|
|
|
query.setCode(userName);
|
|
|
|
|
query.setPassword(passwordEncryptService.password(password));
|
|
|
|
|
query.setState(ENABLE.getValue());
|
|
|
|
|
CoreUser user = coreUserDao.createLambdaQuery().andEq(CoreUser::getCode, userName).
|
|
|
|
|
andEq(CoreUser::getPassword, passwordEncryptService.password(password))
|
|
|
|
|
.andEq(CoreUser::getState, ENABLE.getValue()).single();
|
|
|
|
|
if (user == null) {
|
|
|
|
|
throw new PlatformException("用户" + userName + "不存在或者密码错误");
|
|
|
|
|
}
|
|
|
|
|
if (!user.getState().equals(ENABLE.getValue())) {
|
|
|
|
|
throw new PlatformException("用户" + userName + "已经失效");
|
|
|
|
|
}
|
|
|
|
|
if (user.getDelFlag() == DelFlagEnum.DELETED.getValue()) {
|
|
|
|
|
throw new PlatformException("用户" + userName + "已经删除");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<CoreOrg> orgs = getUserOrg(user.getId(), user.getOrgId());
|
|
|
|
|
UserLoginInfo loginInfo = new UserLoginInfo();
|
|
|
|
|
loginInfo.setOrgs(orgs);
|
|
|
|
|
loginInfo.setUser(user);
|
|
|
|
|
return loginInfo;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增用户 (指定身份,不会增加权限)
|
|
|
|
|
* <p>
|
|
|
|
|
* 创建用户,并增加权限
|
|
|
|
|
* {@link com.ibeetl.jlw.service.WebPlatformService#createUser}
|
|
|
|
|
*
|
|
|
|
|
* @param userCode 用户Code
|
|
|
|
|
* @param password 登录密码(明文传入) 为空时候,默认为123qwe
|
|
|
|
|
* @param orgId 组织ID
|
|
|
|
|
* @param jobType0 岗位
|
|
|
|
|
* @param jobType1 岗位子类型
|
|
|
|
|
*/
|
|
|
|
|
public Long createUserBySomeParams(String userCode, String password, Long orgId, MenuEnums jobType0, MenuEnums jobType1) {
|
|
|
|
|
Assert.notEmpty(userCode, "用户编号不能为空!");
|
|
|
|
|
Assert.notNull(orgId, "机构ID不能为空!");
|
|
|
|
|
Assert.notNull(jobType0, "岗位不能为空!");
|
|
|
|
|
Assert.notNull(jobType1, "岗位子类型不能为空!");
|
|
|
|
|
|
|
|
|
|
// Boolean length = userCode.length() <= 16;
|
|
|
|
|
// Assert.isTrue(length, "输入内容:"+userCode+ " 超过16个字符!");
|
|
|
|
|
|
|
|
|
|
// 判断用户Code唯一
|
|
|
|
|
Boolean isNotExist = coreUserDao.createLambdaQuery().andEq(CoreUser::getCode,userCode).count() == 0;
|
|
|
|
|
Assert.isTrue(isNotExist, "用户名重复!");
|
|
|
|
|
|
|
|
|
|
CoreUser user = new CoreUser();
|
|
|
|
|
user.setName(userCode);
|
|
|
|
|
user.setCode(userCode);
|
|
|
|
|
user.setPassword(defaultIfBlank(passwordEncryptService.password(password), "123qwe"));
|
|
|
|
|
user.setState(ENABLE.getValue());
|
|
|
|
|
user.setCreateTime(new Date());
|
|
|
|
|
user.setDelFlag(0);
|
|
|
|
|
user.setJobType0(jobType0.name());
|
|
|
|
|
user.setJobType1(jobType1.name());
|
|
|
|
|
user.setOrgId(orgId);
|
|
|
|
|
|
|
|
|
|
coreUserDao.insert(user);
|
|
|
|
|
CoreUser c = new CoreUser();
|
|
|
|
|
c.setId(user.getId());
|
|
|
|
|
c.setOldId(50000+user.getId());
|
|
|
|
|
coreUserDao.updateTemplateById(c);
|
|
|
|
|
return user.getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Long createUserBySomeParams(String userCode, String password, Long orgId, MenuEnums jobType0, MenuEnums jobType1,Long oldId ) {
|
|
|
|
|
Assert.notEmpty(userCode, "用户编号不能为空!");
|
|
|
|
|
Assert.notNull(orgId, "机构ID不能为空!");
|
|
|
|
|
Assert.notNull(jobType0, "岗位不能为空!");
|
|
|
|
|
Assert.notNull(jobType1, "岗位子类型不能为空!");
|
|
|
|
|
// 判断用户Code唯一
|
|
|
|
|
Boolean isNotExist = coreUserDao.createLambdaQuery().andEq(CoreUser::getCode, userCode).count() == 0;
|
|
|
|
|
Assert.isTrue(isNotExist, "用户名重复!");
|
|
|
|
|
|
|
|
|
|
CoreUser user = new CoreUser();
|
|
|
|
|
user.setName(userCode);
|
|
|
|
|
user.setCode(userCode);
|
|
|
|
|
user.setPassword(defaultIfBlank(passwordEncryptService.password(password), "123qwe"));
|
|
|
|
|
user.setState(ENABLE.getValue());
|
|
|
|
|
user.setCreateTime(new Date());
|
|
|
|
|
user.setDelFlag(0);
|
|
|
|
|
user.setJobType0(jobType0.name());
|
|
|
|
|
user.setJobType1(jobType1.name());
|
|
|
|
|
user.setOrgId(orgId);
|
|
|
|
|
|
|
|
|
|
coreUserDao.insert(user);
|
|
|
|
|
CoreUser c = new CoreUser();
|
|
|
|
|
c.setId(user.getId());
|
|
|
|
|
c.setOldId(50000 + user.getId());
|
|
|
|
|
coreUserDao.updateTemplateById(c);
|
|
|
|
|
return user.getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Long createUserBySomeParams(String userCode, String password, Long orgId, MenuEnums jobType0, MenuEnums jobType1, Long oldId) {
|
|
|
|
|
Assert.notEmpty(userCode, "用户编号不能为空!");
|
|
|
|
|
Assert.notNull(orgId, "机构ID不能为空!");
|
|
|
|
|
Assert.notNull(jobType0, "岗位不能为空!");
|
|
|
|
|
Assert.notNull(jobType1, "岗位子类型不能为空!");
|
|
|
|
|
|
|
|
|
|
// Boolean length = userCode.length() <= 16;
|
|
|
|
|
// Assert.isTrue(length, "输入内容:"+userCode+ " 超过16个字符!");
|
|
|
|
|
|
|
|
|
|
// 判断用户Code唯一
|
|
|
|
|
Boolean isNotExist = coreUserDao.createLambdaQuery().andEq(CoreUser::getCode,userCode).count() == 0;
|
|
|
|
|
Assert.isTrue(isNotExist, "用户名重复!");
|
|
|
|
|
|
|
|
|
|
CoreUser user = new CoreUser();
|
|
|
|
|
user.setName(userCode);
|
|
|
|
|
user.setCode(userCode);
|
|
|
|
|
user.setPassword(defaultIfBlank(passwordEncryptService.password(password), "123qwe"));
|
|
|
|
|
user.setState(ENABLE.getValue());
|
|
|
|
|
user.setCreateTime(new Date());
|
|
|
|
|
user.setDelFlag(0);
|
|
|
|
|
user.setJobType0(jobType0.name());
|
|
|
|
|
user.setJobType1(jobType1.name());
|
|
|
|
|
user.setOrgId(orgId);
|
|
|
|
|
// 判断用户Code唯一
|
|
|
|
|
Boolean isNotExist = coreUserDao.createLambdaQuery().andEq(CoreUser::getCode, userCode).count() == 0;
|
|
|
|
|
Assert.isTrue(isNotExist, "用户名重复!");
|
|
|
|
|
|
|
|
|
|
CoreUser user = new CoreUser();
|
|
|
|
|
user.setName(userCode);
|
|
|
|
|
user.setCode(userCode);
|
|
|
|
|
user.setPassword(defaultIfBlank(passwordEncryptService.password(password), "123qwe"));
|
|
|
|
|
user.setState(ENABLE.getValue());
|
|
|
|
|
user.setCreateTime(new Date());
|
|
|
|
|
user.setDelFlag(0);
|
|
|
|
|
user.setJobType0(jobType0.name());
|
|
|
|
|
user.setJobType1(jobType1.name());
|
|
|
|
|
user.setOrgId(orgId);
|
|
|
|
|
user.setOldId(oldId);
|
|
|
|
|
coreUserDao.insert(user);
|
|
|
|
|
CoreUser c = new CoreUser();
|
|
|
|
|
c.setId(user.getId());
|
|
|
|
|
coreUserDao.updateTemplateById(c);
|
|
|
|
|
return user.getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<CoreOrg> getUserOrg(long userId,long orgId){
|
|
|
|
|
List<CoreOrg> orgs = orgDao.queryOrgByUser(userId);
|
|
|
|
|
if(orgs.isEmpty()){
|
|
|
|
|
//没有赋值任何角色,默认给一个所在部门
|
|
|
|
|
CoreOrg userOrg = orgDao.unique(orgId);
|
|
|
|
|
orgs.add(userOrg);
|
|
|
|
|
}
|
|
|
|
|
return orgs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<CoreUser> getAllUsersByRole(String role){
|
|
|
|
|
return coreUserDao.getUserByRole(role);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreUser getUserByCode(String userName){
|
|
|
|
|
CoreUser user = new CoreUser();
|
|
|
|
|
user.setCode(userName);
|
|
|
|
|
return coreUserDao.templateOne(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateTemplateById(CoreUser user){
|
|
|
|
|
coreUserDao.updateTemplateById(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreOrg getOrgById(Long orgId){
|
|
|
|
|
return orgDao.unique(orgId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreUser getUserById(Long userId){
|
|
|
|
|
return coreUserDao.unique(userId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getOrgCode(List<Long> orgIds){
|
|
|
|
|
return orgDao.queryAllOrgCode(orgIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<CoreUser> getCoreUserList(CoreUser coreUser){
|
|
|
|
|
return coreUserDao.template(coreUser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<CoreUser> getCoreUserListAndOldIdIsNull(){
|
|
|
|
|
return coreUserDao.getCoreUserListAndOldIdIsNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreUser findByOldId(Long oldId){
|
|
|
|
|
return coreUserDao.getCoreUserByOldId(oldId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Boolean verifyPwd(@NotBlank(message = "待验证的密码不能为空!") String pwd, @NotNull(message = "用户ID不能为空!") Long userId) {
|
|
|
|
|
CoreUser user = new CoreUser();
|
|
|
|
|
user.setId(userId);
|
|
|
|
|
user.setState(GeneralStateEnum.ENABLE.getValue());
|
|
|
|
|
user.setDelFlag(DelFlagEnum.NORMAL.getValue());
|
|
|
|
|
CoreUser coreUser = coreUserDao.templateOne(user);
|
|
|
|
|
return coreUser.getPassword().equals(passwordEncryptService.password(pwd));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Boolean editPwdByOld(@NotBlank(message = "旧密码不能为空!") String oldPwd,
|
|
|
|
|
@NotBlank(message = "新密码不能为空!") String newPwd,
|
|
|
|
|
@NotNull(message = "用户ID不能为空!") Long userId) {
|
|
|
|
|
Assert.isTrue(verifyPwd(oldPwd, userId), "旧密码验证失败!");
|
|
|
|
|
CoreUser entity = new CoreUser();
|
|
|
|
|
entity.setId(userId);
|
|
|
|
|
entity.setPassword(newPwd);
|
|
|
|
|
return coreUserDao.updateTemplateById(entity) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证-不需要验证旧密码
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Boolean editPwdByOldNotVerify(@NotBlank(message = "新密码不能为空!") String newPwd,
|
|
|
|
|
@NotNull(message = "用户ID不能为空!") Long userId) {
|
|
|
|
|
CoreUser entity = new CoreUser();
|
|
|
|
|
entity.setId(userId);
|
|
|
|
|
entity.setPassword(newPwd);
|
|
|
|
|
return coreUserDao.updateTemplateById(entity) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据用户ID更新用户登录的信息
|
|
|
|
|
* 记录,用户信息
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Boolean recordLoginInformation(Long userId,String lastLoginTime) {
|
|
|
|
|
CoreUser cacheUser = coreUserDao.single(userId);
|
|
|
|
|
if (cacheUser == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Long newLoginCount = defaultIfNull(cacheUser.getLoginCount(), 0L) + 1L;
|
|
|
|
|
|
|
|
|
|
CoreUser entity = new CoreUser();
|
|
|
|
|
entity.setId(userId);
|
|
|
|
|
entity.setLoginCount(newLoginCount);
|
|
|
|
|
entity.setLastLoginTime(StringUtils.isEmpty(lastLoginTime) ? null : DateUtil.round(new Date(Long.parseLong(lastLoginTime)),DateField.SECOND));
|
|
|
|
|
return coreUserDao.updateTemplateById(entity) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据身份标识,尝试获取该身份对应的ID
|
|
|
|
|
* @param coreUser
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
coreUserDao.insert(user);
|
|
|
|
|
CoreUser c = new CoreUser();
|
|
|
|
|
c.setId(user.getId());
|
|
|
|
|
coreUserDao.updateTemplateById(c);
|
|
|
|
|
return user.getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<CoreOrg> getUserOrg(long userId, long orgId) {
|
|
|
|
|
List<CoreOrg> orgs = orgDao.queryOrgByUser(userId);
|
|
|
|
|
if (orgs.isEmpty()) {
|
|
|
|
|
//没有赋值任何角色,默认给一个所在部门
|
|
|
|
|
CoreOrg userOrg = orgDao.unique(orgId);
|
|
|
|
|
orgs.add(userOrg);
|
|
|
|
|
}
|
|
|
|
|
return orgs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<CoreUser> getAllUsersByRole(String role) {
|
|
|
|
|
return coreUserDao.getUserByRole(role);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreUser getUserByCode(String userName) {
|
|
|
|
|
CoreUser user = new CoreUser();
|
|
|
|
|
user.setCode(userName);
|
|
|
|
|
return coreUserDao.templateOne(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateTemplateById(CoreUser user) {
|
|
|
|
|
coreUserDao.updateTemplateById(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreOrg getOrgById(Long orgId) {
|
|
|
|
|
return orgDao.unique(orgId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreUser getUserById(Long userId) {
|
|
|
|
|
return coreUserDao.unique(userId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getOrgCode(List<Long> orgIds) {
|
|
|
|
|
return orgDao.queryAllOrgCode(orgIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<CoreUser> getCoreUserList(CoreUser coreUser) {
|
|
|
|
|
return coreUserDao.template(coreUser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<CoreUser> getCoreUserListAndOldIdIsNull() {
|
|
|
|
|
return coreUserDao.getCoreUserListAndOldIdIsNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreUser findByOldId(Long oldId) {
|
|
|
|
|
return coreUserDao.getCoreUserByOldId(oldId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Boolean verifyPwd(@NotBlank(message = "待验证的密码不能为空!") String pwd, @NotNull(message = "用户ID不能为空!") Long userId) {
|
|
|
|
|
CoreUser user = new CoreUser();
|
|
|
|
|
user.setId(userId);
|
|
|
|
|
user.setState(GeneralStateEnum.ENABLE.getValue());
|
|
|
|
|
user.setDelFlag(DelFlagEnum.NORMAL.getValue());
|
|
|
|
|
CoreUser coreUser = coreUserDao.templateOne(user);
|
|
|
|
|
return coreUser.getPassword().equals(passwordEncryptService.password(pwd));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Boolean editPwdByOld(@NotBlank(message = "旧密码不能为空!") String oldPwd,
|
|
|
|
|
@NotBlank(message = "新密码不能为空!") String newPwd,
|
|
|
|
|
@NotNull(message = "用户ID不能为空!") Long userId) {
|
|
|
|
|
Assert.isTrue(verifyPwd(oldPwd, userId), "旧密码验证失败!");
|
|
|
|
|
CoreUser entity = new CoreUser();
|
|
|
|
|
entity.setId(userId);
|
|
|
|
|
entity.setPassword(newPwd);
|
|
|
|
|
return coreUserDao.updateTemplateById(entity) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证-不需要验证旧密码
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Boolean editPwdByOldNotVerify(@NotBlank(message = "新密码不能为空!") String newPwd,
|
|
|
|
|
@NotNull(message = "用户ID不能为空!") Long userId) {
|
|
|
|
|
CoreUser entity = new CoreUser();
|
|
|
|
|
entity.setId(userId);
|
|
|
|
|
entity.setPassword(newPwd);
|
|
|
|
|
return coreUserDao.updateTemplateById(entity) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据用户ID更新用户登录的信息
|
|
|
|
|
* 记录,用户信息
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Boolean recordLoginInformation(Long userId, String lastLoginTime) {
|
|
|
|
|
CoreUser cacheUser = coreUserDao.single(userId);
|
|
|
|
|
if (cacheUser == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Long newLoginCount = defaultIfNull(cacheUser.getLoginCount(), 0L) + 1L;
|
|
|
|
|
|
|
|
|
|
CoreUser entity = new CoreUser();
|
|
|
|
|
entity.setId(userId);
|
|
|
|
|
entity.setLoginCount(newLoginCount);
|
|
|
|
|
entity.setLastLoginTime(StringUtils.isEmpty(lastLoginTime) ? null : DateUtil.round(new Date(Long.parseLong(lastLoginTime)), DateField.SECOND));
|
|
|
|
|
return coreUserDao.updateTemplateById(entity) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据身份标识,尝试获取该身份对应的ID
|
|
|
|
|
* @param coreUser
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
// public Long tryToGetIdByIdentity(CoreUser coreUser, Consumer<Long> consumer) throws ClassNotFoundException {
|
|
|
|
|
// Long id = null;
|
|
|
|
|
// // 如果是超管
|
|
|
|
@ -295,41 +298,105 @@ public class CoreUserService extends CoreBaseService<CoreUser> {
|
|
|
|
|
// consumer.accept(id);
|
|
|
|
|
// return id;
|
|
|
|
|
// }
|
|
|
|
|
/**
|
|
|
|
|
* 根据用户名和密码查询用户,用于子系统登录
|
|
|
|
|
*/
|
|
|
|
|
public Map<String,Object> getUserByUsernameAndPwd(String username,String password){
|
|
|
|
|
return coreUserDao.getUserByUsernameAndPwd(username,password);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> getTeacherByNo(String username){
|
|
|
|
|
return coreUserDao.getTeacherByNo(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> getStudentByNo(String username){
|
|
|
|
|
return coreUserDao.getStudentByNo(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> getStudentByNoOfNet(String username){
|
|
|
|
|
return coreUserDao.getStudentByNoOfNet(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> getTeacherByNoOfNet(String username){
|
|
|
|
|
return coreUserDao.getTeacherByNoOfNet(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> getAdminByNo(String username){return coreUserDao.getAdminByNo(username);}
|
|
|
|
|
public void updateUserId(Long newId,Long oldId){
|
|
|
|
|
coreUserDao.updateUserId(newId, oldId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreUser findByUsername(String username){
|
|
|
|
|
return coreUserDao.findByUsername(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Map<String,Object>> findAllUser(){
|
|
|
|
|
return coreUserDao.findAllUser();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据用户名和密码查询用户,用于子系统登录
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Object> getUserByUsernameAndPwd(String username, String password) {
|
|
|
|
|
return coreUserDao.getUserByUsernameAndPwd(username, password);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> getTeacherByNo(String username) {
|
|
|
|
|
return coreUserDao.getTeacherByNo(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> getStudentByNo(String username) {
|
|
|
|
|
return coreUserDao.getStudentByNo(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> getStudentByNoOfNet(String username) {
|
|
|
|
|
return coreUserDao.getStudentByNoOfNet(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> getTeacherByNoOfNet(String username) {
|
|
|
|
|
return coreUserDao.getTeacherByNoOfNet(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> getAdminByNo(String username) {
|
|
|
|
|
return coreUserDao.getAdminByNo(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateUserId(Long newId, Long oldId) {
|
|
|
|
|
coreUserDao.updateUserId(newId, oldId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreUser findByUsername(String username) {
|
|
|
|
|
return coreUserDao.findByUsername(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> findAllUser() {
|
|
|
|
|
return coreUserDao.findAllUser();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getUsersByLC(CustomFilterByLcUser customFilter, int page, int size) {
|
|
|
|
|
|
|
|
|
|
Integer page1 = size;
|
|
|
|
|
if (page <= 0) {
|
|
|
|
|
page = 1;
|
|
|
|
|
}
|
|
|
|
|
Integer page2 = (page - 1) * size;
|
|
|
|
|
|
|
|
|
|
String role = null;
|
|
|
|
|
if (customFilter.getTypeId() != null) {
|
|
|
|
|
role = customFilter.getTypeId() == 3 ? "js" : "xs";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
if (customFilter.getIdList() != null && customFilter.getIdList().size() > 0) {
|
|
|
|
|
for (int i = 0; i < customFilter.getIdList().size(); i++) {
|
|
|
|
|
sb.append(customFilter.getIdList().get(i));
|
|
|
|
|
if (i < customFilter.getIdList().size() - 1) {
|
|
|
|
|
sb.append(",");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String ids = null;
|
|
|
|
|
if (sb != null) {
|
|
|
|
|
ids = sb.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return coreUserDao.getUsersByLC(customFilter.getId(),ids, role, customFilter.getKeyword()
|
|
|
|
|
, customFilter.getKeyword2(), page1, page2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> accountDalGetList(CustomFilterByLcUser customFilter) {
|
|
|
|
|
String role = null;
|
|
|
|
|
if (customFilter.getTypeId() != null) {
|
|
|
|
|
role = customFilter.getTypeId() == 3 ? "js" : "xs";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
if (customFilter.getIdList() != null && customFilter.getIdList().size() > 0) {
|
|
|
|
|
for (int i = 0; i < customFilter.getIdList().size(); i++) {
|
|
|
|
|
sb.append(customFilter.getIdList().get(i));
|
|
|
|
|
if (i < customFilter.getIdList().size() - 1) {
|
|
|
|
|
sb.append(",");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String ids = null;
|
|
|
|
|
if (sb != null) {
|
|
|
|
|
ids = sb.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return coreUserDao.accountDalGetList(customFilter.getId(),ids, role, customFilter.getKeyword()
|
|
|
|
|
, customFilter.getKeyword2());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|