|
@@ -1,4 +1,5 @@
|
|
|
package com.sckw.system.service;
|
|
package com.sckw.system.service;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -9,9 +10,12 @@ import com.sckw.core.utils.PasswordUtils;
|
|
|
import com.sckw.core.utils.StringUtils;
|
|
import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
|
|
+import com.sckw.redis.utils.RedissonUtils;
|
|
|
|
|
+import com.sckw.system.dao.KwsEntCheckTrackDao;
|
|
|
import com.sckw.system.dao.KwsUserDao;
|
|
import com.sckw.system.dao.KwsUserDao;
|
|
|
import com.sckw.system.dao.KwsUserDeptDao;
|
|
import com.sckw.system.dao.KwsUserDeptDao;
|
|
|
import com.sckw.system.model.KwsUser;
|
|
import com.sckw.system.model.KwsUser;
|
|
|
|
|
+import com.sckw.system.model.vo.req.ForgetPasswordReqVo;
|
|
|
import com.sckw.system.model.vo.req.UpdatePasswordReqVo;
|
|
import com.sckw.system.model.vo.req.UpdatePasswordReqVo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -36,6 +40,8 @@ public class KwsUserService extends ServiceImpl<KwsUserDao, KwsUser> {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsUserDeptDao kwsUserDeptDao;
|
|
KwsUserDeptDao kwsUserDeptDao;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ KwsEntCheckTrackDao kwsEntCheckTrackDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsDeptService kwsDeptService;
|
|
KwsDeptService kwsDeptService;
|
|
@@ -45,7 +51,9 @@ public class KwsUserService extends ServiceImpl<KwsUserDao, KwsUser> {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsEnterpriseService kwsEnterpriseService;
|
|
KwsEnterpriseService kwsEnterpriseService;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ RedissonUtils redissonUtils;
|
|
|
/**
|
|
/**
|
|
|
* 添加新纪录
|
|
* 添加新纪录
|
|
|
*/
|
|
*/
|
|
@@ -79,10 +87,10 @@ public class KwsUserService extends ServiceImpl<KwsUserDao, KwsUser> {
|
|
|
/**
|
|
/**
|
|
|
* 删除记录-根据主键
|
|
* 删除记录-根据主键
|
|
|
*/
|
|
*/
|
|
|
- public HttpResult deleteByKey(String ids) throws Exception {
|
|
|
|
|
|
|
+ public void deleteByKey(String ids) throws Exception {
|
|
|
/**1.数据校验**/
|
|
/**1.数据校验**/
|
|
|
if (StringUtils.isBlank(ids)) {
|
|
if (StringUtils.isBlank(ids)) {
|
|
|
- return HttpResult.error("请选择您要删除的机构信息!");
|
|
|
|
|
|
|
+ throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ACCOUNT_MISSING);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int resultCode = 0;
|
|
int resultCode = 0;
|
|
@@ -92,10 +100,13 @@ public class KwsUserService extends ServiceImpl<KwsUserDao, KwsUser> {
|
|
|
KwsUser kwsUser = kwsUserDao.selectByKey(Long.parseLong(id));
|
|
KwsUser kwsUser = kwsUserDao.selectByKey(Long.parseLong(id));
|
|
|
if (null != kwsUser) {
|
|
if (null != kwsUser) {
|
|
|
kwsUser.setDelFlag(Global.YES);
|
|
kwsUser.setDelFlag(Global.YES);
|
|
|
- resultCode = kwsUserDao.update(kwsUser);
|
|
|
|
|
|
|
+ resultCode += kwsUserDao.update(kwsUser);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return resultCode > 0 ? HttpResult.ok("删除成功!") : HttpResult.error("删除失败!");
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (resultCode < idArray.length) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CODE_60601, HttpStatus.DELETE_FAIL);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -126,29 +137,20 @@ public class KwsUserService extends ServiceImpl<KwsUserDao, KwsUser> {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 重置密码
|
|
* 重置密码
|
|
|
- * @param id
|
|
|
|
|
- * @return
|
|
|
|
|
- * @throws Exception
|
|
|
|
|
*/
|
|
*/
|
|
|
public void resetPassword(Long id) throws Exception {
|
|
public void resetPassword(Long id) throws Exception {
|
|
|
//查用户信息
|
|
//查用户信息
|
|
|
- KwsUser user = kwsUserDao.selectByKey(id);
|
|
|
|
|
- if (Objects.isNull(user)) {
|
|
|
|
|
|
|
+ KwsUser kwsUser = kwsUserDao.selectByKey(id);
|
|
|
|
|
+ if (Objects.isNull(kwsUser)) {
|
|
|
throw new SystemException(HttpStatus.CODE_60602, HttpStatus.ACCOUNT_NOT_EXISTS);
|
|
throw new SystemException(HttpStatus.CODE_60602, HttpStatus.ACCOUNT_NOT_EXISTS);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//重置密码
|
|
//重置密码
|
|
|
- user.setPassword(PasswordUtils.entryptPassword(PasswordUtils.md5(user.getAccount())));
|
|
|
|
|
- if (kwsUserDao.update(user) <= 0) {
|
|
|
|
|
- throw new SystemException(HttpStatus.CODE_60601, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ updatePwd(PasswordUtils.md5(kwsUser.getAccount()), kwsUser);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据主键查询
|
|
* 根据主键查询
|
|
|
- * @param key
|
|
|
|
|
- * @return
|
|
|
|
|
- * @throws Exception
|
|
|
|
|
*/
|
|
*/
|
|
|
public KwsUser selectByKey(Long key) throws Exception {
|
|
public KwsUser selectByKey(Long key) throws Exception {
|
|
|
return kwsUserDao.selectByKey(key);
|
|
return kwsUserDao.selectByKey(key);
|
|
@@ -156,9 +158,6 @@ public class KwsUserService extends ServiceImpl<KwsUserDao, KwsUser> {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 分页查询
|
|
* 分页查询
|
|
|
- * @param params
|
|
|
|
|
- * @return
|
|
|
|
|
- * @throws Exception
|
|
|
|
|
*/
|
|
*/
|
|
|
public List<KwsUser> findPage(Map<String, Object> params) throws Exception{
|
|
public List<KwsUser> findPage(Map<String, Object> params) throws Exception{
|
|
|
return kwsUserDao.findPage(params);
|
|
return kwsUserDao.findPage(params);
|
|
@@ -166,9 +165,6 @@ public class KwsUserService extends ServiceImpl<KwsUserDao, KwsUser> {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询
|
|
* 查询
|
|
|
- * @param params
|
|
|
|
|
- * @return
|
|
|
|
|
- * @throws Exception
|
|
|
|
|
*/
|
|
*/
|
|
|
public List<Map<String, Object>> findList(Map<String, Object> params) throws Exception{
|
|
public List<Map<String, Object>> findList(Map<String, Object> params) throws Exception{
|
|
|
return kwsUserDao.findList(params);
|
|
return kwsUserDao.findList(params);
|
|
@@ -176,9 +172,6 @@ public class KwsUserService extends ServiceImpl<KwsUserDao, KwsUser> {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 参数校验
|
|
* 参数校验
|
|
|
- * @param kwsUser
|
|
|
|
|
- * @return
|
|
|
|
|
- * @throws Exception
|
|
|
|
|
*/
|
|
*/
|
|
|
public void paramsCheck(KwsUser kwsUser) {
|
|
public void paramsCheck(KwsUser kwsUser) {
|
|
|
//用户账号必填校验
|
|
//用户账号必填校验
|
|
@@ -212,6 +205,68 @@ public class KwsUserService extends ServiceImpl<KwsUserDao, KwsUser> {
|
|
|
* 修改密码
|
|
* 修改密码
|
|
|
*/
|
|
*/
|
|
|
public void updatePassword(UpdatePasswordReqVo reqVo) {
|
|
public void updatePassword(UpdatePasswordReqVo reqVo) {
|
|
|
|
|
+ //查用户信息
|
|
|
|
|
+ KwsUser kwsUser = checkUserBase(reqVo.getAccount());
|
|
|
|
|
+
|
|
|
|
|
+ //密码校验
|
|
|
|
|
+ String password = reqVo.getPassword();
|
|
|
|
|
+ String currentPwd = kwsUser.getPassword();
|
|
|
|
|
+ checkPassword(password, currentPwd);
|
|
|
|
|
+
|
|
|
|
|
+ //校验新密码是否可用
|
|
|
|
|
+ String newPassword = reqVo.getNewPassword();
|
|
|
|
|
+ if (PasswordUtils.validatePassword(newPassword, currentPwd)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CODE_10301, HttpStatus.PASSWD_REPEAT);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ //修改密码
|
|
|
|
|
+ updatePwd(newPassword, kwsUser);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void updatePwd(String newPassword, KwsUser kwsUser) {
|
|
|
|
|
+ kwsUser.setPassword(PasswordUtils.entryptPassword(newPassword));
|
|
|
|
|
+ if(kwsUserDao.update(kwsUser) <= 0) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CODE_60601, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 忘记密码
|
|
|
|
|
+ */
|
|
|
|
|
+ public void forgetPassword(ForgetPasswordReqVo reqVo) {
|
|
|
|
|
+ //查用户信息
|
|
|
|
|
+ KwsUser kwsUser = checkUserBase(reqVo.getAccount());
|
|
|
|
|
+
|
|
|
|
|
+ //从缓存中取出验证码,校验
|
|
|
|
|
+ //todo
|
|
|
|
|
+ String sms = redissonUtils.get("captcha:czh").toString();
|
|
|
|
|
+ if (!reqVo.getCaptcha().equals(sms)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CODE_10301, HttpStatus.CAPTCHA_ERROR);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //修改密码
|
|
|
|
|
+ updatePwd(reqVo.getPassword(), kwsUser);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据登录名校验
|
|
|
|
|
+ */
|
|
|
|
|
+ public KwsUser checkUserBase(String account) {
|
|
|
|
|
+ KwsUser kwsUser = getUserByAccount(account);
|
|
|
|
|
+ if (Objects.isNull(kwsUser)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CODE_60602, HttpStatus.ACCOUNT_NOT_EXISTS);
|
|
|
|
|
+ }
|
|
|
|
|
+ return kwsUser;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 校验密码
|
|
|
|
|
+ * @param password 入参传的密码
|
|
|
|
|
+ * @param currentPwd 当前用户的密码
|
|
|
|
|
+ */
|
|
|
|
|
+ public void checkPassword(String password, String currentPwd) {
|
|
|
|
|
+ if (!PasswordUtils.validatePassword(password, currentPwd)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CODE_10301, HttpStatus.PASSWD_ERROR);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|