|
|
@@ -1,6 +1,7 @@
|
|
|
package seecoder.devcloud.web.service.impl.user;
|
|
|
|
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.gitlab4j.api.GitLabApiException;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
@@ -27,6 +28,7 @@ import seecoder.devcloud.web.service.user.MailService;
|
|
|
import seecoder.devcloud.web.service.user.UserService;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class UserServiceImpl implements UserService {
|
|
|
private static final Sort PAGE_SORT = Sort.by(Sort.Direction.ASC, "id");
|
|
|
|
|
|
@@ -65,7 +67,7 @@ public class UserServiceImpl implements UserService {
|
|
|
try {
|
|
|
gitlabUser = gitlabApi.createUser(username, email, realPassword);
|
|
|
} catch (GitLabApiException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
throw new ServiceException("创建GitLab用户时发生异常[" + e.getMessage() + "]");
|
|
|
}
|
|
|
user = new User();
|
|
|
@@ -96,6 +98,7 @@ public class UserServiceImpl implements UserService {
|
|
|
try {
|
|
|
gitlabApi.deleteUser(userId);
|
|
|
} catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
throw new ServiceException("删除GitLab用户时发生异常[" + e.getMessage() + "]");
|
|
|
}
|
|
|
//todo 删除用户需要连带删除什么
|
|
|
@@ -119,8 +122,8 @@ public class UserServiceImpl implements UserService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void changePassword(int userId, ChangePasswordVO form) throws ServiceException {
|
|
|
- User user = userMapper.findById(userId);
|
|
|
+ public void changePassword(ChangePasswordVO form) throws ServiceException {
|
|
|
+ User user = userMapper.findById(form.getUserId());
|
|
|
|
|
|
if (!user.getPassword().equals(DigestUtils.sha256Hex(form.getOrigin()))) {
|
|
|
throw new InvalidRequestException("原密码验证失败,如忘记密码请联系管理员重置");
|
|
|
@@ -140,6 +143,7 @@ public class UserServiceImpl implements UserService {
|
|
|
*/
|
|
|
gitlabApi.changePassword(user.getId(), password);
|
|
|
} catch (GitLabApiException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
throw new ServiceException("修改GitLab用户密码时发生异常[" + e.getMessage() + "]");
|
|
|
}
|
|
|
user.setPassword(DigestUtils.sha256Hex(password));
|