|
@@ -13,8 +13,11 @@ import thyyxxk.webserver.entity.login.UserInfo;
|
|
|
import thyyxxk.webserver.entity.settings.deptphones.DeptPhones;
|
|
|
import thyyxxk.webserver.entity.settings.users.ChangePwdParam;
|
|
|
import thyyxxk.webserver.entity.settings.permissions.*;
|
|
|
+import thyyxxk.webserver.entity.settings.users.WorkIntegrationPlatformAdvice;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
+import thyyxxk.webserver.utils.StringUtil;
|
|
|
import thyyxxk.webserver.utils.TokenUtil;
|
|
|
+import thyyxxk.webserver.websocket.WebSocketServer;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -35,6 +38,9 @@ public class SettingsService {
|
|
|
public ResultVo<UserInfo> getUserInfo() {
|
|
|
final String code = TokenUtil.getTokenUserId();
|
|
|
final UserInfo user = dao.getUserInfo(code);
|
|
|
+ if (null == user) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此用户的在职信息,请重新登录!");
|
|
|
+ }
|
|
|
final String token = TokenUtil.getCorpWechatToken();
|
|
|
final String url = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=" + token +
|
|
|
"&userid=" + user.getCodeRs();
|
|
@@ -42,6 +48,7 @@ public class SettingsService {
|
|
|
final String result = restTemplate.getForObject(url, String.class);
|
|
|
JSONObject json = JSONObject.parseObject(result);
|
|
|
user.setAvatar(json.getString("avatar"));
|
|
|
+ user.setRoles(dao.getUserRoles(code));
|
|
|
return ResultVoUtil.success(user);
|
|
|
}
|
|
|
|
|
@@ -172,4 +179,53 @@ public class SettingsService {
|
|
|
dao.saveDeptPhone(param);
|
|
|
return ResultVoUtil.success();
|
|
|
}
|
|
|
+
|
|
|
+ public ResultVo<List<WorkIntegrationPlatformAdvice>> getMyAdvices() {
|
|
|
+ String userId = TokenUtil.getTokenUserId();
|
|
|
+ List<Integer> userRoles = dao.getUserRoles(userId);
|
|
|
+ List<WorkIntegrationPlatformAdvice> list;
|
|
|
+ if (null != userRoles && userRoles.contains(1)) {
|
|
|
+ list = dao.selectAllAdvices();
|
|
|
+ } else {
|
|
|
+ list = dao.selectMyAdvices(userId);
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> submitNewAdvice(WorkIntegrationPlatformAdvice advice) {
|
|
|
+ if (StringUtil.isBlank(advice.getSubmitContent())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "请填写建议内容!");
|
|
|
+ }
|
|
|
+ String userId = TokenUtil.getTokenUserId();
|
|
|
+ dao.insertNewAdvice(userId, advice.getSubmitContent());
|
|
|
+ List<String> admins = dao.selectAdmins();
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("name", "systemNotification");
|
|
|
+ obj.put("message", String.format("用户【%s】提交了新的建议,请前往个人中心查看。", userId));
|
|
|
+ String message = obj.toJSONString();
|
|
|
+ admins.forEach(code -> WebSocketServer.sendMessageByUserCode(code, message));
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> checkAdvice(Integer id) {
|
|
|
+ dao.checkAdvice(id);
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> dismissUserBadge(Integer id) {
|
|
|
+ dao.dismissUserBadge(id);
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> replyAdvice(WorkIntegrationPlatformAdvice advice) {
|
|
|
+ if (StringUtil.isBlank(advice.getReply())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "请填写回复内容!");
|
|
|
+ }
|
|
|
+ dao.updateReply(advice.getId(), advice.getReply(), TokenUtil.getTokenUserId());
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("name", "systemNotification");
|
|
|
+ obj.put("message", "您提交的建议已有新的回复,请前往个人中心查看。");
|
|
|
+ WebSocketServer.sendMessageByUserCode(advice.getSubmitStaff(), obj.toJSONString());
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
}
|