mirror of
https://github.com/chatopera/cosin.git
synced 2025-07-20 04:23:01 +08:00
#524 new role logic
This commit is contained in:
parent
84e025cbcc
commit
be02c8faea
@ -18,11 +18,9 @@ package com.chatopera.cc;
|
||||
|
||||
import com.chatopera.cc.basic.Constants;
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.basic.plugins.PluginRegistry;
|
||||
import com.chatopera.cc.config.AppCtxRefreshEventListener;
|
||||
import com.chatopera.cc.util.SystemEnvHelper;
|
||||
import com.chatopera.cc.util.mobile.MobileNumberUtils;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -44,9 +44,6 @@ public class ACDAgentDispatcher implements IACDDispatcher {
|
||||
@Autowired
|
||||
private AgentStatusRepository agentStatusRes;
|
||||
|
||||
@Autowired
|
||||
private ACDAgentService acdAgentService;
|
||||
|
||||
@Autowired
|
||||
private RedisCommand redisCommand;
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class ACDMessageHelper {
|
||||
* @param initiator
|
||||
* @return
|
||||
*/
|
||||
public static ACDComposeContext getComposeContextWithAgentUser(final AgentUser agentUser, final boolean isInvite, final String initiator) {
|
||||
public ACDComposeContext getComposeContextWithAgentUser(final AgentUser agentUser, final boolean isInvite, final String initiator) {
|
||||
ACDComposeContext ctx = new ACDComposeContext();
|
||||
ctx.setOnlineUserId(agentUser.getUserid());
|
||||
ctx.setOnlineUserNickname(agentUser.getNickname());
|
||||
|
@ -28,6 +28,8 @@ import com.chatopera.cc.model.StreamingFile;
|
||||
import com.chatopera.cc.model.User;
|
||||
import com.chatopera.cc.persistence.blob.JpaBlobHelper;
|
||||
import com.chatopera.cc.persistence.repository.StreamingFileRepository;
|
||||
import com.chatopera.cc.proxy.OrganProxy;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
@ -53,7 +55,6 @@ import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionAttributes
|
||||
public class Handler {
|
||||
@ -71,6 +72,9 @@ public class Handler {
|
||||
@Autowired
|
||||
private AuthToken authToken;
|
||||
|
||||
@Autowired
|
||||
private OrganProxy organProxy;
|
||||
|
||||
public final static int PAGE_SIZE_BG = 1;
|
||||
public final static int PAGE_SIZE_TW = 20;
|
||||
public final static int PAGE_SIZE_FV = 50;
|
||||
@ -115,28 +119,12 @@ public class Handler {
|
||||
public Organ getOrgan(HttpServletRequest request) {
|
||||
User user = getUser(request);
|
||||
if (user.getOrgans() != null) {
|
||||
ArrayList<Organ> organs = new ArrayList<>(user.getOrgans().values());
|
||||
|
||||
if (organs.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Organ organ = (Organ) request.getSession(true).getAttribute(Constants.ORGAN_SESSION_NAME);
|
||||
if (organ == null) {
|
||||
if (organs.size() > 0) {
|
||||
ArrayList<String> organTree = new ArrayList();
|
||||
organs.stream().forEach(o -> {
|
||||
if (organTree.stream().filter(p -> StringUtils.equals(o.getParent(), p)).findFirst().isPresent()) {
|
||||
int index = organTree.indexOf(o.getParent());
|
||||
organTree.add(index + 1, o.getId());
|
||||
} else {
|
||||
organTree.add(0, o.getId());
|
||||
}
|
||||
});
|
||||
organ = organProxy.getDefault(user.getOrgans().values());
|
||||
|
||||
organ = organs.stream().filter(o ->
|
||||
StringUtils.equals(o.getId(), organTree.get(0))
|
||||
).findFirst().orElse(organs.get(0));
|
||||
if (organ != null) {
|
||||
request.getSession(true).setAttribute(Constants.ORGAN_SESSION_NAME, organ);
|
||||
}
|
||||
}
|
||||
@ -154,7 +142,8 @@ public class Handler {
|
||||
* @return
|
||||
* @throws CSKefuException
|
||||
*/
|
||||
public boolean esOrganFilter(final HttpServletRequest request, final BoolQueryBuilder boolQueryBuilder) throws CSKefuException {
|
||||
public boolean esOrganFilter(final HttpServletRequest request, final BoolQueryBuilder boolQueryBuilder)
|
||||
throws CSKefuException {
|
||||
// 组合部门条件
|
||||
User u = getUser(request);
|
||||
if (u == null) {
|
||||
@ -164,7 +153,8 @@ public class Handler {
|
||||
return true;
|
||||
} else {
|
||||
// 用户在部门中,通过部门过滤数据
|
||||
// String[] values = u.getAffiliates().toArray(new String[u.getAffiliates().size()]);
|
||||
// String[] values = u.getAffiliates().toArray(new
|
||||
// String[u.getAffiliates().size()]);
|
||||
// boolQueryBuilder.filter(termsQuery("organ", values));
|
||||
// 不对contacts进行过滤,普通用户也可以查看该租户的任何数据
|
||||
// return true;
|
||||
@ -289,7 +279,6 @@ public class Handler {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
map.put("apbegin", request.getParameter("apbegin"));
|
||||
map.put("apend", request.getParameter("apend"));
|
||||
@ -398,7 +387,6 @@ public class Handler {
|
||||
request.getSession(true).setAttribute(Constants.USER_SESSION_NAME, user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建系统监控的 模板页面
|
||||
*
|
||||
@ -481,7 +469,6 @@ public class Handler {
|
||||
return pagesize;
|
||||
}
|
||||
|
||||
|
||||
public int get50Ps(HttpServletRequest request) {
|
||||
int pagesize = PAGE_SIZE_FV;
|
||||
String ps = request.getParameter("ps");
|
||||
@ -526,5 +513,4 @@ public class Handler {
|
||||
return fileid;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.basic.MainUtils;
|
||||
import com.chatopera.cc.basic.auth.AuthToken;
|
||||
import com.chatopera.cc.model.AgentStatus;
|
||||
import com.chatopera.cc.model.Organ;
|
||||
import com.chatopera.cc.model.SystemConfig;
|
||||
import com.chatopera.cc.model.User;
|
||||
import com.chatopera.cc.model.UserRole;
|
||||
@ -91,7 +92,6 @@ public class LoginController extends Handler {
|
||||
@Value("${extras.login.chatbox}")
|
||||
private String extrasLoginChatbox;
|
||||
|
||||
|
||||
private void putViewExtras(final ModelAndView view) {
|
||||
if (StringUtils.isNotBlank(extrasLoginBanner) && !StringUtils.equalsIgnoreCase(extrasLoginBanner, "off")) {
|
||||
view.addObject("extrasLoginBanner", extrasLoginBanner);
|
||||
@ -118,7 +118,8 @@ public class LoginController extends Handler {
|
||||
*/
|
||||
@RequestMapping(value = "/login", method = RequestMethod.GET)
|
||||
@Menu(type = "apps", subtype = "user", access = true)
|
||||
public ModelAndView login(HttpServletRequest request, HttpServletResponse response, @RequestHeader(value = "referer", required = false) String referer, @Valid String msg) {
|
||||
public ModelAndView login(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestHeader(value = "referer", required = false) String referer, @Valid String msg) {
|
||||
ModelAndView view = new ModelAndView("redirect:/");
|
||||
if (request.getSession(true).getAttribute(Constants.USER_SESSION_NAME) == null) {
|
||||
view = new ModelAndView("/login");
|
||||
@ -166,7 +167,8 @@ public class LoginController extends Handler {
|
||||
view.addObject("systemConfig", systemConfig);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(tongjiBaiduSiteKey) && !StringUtils.equalsIgnoreCase(tongjiBaiduSiteKey, "placeholder")) {
|
||||
if (StringUtils.isNotBlank(tongjiBaiduSiteKey)
|
||||
&& !StringUtils.equalsIgnoreCase(tongjiBaiduSiteKey, "placeholder")) {
|
||||
view.addObject("tongjiBaiduSiteKey", tongjiBaiduSiteKey);
|
||||
}
|
||||
|
||||
@ -288,7 +290,6 @@ public class LoginController extends Handler {
|
||||
loginUser.getId(), MainUtils.getContextID(request.getSession().getId()), loginUser.getOrgi());
|
||||
loginUser.setSessionid(MainUtils.getContextID(request.getSession().getId()));
|
||||
|
||||
|
||||
if (StringUtils.isNotBlank(referer)) {
|
||||
view = new ModelAndView("redirect:" + referer);
|
||||
} else {
|
||||
@ -297,7 +298,8 @@ public class LoginController extends Handler {
|
||||
|
||||
// 登录成功 判断是否进入多租户页面
|
||||
SystemConfig systemConfig = MainUtils.getSystemConfig();
|
||||
if (systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantconsole() && !loginUser.isAdmin()) {
|
||||
if (systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantconsole()
|
||||
&& !loginUser.isAdmin()) {
|
||||
view = new ModelAndView("redirect:/apps/tenant/index");
|
||||
}
|
||||
List<UserRole> userRoleList = userRoleRes.findByOrgiAndUser(loginUser.getOrgi(), loginUser);
|
||||
@ -310,8 +312,10 @@ public class LoginController extends Handler {
|
||||
// 获取用户部门以及下级部门
|
||||
userProxy.attachOrgansPropertiesForUser(loginUser);
|
||||
|
||||
Organ currentOrgan = super.getOrgan(request);
|
||||
|
||||
// 添加角色信息
|
||||
userProxy.attachRolesMap(loginUser);
|
||||
userProxy.attachRolesMap(loginUser, currentOrgan);
|
||||
|
||||
loginUser.setLastlogintime(new Date());
|
||||
if (StringUtils.isNotBlank(loginUser.getId())) {
|
||||
@ -323,7 +327,6 @@ public class LoginController extends Handler {
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登出用户
|
||||
* code代表登出的原因
|
||||
@ -334,7 +337,8 @@ public class LoginController extends Handler {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/logout")
|
||||
public String logout(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "code", required = false) String code) throws UnsupportedEncodingException {
|
||||
public String logout(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam(value = "code", required = false) String code) throws UnsupportedEncodingException {
|
||||
final User user = super.getUser(request);
|
||||
request.getSession().removeAttribute(Constants.USER_SESSION_NAME);
|
||||
request.getSession().invalidate();
|
||||
|
@ -22,10 +22,8 @@ import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.basic.MainUtils;
|
||||
import com.chatopera.cc.cache.Cache;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.SysDic;
|
||||
import com.chatopera.cc.model.User;
|
||||
import com.chatopera.cc.persistence.repository.OnlineUserRepository;
|
||||
import com.chatopera.cc.persistence.repository.SysDicRepository;
|
||||
import com.chatopera.cc.persistence.repository.UserEventRepository;
|
||||
import com.chatopera.cc.persistence.repository.UserRepository;
|
||||
import com.chatopera.cc.proxy.OnlineUserProxy;
|
||||
@ -39,9 +37,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@ -59,9 +55,6 @@ public class AdminController extends Handler {
|
||||
@Autowired
|
||||
private UserEventRepository userEventRes;
|
||||
|
||||
@Autowired
|
||||
private SysDicRepository sysDicRes;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
|
@ -23,10 +23,13 @@ import com.chatopera.cc.persistence.repository.*;
|
||||
import com.chatopera.cc.proxy.OrganProxy;
|
||||
import com.chatopera.cc.proxy.UserProxy;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.util.json.GsonTools;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
@ -35,6 +38,8 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -54,9 +59,6 @@ public class RoleController extends Handler {
|
||||
@Autowired
|
||||
private RoleAuthRepository roleAuthRes;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private SysDicRepository sysDicRes;
|
||||
|
||||
@ -71,7 +73,7 @@ public class RoleController extends Handler {
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String role, @Valid String msg) {
|
||||
Organ currentOrgan = super.getOrgan(request);
|
||||
|
||||
List<Role> roleList = roleRepository.findByOrgiAndOrgan(super.getOrgi(),currentOrgan.getId());
|
||||
List<Role> roleList = roleRepository.findByOrgi(super.getOrgi());
|
||||
map.addAttribute("roleList", roleList);
|
||||
map.addAttribute("msg", msg);
|
||||
map.addAttribute("currentOrgan", currentOrgan);
|
||||
@ -88,7 +90,30 @@ public class RoleController extends Handler {
|
||||
map.addAttribute("roleData", roleData = roleList.get(0));
|
||||
}
|
||||
if (roleData != null) {
|
||||
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgi(), roleData, new PageRequest(super.getP(request), super.getPs(request))));
|
||||
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan,
|
||||
super.getOrgi(request));
|
||||
// List<String> userIds = userProxy.findUserIdsInOrgans(organs.keySet());
|
||||
|
||||
// Page<UserRole> userRoleList =
|
||||
// userRoleRes.findByOrganAndRole(currentOrgan.getId(), roleData,
|
||||
// new PageRequest(super.getP(request), super.getPs(request)));
|
||||
|
||||
Page<UserRole> userRoleList = userRoleRes.findByOrganInAndRole(organs.keySet(), roleData,
|
||||
new PageRequest(super.getP(request), super.getPs(request)));
|
||||
|
||||
if (userRoleList.getContent().size() > 0) {
|
||||
for (UserRole ur : userRoleList.getContent()) {
|
||||
organs.values().stream().filter(o -> o.getId().equals(ur.getOrgan())).findFirst()
|
||||
.ifPresent(o -> {
|
||||
User u = GsonTools.copyObject(ur.getUser());
|
||||
u.setCurrOrganId(o.getId());
|
||||
u.setCurrOrganName(o.getName());
|
||||
ur.setUser(u);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
map.addAttribute("userRoleList", userRoleList);
|
||||
}
|
||||
}
|
||||
return request(super.createView("/admin/role/index"));
|
||||
@ -122,8 +147,8 @@ public class RoleController extends Handler {
|
||||
@RequestMapping("/seluser")
|
||||
@Menu(type = "admin", subtype = "seluser", admin = true)
|
||||
public ModelAndView seluser(ModelMap map, HttpServletRequest request, @Valid String role) {
|
||||
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(super.getOrgan(request), super.getOrgi(request));
|
||||
map.addAttribute("userList", userProxy.findUserInOrgans(organs.keySet()));
|
||||
Organ currentOrgan = super.getOrgan(request);
|
||||
map.addAttribute("userList", userProxy.findUserInOrgans(Arrays.asList(currentOrgan.getId())));
|
||||
Role roleData = roleRepository.findByIdAndOrgi(role, super.getOrgi());
|
||||
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgi(), roleData));
|
||||
map.addAttribute("role", roleData);
|
||||
@ -133,8 +158,9 @@ public class RoleController extends Handler {
|
||||
@RequestMapping("/saveuser")
|
||||
@Menu(type = "admin", subtype = "saveuser", admin = true)
|
||||
public ModelAndView saveuser(HttpServletRequest request, @Valid String[] users, @Valid String role) {
|
||||
Organ currentOrgan = super.getOrgan(request);
|
||||
Role roleData = roleRepository.findByIdAndOrgi(role, super.getOrgi());
|
||||
List<UserRole> userRoleList = userRoleRes.findByOrgiAndRole(super.getOrgi(), roleData);
|
||||
List<UserRole> userRoleList = userRoleRes.findByOrganAndRole(super.getOrgi(), roleData);
|
||||
if (users != null && users.length > 0) {
|
||||
for (String user : users) {
|
||||
boolean exist = false;
|
||||
@ -150,6 +176,7 @@ public class RoleController extends Handler {
|
||||
userRole.setRole(new Role(role));
|
||||
userRole.setOrgi(super.getOrgi());
|
||||
userRole.setCreater(super.getUser(request).getId());
|
||||
userRole.setOrgan(currentOrgan.getId());
|
||||
userRoleRes.save(userRole);
|
||||
}
|
||||
}
|
||||
@ -239,7 +266,8 @@ public class RoleController extends Handler {
|
||||
SysDic sysDic = Dict.getInstance().getDicItem(menu);
|
||||
|
||||
if (sysDic != null && (!StringUtils.equals(sysDic.getParentid(), "0"))) {
|
||||
logger.debug("[authsave] get sysdict {}, code {}, name {}, parent {}", sysDic.getId(), sysDic.getCode(), sysDic.getName(), sysDic.getParentid());
|
||||
logger.debug("[authsave] get sysdict {}, code {}, name {}, parent {}", sysDic.getId(),
|
||||
sysDic.getCode(), sysDic.getName(), sysDic.getParentid());
|
||||
roleAuth.setCreater(super.getUser(request).getId());
|
||||
roleAuth.setOrgi(super.getOrgi());
|
||||
roleAuth.setCreatetime(new Date());
|
||||
|
@ -41,7 +41,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -23,7 +23,6 @@ import com.chatopera.cc.model.Organ;
|
||||
import com.chatopera.cc.model.User;
|
||||
import com.chatopera.cc.persistence.repository.*;
|
||||
import com.chatopera.cc.proxy.OnlineUserProxy;
|
||||
import com.chatopera.cc.proxy.UserProxy;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -60,9 +59,6 @@ public class WebIMController extends Handler {
|
||||
@Autowired
|
||||
private ServiceAiRepository serviceAiRes;
|
||||
|
||||
@Autowired
|
||||
private OrgiSkillRelRepository orgiSkillRelService;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
|
||||
@ -72,9 +68,6 @@ public class WebIMController extends Handler {
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Autowired
|
||||
private UserProxy userProxy;
|
||||
|
||||
@RequestMapping("/index")
|
||||
@Menu(type = "app", subtype = "app", admin = true)
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String snsid) {
|
||||
|
@ -11,7 +11,6 @@
|
||||
package com.chatopera.cc.controller.api;
|
||||
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.cache.Cache;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.controller.api.request.RestUtils;
|
||||
import com.chatopera.cc.model.InviteRecord;
|
||||
@ -48,9 +47,6 @@ public class ApiAppsController extends Handler {
|
||||
@Autowired
|
||||
private InviteRecordRepository inviteRecordRes;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
@Menu(type = "apps", subtype = "apps", access = true)
|
||||
public ResponseEntity<String> operations(HttpServletRequest request, @RequestBody final String body, @Valid String q) {
|
||||
|
@ -16,7 +16,6 @@
|
||||
package com.chatopera.cc.controller.api;
|
||||
|
||||
import com.chatopera.cc.basic.Constants;
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.basic.MainUtils;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.controller.api.request.RestUtils;
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
package com.chatopera.cc.controller.api;
|
||||
|
||||
import com.chatopera.cc.basic.Constants;
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.controller.api.request.RestUtils;
|
||||
import com.chatopera.cc.exception.CSKefuRestException;
|
||||
@ -25,7 +23,6 @@ import com.chatopera.cc.model.Tag;
|
||||
import com.chatopera.cc.model.TagRelation;
|
||||
import com.chatopera.cc.persistence.repository.TagRelationRepository;
|
||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||
import com.chatopera.cc.persistence.repository.UserRepository;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.util.json.GsonTools;
|
||||
import com.google.gson.JsonArray;
|
||||
@ -63,10 +60,6 @@ public class ApiContactTagsController extends Handler {
|
||||
@Autowired
|
||||
private TagRelationRepository tagRelationRes;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRes;
|
||||
|
||||
|
||||
/**
|
||||
* 获取联系人标签
|
||||
*
|
||||
|
@ -158,8 +158,6 @@ public class ApiContactsController extends Handler {
|
||||
JsonObject json = new JsonObject();
|
||||
HttpHeaders headers = RestUtils.header();
|
||||
final User logined = super.getUser(request);
|
||||
final String orgi = logined.getOrgi();
|
||||
|
||||
if (!j.has("ops")) {
|
||||
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
|
||||
json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的请求参数。");
|
||||
|
@ -17,13 +17,11 @@
|
||||
package com.chatopera.cc.controller.api;
|
||||
|
||||
import com.chatopera.cc.acd.ACDAgentService;
|
||||
import com.chatopera.cc.acd.ACDPolicyService;
|
||||
import com.chatopera.cc.acd.ACDWorkMonitor;
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.cache.Cache;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.AgentStatus;
|
||||
import com.chatopera.cc.model.SessionConfig;
|
||||
import com.chatopera.cc.model.User;
|
||||
import com.chatopera.cc.persistence.repository.AgentStatusRepository;
|
||||
import com.chatopera.cc.proxy.AgentStatusProxy;
|
||||
@ -56,9 +54,6 @@ public class ApiServiceQueneController extends Handler {
|
||||
@Autowired
|
||||
private ACDWorkMonitor acdWorkMonitor;
|
||||
|
||||
@Autowired
|
||||
private ACDPolicyService acdPolicyService;
|
||||
|
||||
@Autowired
|
||||
private AgentStatusRepository agentStatusRes;
|
||||
|
||||
|
@ -27,7 +27,6 @@ import com.chatopera.cc.persistence.repository.OrganRepository;
|
||||
import com.chatopera.cc.persistence.repository.OrganUserRepository;
|
||||
import com.chatopera.cc.persistence.repository.UserRepository;
|
||||
import com.chatopera.cc.persistence.repository.UserRoleRepository;
|
||||
import com.chatopera.cc.proxy.OnlineUserProxy;
|
||||
import com.chatopera.cc.proxy.UserProxy;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.util.RestResult;
|
||||
|
@ -57,9 +57,6 @@ public class ApiLoginController extends Handler {
|
||||
@Autowired
|
||||
private UserRoleRepository userRoleRes;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Autowired
|
||||
private AuthToken authToken;
|
||||
|
||||
|
@ -340,13 +340,6 @@ public class AgentAuditController extends Handler {
|
||||
.toString())));
|
||||
view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid()));
|
||||
|
||||
// TODO: mdx-organ clean
|
||||
// SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
|
||||
//
|
||||
// view.addObject("sessionConfig", sessionConfig);
|
||||
// if (sessionConfig.isOtherquickplay()) {
|
||||
// view.addObject("topicList", OnlineUserProxy.search(null, orgi, super.getUser(request)));
|
||||
// }
|
||||
AgentService service = agentServiceRes.findByIdAndOrgi(agentUser.getAgentserviceid(), orgi);
|
||||
if (service != null) {
|
||||
view.addObject("tags", tagRes.findByOrgiAndTagtypeAndSkill(orgi, MainContext.ModelType.USER.toString(), service.getSkill()));
|
||||
@ -378,8 +371,6 @@ public class AgentAuditController extends Handler {
|
||||
) {
|
||||
logger.info("[transfer] userId {}, agentUser {}", userid, agentuserid);
|
||||
final String orgi = super.getOrgi(request);
|
||||
final User logined = super.getUser(request);
|
||||
|
||||
Organ targetOrgan = super.getOrgan(request);
|
||||
Map<String, Organ> ownOrgans = organProxy.findAllOrganByParentAndOrgi(targetOrgan, super.getOrgi(request));
|
||||
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) {
|
||||
@ -444,7 +435,6 @@ public class AgentAuditController extends Handler {
|
||||
@Valid String agentid,
|
||||
@Valid String organ
|
||||
) {
|
||||
final User logined = super.getUser(request);
|
||||
final String orgi = super.getOrgi(request);
|
||||
if (StringUtils.isNotBlank(organ)) {
|
||||
List<String> userids = new ArrayList<>();
|
||||
|
@ -21,8 +21,10 @@ import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.basic.MainUtils;
|
||||
import com.chatopera.cc.config.MessagingServerConfigure;
|
||||
import com.chatopera.cc.model.Dict;
|
||||
import com.chatopera.cc.model.Organ;
|
||||
import com.chatopera.cc.model.SystemConfig;
|
||||
import com.chatopera.cc.model.User;
|
||||
import com.chatopera.cc.proxy.OrganProxy;
|
||||
import com.chatopera.cc.proxy.UserProxy;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.util.PugHelper;
|
||||
@ -40,6 +42,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
||||
private final static Logger logger = LoggerFactory.getLogger(UserInterceptorHandler.class);
|
||||
private static UserProxy userProxy;
|
||||
private static OrganProxy organProxy;
|
||||
private static Integer webimport;
|
||||
|
||||
@Override
|
||||
@ -47,21 +50,26 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
||||
throws Exception {
|
||||
boolean filter = false;
|
||||
User user = (User) request.getSession(true).getAttribute(Constants.USER_SESSION_NAME);
|
||||
Organ organ = (Organ) request.getSession(true).getAttribute(Constants.ORGAN_SESSION_NAME);
|
||||
|
||||
if (handler instanceof HandlerMethod) {
|
||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||
Menu menu = handlerMethod.getMethod().getAnnotation(Menu.class);
|
||||
if (user != null || (menu != null && menu.access()) || handlerMethod.getBean() instanceof BasicErrorController) {
|
||||
if (user != null || (menu != null && menu.access())
|
||||
|| handlerMethod.getBean() instanceof BasicErrorController) {
|
||||
filter = true;
|
||||
if (user != null && StringUtils.isNotBlank(user.getId())) {
|
||||
|
||||
if (organ == null) {
|
||||
organ = getOrganProxy().getDefault(user.getOrgans().values());
|
||||
}
|
||||
/**
|
||||
* 每次刷新用户的组织机构、角色和权限
|
||||
* TODO 此处代码执行频率高,但是并不是每次都要执行,存在很多冗余
|
||||
* 待用更好的方法实现
|
||||
*/
|
||||
getUserProxy().attachOrgansPropertiesForUser(user);
|
||||
getUserProxy().attachRolesMap(user);
|
||||
getUserProxy().attachRolesMap(user, organ);
|
||||
|
||||
request.getSession(true).setAttribute(Constants.USER_SESSION_NAME, user);
|
||||
}
|
||||
@ -160,10 +168,10 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
|
||||
Exception ex) {
|
||||
}
|
||||
|
||||
|
||||
private static Integer getWebimport() {
|
||||
if (webimport == null) {
|
||||
webimport = MainContext.getContext().getBean(MessagingServerConfigure.class).getWebIMPort();
|
||||
@ -171,11 +179,17 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
||||
return webimport;
|
||||
}
|
||||
|
||||
|
||||
private static UserProxy getUserProxy() {
|
||||
if (userProxy == null) {
|
||||
userProxy = MainContext.getContext().getBean(UserProxy.class);
|
||||
}
|
||||
return userProxy;
|
||||
}
|
||||
|
||||
private static OrganProxy getOrganProxy() {
|
||||
if (organProxy == null) {
|
||||
organProxy = MainContext.getContext().getBean(OrganProxy.class);
|
||||
}
|
||||
return organProxy;
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ public class UserRole implements java.io.Serializable {
|
||||
private Role role;
|
||||
private String creater;
|
||||
private String orgi;
|
||||
private String organ;
|
||||
private Date createtime = new Date();
|
||||
|
||||
@Id
|
||||
@ -44,6 +45,14 @@ public class UserRole implements java.io.Serializable {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getOrgan() {
|
||||
return organ;
|
||||
}
|
||||
|
||||
public void setOrgan(String organ) {
|
||||
this.organ = organ;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.chatopera.cc.persistence.repository;
|
||||
|
||||
import com.chatopera.cc.model.Organ;
|
||||
import com.chatopera.cc.model.Role;
|
||||
import com.chatopera.cc.model.User;
|
||||
import com.chatopera.cc.model.UserRole;
|
||||
@ -24,10 +25,17 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface UserRoleRepository extends JpaRepository<UserRole, String>
|
||||
{
|
||||
public interface UserRoleRepository extends JpaRepository<UserRole, String> {
|
||||
List<UserRole> findByOrganAndRole(String organ, Role role);
|
||||
|
||||
Page<UserRole> findByOrganAndRole(String organ, Role role,
|
||||
Pageable paramPageable);
|
||||
|
||||
Page<UserRole> findByOrganInAndRole(Collection<String> organ, Role role,
|
||||
Pageable paramPageable);
|
||||
|
||||
Page<UserRole> findByOrgiAndRole(String orgi, Role role, Pageable paramPageable);
|
||||
|
||||
@ -35,8 +43,9 @@ public interface UserRoleRepository extends JpaRepository<UserRole, String>
|
||||
|
||||
List<UserRole> findByOrgiAndUser(String orgi, User user);
|
||||
|
||||
List<UserRole> findByOrganAndUser(String organ, User user);
|
||||
|
||||
@Query(value = "SELECT u.user_id FROM uk_userrole u WHERE u.orgi = ?1 AND u.role_id = ?2", nativeQuery = true)
|
||||
List<String> findByOrgiAndRoleId(final String orgi, final String roleid);
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.chatopera.cc.proxy;
|
||||
|
||||
import com.chatopera.cc.acd.ACDPolicyService;
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.basic.MainUtils;
|
||||
import com.chatopera.cc.cache.Cache;
|
||||
@ -60,9 +59,6 @@ public class AgentUserProxy {
|
||||
// 转接聊天
|
||||
private final static String AUTH_KEY_AUDIT_TRANS = "A13_A01_A03";
|
||||
|
||||
@Autowired
|
||||
private ACDPolicyService acdPolicyService;
|
||||
|
||||
@Autowired
|
||||
private AgentUserRepository agentUserRes;
|
||||
|
||||
|
@ -18,17 +18,14 @@ package com.chatopera.cc.proxy;
|
||||
|
||||
import com.chatopera.cc.cache.Cache;
|
||||
import com.chatopera.cc.model.AgentService;
|
||||
import com.chatopera.cc.model.AgentUser;
|
||||
import com.chatopera.cc.model.BlackEntity;
|
||||
import com.chatopera.cc.model.User;
|
||||
import com.chatopera.cc.persistence.repository.AgentServiceRepository;
|
||||
import com.chatopera.cc.persistence.repository.AgentUserRepository;
|
||||
import com.chatopera.cc.persistence.repository.BlackListRepository;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
@ -40,9 +37,6 @@ public class BlackEntityProxy {
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Autowired
|
||||
private AgentUserRepository agentUserRepository;
|
||||
|
||||
@Autowired
|
||||
private AgentServiceRepository agentServiceRes;
|
||||
|
||||
|
@ -49,7 +49,6 @@ public class OrganProxy {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param organ
|
||||
* @param orgi
|
||||
@ -113,4 +112,26 @@ public class OrganProxy {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Organ getDefault(Collection<Organ> organs) {
|
||||
Organ organ = null;
|
||||
|
||||
if (organs.size() > 0) {
|
||||
ArrayList<String> organTree = new ArrayList<>();
|
||||
organs.stream().forEach(o -> {
|
||||
if (organTree.stream().filter(p -> StringUtils.equals(o.getParent(), p)).findFirst()
|
||||
.isPresent()) {
|
||||
int index = organTree.indexOf(o.getParent());
|
||||
organTree.add(index + 1, o.getId());
|
||||
} else {
|
||||
organTree.add(0, o.getId());
|
||||
}
|
||||
});
|
||||
|
||||
organ = organs.stream().filter(o -> StringUtils.equals(o.getId(), organTree.get(0))).findFirst()
|
||||
.orElse(organs.stream().findFirst().get());
|
||||
}
|
||||
|
||||
return organ;
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户/坐席 常用方法
|
||||
@ -59,6 +60,9 @@ public class UserProxy {
|
||||
@Autowired
|
||||
private ExtensionRepository extensionRes;
|
||||
|
||||
@Autowired
|
||||
private UserRoleRepository userRoleRes;
|
||||
|
||||
public JsonObject createNewUser(final User user) {
|
||||
return this.createNewUser(user, null);
|
||||
}
|
||||
@ -79,7 +83,6 @@ public class UserProxy {
|
||||
user.setSuperadmin(false); // 不支持创建第二个系统管理员
|
||||
user.setOrgi(Constants.SYSTEM_ORGI);
|
||||
|
||||
|
||||
if (StringUtils.isNotBlank(user.getPassword())) {
|
||||
user.setPassword(MainUtils.md5(user.getPassword()));
|
||||
}
|
||||
@ -99,7 +102,6 @@ public class UserProxy {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public User findOne(final String id) {
|
||||
return userRes.findOne(id);
|
||||
}
|
||||
@ -122,7 +124,8 @@ public class UserProxy {
|
||||
|
||||
List<OrganUser> x = organUserRes.findByOrganIn(organs);
|
||||
|
||||
if (x.size() == 0) return null;
|
||||
if (x.size() == 0)
|
||||
return null;
|
||||
|
||||
Set<String> y = new HashSet<>();
|
||||
|
||||
@ -142,7 +145,8 @@ public class UserProxy {
|
||||
*/
|
||||
public List<User> findUserInOrgans(final Collection<String> organs) {
|
||||
List<OrganUser> x = organUserRes.findByOrganIn(organs);
|
||||
if (x.size() == 0) return null;
|
||||
if (x.size() == 0)
|
||||
return null;
|
||||
Set<String> y = new HashSet<>();
|
||||
for (final OrganUser z : x) {
|
||||
y.add(z.getUserid());
|
||||
@ -153,7 +157,8 @@ public class UserProxy {
|
||||
public Page<User> findUserInOrgans(final Collection<String> organs,
|
||||
Pageable pageRequest) {
|
||||
List<OrganUser> x = organUserRes.findByOrganIn(organs);
|
||||
if (x.size() == 0) return null;
|
||||
if (x.size() == 0)
|
||||
return null;
|
||||
Set<String> y = new HashSet<>();
|
||||
for (final OrganUser z : x) {
|
||||
y.add(z.getUserid());
|
||||
@ -161,7 +166,6 @@ public class UserProxy {
|
||||
return userRes.findByIdIn(y, pageRequest);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过坐席ID查找其技能组Map
|
||||
*
|
||||
@ -171,7 +175,8 @@ public class UserProxy {
|
||||
public HashMap<String, String> getSkillsMapByAgentno(final String agentno) {
|
||||
|
||||
final User user = userRes.findOne(agentno);
|
||||
if (user == null) return new HashMap<>();
|
||||
if (user == null)
|
||||
return new HashMap<>();
|
||||
|
||||
attachOrgansPropertiesForUser(user);
|
||||
return user.getSkills();
|
||||
@ -186,7 +191,8 @@ public class UserProxy {
|
||||
public List<String> findOrgansByUserid(final String userid) {
|
||||
List<OrganUser> x = organUserRes.findByUserid(userid);
|
||||
|
||||
if (x.size() == 0) return null;
|
||||
if (x.size() == 0)
|
||||
return null;
|
||||
|
||||
List<String> y = new ArrayList<>();
|
||||
|
||||
@ -197,7 +203,6 @@ public class UserProxy {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
public Page<User> findByOrganInAndAgentAndDatastatus(
|
||||
final List<String> organs,
|
||||
boolean agent,
|
||||
@ -205,7 +210,8 @@ public class UserProxy {
|
||||
Pageable pageRequest) {
|
||||
List<String> users = findUserIdsInOrgans(organs);
|
||||
|
||||
if (users == null) return null;
|
||||
if (users == null)
|
||||
return null;
|
||||
|
||||
return userRes.findByAgentAndDatastatusAndIdIn(agent, datastatus, users, pageRequest);
|
||||
|
||||
@ -217,7 +223,8 @@ public class UserProxy {
|
||||
boolean datastatus) {
|
||||
List<String> users = findUserIdsInOrgans(organs);
|
||||
|
||||
if (users == null) return null;
|
||||
if (users == null)
|
||||
return null;
|
||||
|
||||
return userRes.findByAgentAndDatastatusAndIdIn(agent, datastatus, users);
|
||||
}
|
||||
@ -227,7 +234,8 @@ public class UserProxy {
|
||||
boolean datastatus) {
|
||||
List<String> users = findUserIdsInOrgans(organs);
|
||||
|
||||
if (users == null) return null;
|
||||
if (users == null)
|
||||
return null;
|
||||
|
||||
return userRes.findByDatastatusAndIdIn(datastatus, users);
|
||||
}
|
||||
@ -238,14 +246,16 @@ public class UserProxy {
|
||||
final String username,
|
||||
Pageable pageRequest) {
|
||||
List<String> users = findUserIdsInOrgans(organs);
|
||||
if (users == null) return null;
|
||||
if (users == null)
|
||||
return null;
|
||||
return userRes.findByDatastatusAndUsernameLikeAndIdIn(datastatus, username, users, pageRequest);
|
||||
}
|
||||
|
||||
public List<User> findByOrganAndOrgiAndDatastatus(final String organ, final String orgi, final boolean datastatus) {
|
||||
List<String> users = findUserIdsInOrgan(organ);
|
||||
|
||||
if (users == null) return null;
|
||||
if (users == null)
|
||||
return null;
|
||||
|
||||
return userRes.findByOrgiAndDatastatusAndIdIn(orgi, datastatus, users);
|
||||
|
||||
@ -451,12 +461,12 @@ public class UserProxy {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
public List<User> findAllByCallcenterIsTrueAndDatastatusIsFalseAndOrgan(final String organ) {
|
||||
|
||||
final List<String> users = findUserIdsInOrgan(organ);
|
||||
|
||||
if (users == null) return null;
|
||||
if (users == null)
|
||||
return null;
|
||||
|
||||
return userRes.findAllByCallcenterIsTrueAndDatastatusIsFalseAndIdIn(users);
|
||||
}
|
||||
@ -478,18 +488,15 @@ public class UserProxy {
|
||||
|
||||
final List<String> users = findUserIdsInOrgan(organ);
|
||||
|
||||
if (users == null) return 0;
|
||||
if (users == null)
|
||||
return 0;
|
||||
|
||||
return userRes.countByAgentAndDatastatusAndIdIn(agent, datastatus, users);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加用户的角色信息
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
public void attachRolesMap(final User user) {
|
||||
public void attachRolesMap(final User user, Organ organ) {
|
||||
|
||||
// 获取用户的角色权限,进行授权
|
||||
List<RoleAuth> roleAuthList = roleAuthRes.findAll(new Specification<RoleAuth>() {
|
||||
@Override
|
||||
@ -497,8 +504,13 @@ public class UserProxy {
|
||||
Root<RoleAuth> root, CriteriaQuery<?> query,
|
||||
CriteriaBuilder cb) {
|
||||
List<Predicate> criteria = new ArrayList<Predicate>();
|
||||
if (user.getRoleList() != null && user.getRoleList().size() > 0) {
|
||||
for (Role role : user.getRoleList()) {
|
||||
|
||||
String organId = organ != null ? organ.getId() : null;
|
||||
|
||||
List<UserRole> userRoleList = userRoleRes.findByOrganAndUser(organId, user);
|
||||
List<Role> roles = userRoleList.stream().map(ur -> ur.getRole()).collect(Collectors.toList());
|
||||
if (roles.size() > 0) {
|
||||
for (Role role : roles) {
|
||||
criteria.add(cb.equal(root.get("roleid").as(String.class), role.getId()));
|
||||
}
|
||||
}
|
||||
@ -508,7 +520,8 @@ public class UserProxy {
|
||||
}
|
||||
});
|
||||
|
||||
// clear previous auth map values, ensure the changes are token effect in real time.
|
||||
// clear previous auth map values, ensure the changes are token effect in real
|
||||
// time.
|
||||
user.getRoleAuthMap().clear();
|
||||
if (roleAuthList != null) {
|
||||
for (RoleAuth roleAuth : roleAuthList) {
|
||||
@ -517,6 +530,42 @@ public class UserProxy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加用户的角色信息
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
// public void attachRolesMap(final User user) {
|
||||
// // 获取用户的角色权限,进行授权
|
||||
// List<RoleAuth> roleAuthList = roleAuthRes.findAll(new
|
||||
// Specification<RoleAuth>() {
|
||||
// @Override
|
||||
// public Predicate toPredicate(
|
||||
// Root<RoleAuth> root, CriteriaQuery<?> query,
|
||||
// CriteriaBuilder cb) {
|
||||
// List<Predicate> criteria = new ArrayList<Predicate>();
|
||||
// if (user.getRoleList() != null && user.getRoleList().size() > 0) {
|
||||
// for (Role role : user.getRoleList()) {
|
||||
// criteria.add(cb.equal(root.get("roleid").as(String.class), role.getId()));
|
||||
// }
|
||||
// }
|
||||
// Predicate[] p = new Predicate[criteria.size()];
|
||||
// cb.and(cb.equal(root.get("orgi").as(String.class), user.getOrgi()));
|
||||
// return cb.or(criteria.toArray(p));
|
||||
// }
|
||||
// });
|
||||
|
||||
// // clear previous auth map values, ensure the changes are token effect in
|
||||
// real
|
||||
// // time.
|
||||
// user.getRoleAuthMap().clear();
|
||||
// if (roleAuthList != null) {
|
||||
// for (RoleAuth roleAuth : roleAuthList) {
|
||||
// user.getRoleAuthMap().put(roleAuth.getDicvalue(), true);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获得一个部门及其子部门并添加到User的myorgans中
|
||||
*
|
||||
|
@ -12,8 +12,11 @@
|
||||
ul#roleTree.ztree
|
||||
.layui-form-button
|
||||
.layui-button-block
|
||||
if user.superadmin
|
||||
button.layui-btn(lay-submit, lay-filter='formDemo') 立即提交
|
||||
button#reset.layui-btn.layui-btn-original(type='reset', href='/admin/role/auth.html?id=${role.id}') 重置
|
||||
else
|
||||
button.layui-btn.layui-btn-original(type='reset', onclick='layer.close(top.layerwin);') 关闭
|
||||
script(type='text/javascript').
|
||||
var setting = {
|
||||
check: {enable: true},
|
||||
|
@ -4,7 +4,8 @@ block content
|
||||
.row(style='height:100%;')
|
||||
.col-lg-3(style='border-right:1px solid #e6e6e6;padding-right:0px;')
|
||||
h1.site-h1(style='background-color:#FFFFFF;')
|
||||
| #{currentOrgan.name}角色列表
|
||||
| 角色列表
|
||||
if user.superadmin
|
||||
span(style='float:right;')
|
||||
button.layui-btn.layui-btn-small.green(href='/admin/role/add.html', data-toggle='ajax', data-height='200', data-width='550', data-title='新建角色')
|
||||
| 新建角色
|
||||
@ -34,16 +35,19 @@ block content
|
||||
if roleData
|
||||
button.layui-btn.layui-btn-small.green(href="/admin/role/seluser.html?role=" + roleData.id, data-toggle="ajax", data-width="750", data-title="添加用户到角色")
|
||||
| 添加用户到角色
|
||||
if user.superadmin
|
||||
button.layui-btn.layui-btn-original.layui-btn-small(href="/admin/role/edit.html?id=" + roleData.id, data-toggle="ajax", data-width="550", data-height="200", data-title="修改角色")
|
||||
| 修改角色
|
||||
button.layui-btn.layui-btn-warm.layui-btn-small(href="/admin/role/auth.html?id=" + roleData.id, data-toggle="ajax", title="角色授权", data-width="400", data-height="500")
|
||||
| 角色授权
|
||||
if user.superadmin
|
||||
button.layui-btn.layui-btn-danger.layui-btn-small(href="/admin/role/delete.html?id=" + roleData.id, data-toggle="tip", data-title="请确认是否删除角色?")
|
||||
| 删除角色
|
||||
.row(style='padding:5px;')
|
||||
.col-lg-12
|
||||
table.layui-table(lay-skin='line')
|
||||
colgroup
|
||||
col(width='20%')
|
||||
col(width='30%')
|
||||
col(width='20%')
|
||||
col(width='25%')
|
||||
@ -52,6 +56,7 @@ block content
|
||||
col
|
||||
thead
|
||||
tr
|
||||
th 组织
|
||||
th 用户
|
||||
th 姓名
|
||||
th 电子邮件
|
||||
@ -61,7 +66,8 @@ block content
|
||||
if userRoleList && userRoleList.content
|
||||
for userRole in userRoleList.content
|
||||
tr
|
||||
td(style="150px")
|
||||
td= userRole.user.currOrganName
|
||||
td(style="width:150px")
|
||||
a(href="")
|
||||
i.layui-icon.headimg
|
||||
div(style="margin-left:50px;margin-top:0px;")
|
||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,32 @@
|
||||
USE `cosinee`;
|
||||
-- -----------------
|
||||
-- prepare variables
|
||||
-- -----------------
|
||||
|
||||
SET @dbname = DATABASE ( );
|
||||
SET @tablename = "uk_userrole";
|
||||
SET @columnname = "organ";
|
||||
|
||||
SET @preparedStatement = (
|
||||
SELECT
|
||||
IF
|
||||
(
|
||||
(
|
||||
SELECT
|
||||
COUNT( * )
|
||||
FROM
|
||||
INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE
|
||||
( table_name = @tablename )
|
||||
AND ( table_schema = @dbname )
|
||||
AND ( column_name = @columnname )
|
||||
) > 0,
|
||||
"SELECT 1",
|
||||
CONCAT( "ALTER TABLE ", @tablename, " ADD ", @columnname, " varchar(32) DEFAULT NULL COMMENT '组织ID';" )
|
||||
)
|
||||
);
|
||||
PREPARE alterIfNotExists
|
||||
FROM
|
||||
@preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
Loading…
x
Reference in New Issue
Block a user