mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
#58 merge code.
This commit is contained in:
commit
e42eebe282
@ -17,6 +17,7 @@
|
||||
package com.chatopera.cc.webim.web.handler;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
@ -25,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.chatopera.cc.core.UKDataContext;
|
||||
import com.chatopera.cc.util.UKView;
|
||||
import com.chatopera.cc.util.exception.CSKefuException;
|
||||
import com.chatopera.cc.webim.service.cache.CacheHelper;
|
||||
import com.chatopera.cc.webim.service.repository.TenantRepository;
|
||||
import com.chatopera.cc.webim.web.handler.api.rest.QueryParams;
|
||||
@ -36,6 +38,8 @@ import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.QueryStringQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryStringQueryBuilder.Operator;
|
||||
import org.elasticsearch.index.query.RangeQueryBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
@ -49,6 +53,8 @@ import com.chatopera.cc.webim.web.model.SystemConfig;
|
||||
@Controller
|
||||
@SessionAttributes
|
||||
public class Handler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Handler.class);
|
||||
|
||||
@Autowired
|
||||
private TenantRepository tenantRes;
|
||||
|
||||
@ -85,6 +91,32 @@ public class Handler {
|
||||
}
|
||||
return user ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建ElasticSearch基于部门查询的Filter
|
||||
* @param request
|
||||
* @param boolQueryBuilder
|
||||
* @return
|
||||
* @throws CSKefuException
|
||||
*/
|
||||
public boolean esOrganFilter(final HttpServletRequest request, final BoolQueryBuilder boolQueryBuilder) throws CSKefuException {
|
||||
// 组合部门条件
|
||||
User u = getUser(request);
|
||||
if( u == null){
|
||||
throw new CSKefuException("[esOrganFilter] 未能获取到登录用户。");
|
||||
} else if(u.isSuperuser()){
|
||||
// 超级管理员, 查看任何数据
|
||||
return true;
|
||||
} else if(u.getMyorgans().size() == 0){
|
||||
// 用户没有被分配到部门,返回空数据
|
||||
return false;
|
||||
} else {
|
||||
// 用户在部门中,通过部门过滤数据
|
||||
String[] values = u.getMyorgans().toArray(new String[u.getMyorgans().size()]);
|
||||
boolQueryBuilder.filter(termsQuery("organ", values));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@ -253,8 +285,6 @@ public class Handler {
|
||||
return user ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setUser(HttpServletRequest request , User user){
|
||||
request.getSession(true).removeAttribute(UKDataContext.USER_SESSION_NAME) ;
|
||||
request.getSession(true).setAttribute(UKDataContext.USER_SESSION_NAME , user) ;
|
||||
|
@ -16,10 +16,26 @@
|
||||
*/
|
||||
package com.chatopera.cc.webim.web.handler;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.chatopera.cc.core.UKDataContext;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.util.UKTools;
|
||||
import com.chatopera.cc.webim.service.cache.CacheHelper;
|
||||
import com.chatopera.cc.webim.service.repository.OrganRepository;
|
||||
import com.chatopera.cc.webim.service.repository.RoleAuthRepository;
|
||||
import com.chatopera.cc.webim.service.repository.UserRepository;
|
||||
import com.chatopera.cc.webim.service.repository.UserRoleRepository;
|
||||
import com.chatopera.cc.webim.util.OnlineUserUtils;
|
||||
import com.chatopera.cc.webim.web.model.*;
|
||||
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.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
@ -29,281 +45,265 @@ import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.chatopera.cc.core.UKDataContext;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.webim.service.cache.CacheHelper;
|
||||
import com.chatopera.cc.webim.service.repository.OrganRepository;
|
||||
import com.chatopera.cc.webim.service.repository.OrganRoleRepository;
|
||||
import com.chatopera.cc.webim.service.repository.RoleAuthRepository;
|
||||
import com.chatopera.cc.webim.service.repository.UserRoleRepository;
|
||||
import com.chatopera.cc.webim.util.OnlineUserUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.chatopera.cc.util.UKTools;
|
||||
import com.chatopera.cc.webim.service.repository.UserRepository;
|
||||
import com.chatopera.cc.webim.web.model.Organ;
|
||||
import com.chatopera.cc.webim.web.model.OrganRole;
|
||||
import com.chatopera.cc.webim.web.model.Role;
|
||||
import com.chatopera.cc.webim.web.model.RoleAuth;
|
||||
import com.chatopera.cc.webim.web.model.SystemConfig;
|
||||
import com.chatopera.cc.webim.web.model.User;
|
||||
import com.chatopera.cc.webim.web.model.UserRole;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author UK
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class LoginController extends Handler{
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private OrganRoleRepository organRoleRes ;
|
||||
|
||||
@Autowired
|
||||
private UserRoleRepository userRoleRes ;
|
||||
|
||||
@Autowired
|
||||
private RoleAuthRepository roleAuthRes ;
|
||||
|
||||
@Autowired
|
||||
private OrganRepository organRepository;
|
||||
public class LoginController extends Handler {
|
||||
private final static Logger logger = LoggerFactory.getLogger(LoginController.class);
|
||||
|
||||
@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) throws NoSuchAlgorithmException {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
|
||||
if(request.getSession(true).getAttribute(UKDataContext.USER_SESSION_NAME) ==null){
|
||||
view = request(super.createRequestPageTempletResponse("/login"));
|
||||
if(!StringUtils.isBlank(request.getParameter("referer"))){
|
||||
referer = request.getParameter("referer") ;
|
||||
}
|
||||
if(!StringUtils.isBlank(referer)){
|
||||
view.addObject("referer", referer) ;
|
||||
}
|
||||
Cookie[] cookies = request.getCookies();//这样便可以获取一个cookie数组
|
||||
if(cookies!=null) {
|
||||
for(Cookie cookie : cookies){
|
||||
if(cookie!=null && !StringUtils.isBlank(cookie.getName()) && !StringUtils.isBlank(cookie.getValue())){
|
||||
if(cookie.getName().equals(UKDataContext.UKEFU_SYSTEM_COOKIES_FLAG)){
|
||||
String flagid = UKTools.decryption(cookie.getValue());
|
||||
if(!StringUtils.isBlank(flagid)) {
|
||||
User user = userRepository.findById(flagid) ;
|
||||
if(user!=null) {
|
||||
view = this.processLogin(request, response, view, user, referer) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!StringUtils.isBlank(msg)){
|
||||
view.addObject("msg", msg) ;
|
||||
}
|
||||
SystemConfig systemConfig = UKTools.getSystemConfig();
|
||||
if(systemConfig!=null&&systemConfig.isEnableregorgi()) {
|
||||
view.addObject("show", true);
|
||||
}
|
||||
if(systemConfig != null){
|
||||
view.addObject("systemConfig", systemConfig) ;
|
||||
}
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private UserRoleRepository userRoleRes;
|
||||
|
||||
@Autowired
|
||||
private RoleAuthRepository roleAuthRes;
|
||||
|
||||
@Autowired
|
||||
private OrganRepository organRepository;
|
||||
|
||||
/**
|
||||
* 获取一个用户所拥有的所有部门ID
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
private void organs(final User user, final String organ) {
|
||||
if (organ == null)
|
||||
return;
|
||||
user.getMyorgans().add(organ);
|
||||
List<Organ> y = organRepository.findByOrgiAndParent(user.getOrgi(), organ);
|
||||
for (Organ x : y) {
|
||||
organs(user, x.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@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) throws NoSuchAlgorithmException {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
|
||||
if (request.getSession(true).getAttribute(UKDataContext.USER_SESSION_NAME) == null) {
|
||||
view = request(super.createRequestPageTempletResponse("/login"));
|
||||
if (!StringUtils.isBlank(request.getParameter("referer"))) {
|
||||
referer = request.getParameter("referer");
|
||||
}
|
||||
if (!StringUtils.isBlank(referer)) {
|
||||
view.addObject("referer", referer);
|
||||
}
|
||||
Cookie[] cookies = request.getCookies();//这样便可以获取一个cookie数组
|
||||
if (cookies != null) {
|
||||
for (Cookie cookie : cookies) {
|
||||
if (cookie != null && !StringUtils.isBlank(cookie.getName()) && !StringUtils.isBlank(cookie.getValue())) {
|
||||
if (cookie.getName().equals(UKDataContext.UKEFU_SYSTEM_COOKIES_FLAG)) {
|
||||
String flagid = UKTools.decryption(cookie.getValue());
|
||||
if (!StringUtils.isBlank(flagid)) {
|
||||
User user = userRepository.findById(flagid);
|
||||
if (user != null) {
|
||||
view = this.processLogin(request, response, view, user, referer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isBlank(msg)) {
|
||||
view.addObject("msg", msg);
|
||||
}
|
||||
SystemConfig systemConfig = UKTools.getSystemConfig();
|
||||
if (systemConfig != null && systemConfig.isEnableregorgi()) {
|
||||
view.addObject("show", true);
|
||||
}
|
||||
if (systemConfig != null) {
|
||||
view.addObject("systemConfig", systemConfig);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/login" , method=RequestMethod.POST)
|
||||
@Menu(type = "apps" , subtype = "user" , access = true)
|
||||
public ModelAndView login(HttpServletRequest request, HttpServletResponse response , @Valid User user ,@Valid String referer,@Valid String sla) throws NoSuchAlgorithmException {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
|
||||
if(request.getSession(true).getAttribute(UKDataContext.USER_SESSION_NAME) ==null){
|
||||
if(user!=null && user.getUsername()!=null){
|
||||
final User loginUser = userRepository.findByUsernameAndPasswordAndDatastatus(user.getUsername() , UKTools.md5(user.getPassword()),false) ;
|
||||
if(loginUser!=null && !StringUtils.isBlank(loginUser.getId())){
|
||||
view = this.processLogin(request, response, view, loginUser, referer) ;
|
||||
if(!StringUtils.isBlank(sla) && sla.equals("1")) {
|
||||
Cookie flagid = new Cookie(UKDataContext.UKEFU_SYSTEM_COOKIES_FLAG,UKTools.encryption(loginUser.getId()));
|
||||
flagid.setMaxAge(7*24*60*60);
|
||||
response.addCookie(flagid);
|
||||
// add authorization code for rest api
|
||||
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
||||
@Menu(type = "apps", subtype = "user", access = true)
|
||||
public ModelAndView login(HttpServletRequest request, HttpServletResponse response, @Valid User user, @Valid String referer, @Valid String sla) throws NoSuchAlgorithmException {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
|
||||
if (request.getSession(true).getAttribute(UKDataContext.USER_SESSION_NAME) == null) {
|
||||
if (user != null && user.getUsername() != null) {
|
||||
final User loginUser = userRepository.findByUsernameAndPasswordAndDatastatus(user.getUsername(), UKTools.md5(user.getPassword()), false);
|
||||
if (loginUser != null && !StringUtils.isBlank(loginUser.getId())) {
|
||||
view = this.processLogin(request, response, view, loginUser, referer);
|
||||
if (!StringUtils.isBlank(sla) && sla.equals("1")) {
|
||||
Cookie flagid = new Cookie(UKDataContext.UKEFU_SYSTEM_COOKIES_FLAG, UKTools.encryption(loginUser.getId()));
|
||||
flagid.setMaxAge(7 * 24 * 60 * 60);
|
||||
response.addCookie(flagid);
|
||||
// add authorization code for rest api
|
||||
String auth = UKTools.getUUID();
|
||||
CacheHelper.getApiUserCacheBean().put(auth, loginUser, UKDataContext.SYSTEM_ORGI);
|
||||
response.addCookie((new Cookie("authorization", auth)));
|
||||
}
|
||||
}else{
|
||||
view = request(super.createRequestPageTempletResponse("/login"));
|
||||
if(!StringUtils.isBlank(referer)){
|
||||
view.addObject("referer", referer) ;
|
||||
}
|
||||
view.addObject("msg", "0") ;
|
||||
}
|
||||
}
|
||||
}
|
||||
SystemConfig systemConfig = UKTools.getSystemConfig();
|
||||
if(systemConfig!=null&&systemConfig.isEnableregorgi()) {
|
||||
view.addObject("show", true);
|
||||
}
|
||||
if(systemConfig != null){
|
||||
view.addObject("systemConfig", systemConfig) ;
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
private ModelAndView processLogin(HttpServletRequest request, HttpServletResponse response , ModelAndView view ,final User loginUser , String referer) {
|
||||
if(loginUser!=null) {
|
||||
loginUser.setLogin(true);
|
||||
if(!StringUtils.isBlank(referer)){
|
||||
view = request(super.createRequestPageTempletResponse("redirect:"+referer));
|
||||
}else {
|
||||
view = request(super.createRequestPageTempletResponse("redirect:/"));
|
||||
}
|
||||
//登录成功 判断是否进入多租户页面
|
||||
SystemConfig systemConfig = UKTools.getSystemConfig();
|
||||
if(systemConfig!=null&&systemConfig.isEnabletneant() && systemConfig.isTenantconsole() &&!loginUser.isSuperuser()) {
|
||||
view = request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index"));
|
||||
}
|
||||
List<UserRole> userRoleList = userRoleRes.findByOrgiAndUser(loginUser.getOrgi(), loginUser);
|
||||
if(userRoleList!=null && userRoleList.size()>0){
|
||||
for(UserRole userRole : userRoleList){
|
||||
loginUser.getRoleList().add(userRole.getRole()) ;
|
||||
}
|
||||
}
|
||||
if(!StringUtils.isBlank(loginUser.getOrgan())){
|
||||
Organ organ = organRepository.findByIdAndOrgi(loginUser.getOrgan(), loginUser.getOrgi()) ;
|
||||
if(organ!=null){
|
||||
List<OrganRole> organRoleList = organRoleRes.findByOrgiAndOrgan(loginUser.getOrgi(), organ) ;
|
||||
if(organRoleList.size() > 0){
|
||||
for(OrganRole organRole : organRoleList){
|
||||
loginUser.getRoleAuthMap().put(organRole.getDicvalue(),true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//获取用户的授权资源
|
||||
List<RoleAuth> roleAuthList = roleAuthRes.findAll(new Specification<RoleAuth>(){
|
||||
@Override
|
||||
public Predicate toPredicate(Root<RoleAuth> root, CriteriaQuery<?> query,
|
||||
CriteriaBuilder cb) {
|
||||
List<Predicate> list = new ArrayList<Predicate>();
|
||||
if(loginUser.getRoleList()!=null && loginUser.getRoleList().size() > 0){
|
||||
for(Role role : loginUser.getRoleList()){
|
||||
list.add(cb.equal(root.get("roleid").as(String.class), role.getId())) ;
|
||||
}
|
||||
}
|
||||
Predicate[] p = new Predicate[list.size()];
|
||||
cb.and(cb.equal(root.get("orgi").as(String.class), loginUser.getOrgi())) ;
|
||||
return cb.or(list.toArray(p));
|
||||
}}) ;
|
||||
if(roleAuthList!=null) {
|
||||
for(RoleAuth roleAuth:roleAuthList) {
|
||||
loginUser.getRoleAuthMap().put(roleAuth.getDicvalue(), true);
|
||||
}
|
||||
}
|
||||
|
||||
loginUser.setLastlogintime(new Date());
|
||||
if(!StringUtils.isBlank(loginUser.getId())){
|
||||
userRepository.save(loginUser) ;
|
||||
}
|
||||
super.setUser(request, loginUser);
|
||||
//当前用户 企业id为空 调到创建企业页面
|
||||
if(StringUtils.isBlank(loginUser.getOrgid())) {
|
||||
view = request(super.createRequestPageTempletResponse("redirect:/apps/organization/add.html"));
|
||||
}
|
||||
}
|
||||
return view ;
|
||||
}
|
||||
|
||||
@RequestMapping("/logout")
|
||||
public String logout(HttpServletRequest request , HttpServletResponse response){
|
||||
request.getSession().removeAttribute(UKDataContext.USER_SESSION_NAME) ;
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if(cookies!=null) {
|
||||
for(Cookie cookie : cookies){
|
||||
if(cookie!=null && !StringUtils.isBlank(cookie.getName()) && !StringUtils.isBlank(cookie.getValue())){
|
||||
if(cookie.getName().equals(UKDataContext.UKEFU_SYSTEM_COOKIES_FLAG)){
|
||||
cookie.setMaxAge(0);
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "redirect:/";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/register" )
|
||||
@Menu(type = "apps" , subtype = "user" , access = true)
|
||||
public ModelAndView register(HttpServletRequest request, HttpServletResponse response,@Valid String msg) {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
|
||||
if(request.getSession(true).getAttribute(UKDataContext.USER_SESSION_NAME) ==null){
|
||||
view = request(super.createRequestPageTempletResponse("/register"));
|
||||
}
|
||||
if(!StringUtils.isBlank(msg)){
|
||||
view.addObject("msg", msg) ;
|
||||
}
|
||||
response.addCookie((new Cookie("authorization", auth)));
|
||||
}
|
||||
} else {
|
||||
view = request(super.createRequestPageTempletResponse("/login"));
|
||||
if (!StringUtils.isBlank(referer)) {
|
||||
view.addObject("referer", referer);
|
||||
}
|
||||
view.addObject("msg", "0");
|
||||
}
|
||||
}
|
||||
}
|
||||
SystemConfig systemConfig = UKTools.getSystemConfig();
|
||||
if (systemConfig != null && systemConfig.isEnableregorgi()) {
|
||||
view.addObject("show", true);
|
||||
}
|
||||
if (systemConfig != null) {
|
||||
view.addObject("systemConfig", systemConfig);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
private ModelAndView processLogin(HttpServletRequest request, HttpServletResponse response, ModelAndView view, final User loginUser, String referer) {
|
||||
if (loginUser != null) {
|
||||
loginUser.setLogin(true);
|
||||
if (!StringUtils.isBlank(referer)) {
|
||||
view = request(super.createRequestPageTempletResponse("redirect:" + referer));
|
||||
} else {
|
||||
view = request(super.createRequestPageTempletResponse("redirect:/"));
|
||||
}
|
||||
//登录成功 判断是否进入多租户页面
|
||||
SystemConfig systemConfig = UKTools.getSystemConfig();
|
||||
if (systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantconsole() && !loginUser.isSuperuser()) {
|
||||
view = request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index"));
|
||||
}
|
||||
List<UserRole> userRoleList = userRoleRes.findByOrgiAndUser(loginUser.getOrgi(), loginUser);
|
||||
if (userRoleList != null && userRoleList.size() > 0) {
|
||||
for (UserRole userRole : userRoleList) {
|
||||
loginUser.getRoleList().add(userRole.getRole());
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用户部门以及下级部门
|
||||
organs(loginUser, loginUser.getOrgan()); // 添加部门到myorgans中
|
||||
|
||||
// 获取用户的角色权限,进行授权
|
||||
List<RoleAuth> roleAuthList = roleAuthRes.findAll(new Specification<RoleAuth>() {
|
||||
@Override
|
||||
public Predicate toPredicate(Root<RoleAuth> root, CriteriaQuery<?> query,
|
||||
CriteriaBuilder cb) {
|
||||
List<Predicate> list = new ArrayList<Predicate>();
|
||||
if (loginUser.getRoleList() != null && loginUser.getRoleList().size() > 0) {
|
||||
for (Role role : loginUser.getRoleList()) {
|
||||
list.add(cb.equal(root.get("roleid").as(String.class), role.getId()));
|
||||
}
|
||||
}
|
||||
Predicate[] p = new Predicate[list.size()];
|
||||
cb.and(cb.equal(root.get("orgi").as(String.class), loginUser.getOrgi()));
|
||||
return cb.or(list.toArray(p));
|
||||
}
|
||||
});
|
||||
|
||||
if (roleAuthList != null) {
|
||||
for (RoleAuth roleAuth : roleAuthList) {
|
||||
loginUser.getRoleAuthMap().put(roleAuth.getDicvalue(), true);
|
||||
}
|
||||
}
|
||||
|
||||
loginUser.setLastlogintime(new Date());
|
||||
if (!StringUtils.isBlank(loginUser.getId())) {
|
||||
userRepository.save(loginUser);
|
||||
}
|
||||
|
||||
super.setUser(request, loginUser);
|
||||
//当前用户 企业id为空 调到创建企业页面
|
||||
if (StringUtils.isBlank(loginUser.getOrgid())) {
|
||||
view = request(super.createRequestPageTempletResponse("redirect:/apps/organization/add.html"));
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@RequestMapping("/logout")
|
||||
public String logout(HttpServletRequest request, HttpServletResponse response) {
|
||||
request.getSession().removeAttribute(UKDataContext.USER_SESSION_NAME);
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if (cookies != null) {
|
||||
for (Cookie cookie : cookies) {
|
||||
if (cookie != null && !StringUtils.isBlank(cookie.getName()) && !StringUtils.isBlank(cookie.getValue())) {
|
||||
if (cookie.getName().equals(UKDataContext.UKEFU_SYSTEM_COOKIES_FLAG)) {
|
||||
cookie.setMaxAge(0);
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "redirect:/";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/register")
|
||||
@Menu(type = "apps", subtype = "user", access = true)
|
||||
public ModelAndView register(HttpServletRequest request, HttpServletResponse response, @Valid String msg) {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
|
||||
if (request.getSession(true).getAttribute(UKDataContext.USER_SESSION_NAME) == null) {
|
||||
view = request(super.createRequestPageTempletResponse("/register"));
|
||||
}
|
||||
if (!StringUtils.isBlank(msg)) {
|
||||
view.addObject("msg", msg);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@RequestMapping("/addAdmin")
|
||||
@Menu(type = "apps" , subtype = "user",access=true)
|
||||
public ModelAndView addAdmin(HttpServletRequest request ,HttpServletResponse response,@Valid User user) {
|
||||
String msg = "" ;
|
||||
msg = validUser(user);
|
||||
if(!StringUtils.isBlank(msg)){
|
||||
return request(super.createRequestPageTempletResponse("redirect:/register.html?msg="+msg));
|
||||
}else{
|
||||
user.setUname(user.getUsername());
|
||||
user.setUsertype("0");
|
||||
if(!StringUtils.isBlank(user.getPassword())){
|
||||
user.setPassword(UKTools.md5(user.getPassword()));
|
||||
}
|
||||
user.setOrgi(super.getOrgiByTenantshare(request));
|
||||
@Menu(type = "apps", subtype = "user", access = true)
|
||||
public ModelAndView addAdmin(HttpServletRequest request, HttpServletResponse response, @Valid User user) {
|
||||
String msg = "";
|
||||
msg = validUser(user);
|
||||
if (!StringUtils.isBlank(msg)) {
|
||||
return request(super.createRequestPageTempletResponse("redirect:/register.html?msg=" + msg));
|
||||
} else {
|
||||
user.setUname(user.getUsername());
|
||||
user.setUsertype("0");
|
||||
if (!StringUtils.isBlank(user.getPassword())) {
|
||||
user.setPassword(UKTools.md5(user.getPassword()));
|
||||
}
|
||||
user.setOrgi(super.getOrgiByTenantshare(request));
|
||||
/*if(!StringUtils.isBlank(super.getUser(request).getOrgid())) {
|
||||
user.setOrgid(super.getUser(request).getOrgid());
|
||||
}else {
|
||||
user.setOrgid(UKDataContext.SYSTEM_ORGI);
|
||||
}*/
|
||||
userRepository.save(user) ;
|
||||
OnlineUserUtils.clean(super.getOrgi(request));
|
||||
|
||||
}
|
||||
ModelAndView view = this.processLogin(request, response, request(super.createRequestPageTempletResponse("redirect:/")), user, "");
|
||||
//当前用户 企业id为空 调到创建企业页面
|
||||
if(StringUtils.isBlank(user.getOrgid())) {
|
||||
view = request(super.createRequestPageTempletResponse("redirect:/apps/organization/add.html"));
|
||||
}
|
||||
return view;
|
||||
userRepository.save(user);
|
||||
OnlineUserUtils.clean(super.getOrgi(request));
|
||||
|
||||
}
|
||||
ModelAndView view = this.processLogin(request, response, request(super.createRequestPageTempletResponse("redirect:/")), user, "");
|
||||
//当前用户 企业id为空 调到创建企业页面
|
||||
if (StringUtils.isBlank(user.getOrgid())) {
|
||||
view = request(super.createRequestPageTempletResponse("redirect:/apps/organization/add.html"));
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
private String validUser(User user) {
|
||||
String msg = "";
|
||||
User tempUser = userRepository.findByUsernameAndDatastatus(user.getUsername(),false) ;
|
||||
if(tempUser!=null) {
|
||||
msg = "username_exist";
|
||||
return msg;
|
||||
}
|
||||
tempUser = userRepository.findByEmailAndDatastatus(user.getEmail(),false) ;
|
||||
if(tempUser!=null) {
|
||||
msg = "email_exist";
|
||||
return msg;
|
||||
}
|
||||
tempUser = userRepository.findByMobileAndDatastatus(user.getMobile(),false) ;
|
||||
if(tempUser!=null) {
|
||||
msg = "mobile_exist";
|
||||
return msg;
|
||||
}
|
||||
return msg;
|
||||
String msg = "";
|
||||
User tempUser = userRepository.findByUsernameAndDatastatus(user.getUsername(), false);
|
||||
if (tempUser != null) {
|
||||
msg = "username_exist";
|
||||
return msg;
|
||||
}
|
||||
tempUser = userRepository.findByEmailAndDatastatus(user.getEmail(), false);
|
||||
if (tempUser != null) {
|
||||
msg = "email_exist";
|
||||
return msg;
|
||||
}
|
||||
tempUser = userRepository.findByMobileAndDatastatus(user.getMobile(), false);
|
||||
if (tempUser != null) {
|
||||
msg = "mobile_exist";
|
||||
return msg;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -316,26 +316,7 @@ public class OrganController extends Handler{
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?msg="+msg));
|
||||
}
|
||||
|
||||
@RequestMapping("/auth")
|
||||
@Menu(type = "admin" , subtype = "organ")
|
||||
public ModelAndView auth(ModelMap map ,HttpServletRequest request , @Valid String id) {
|
||||
|
||||
SysDic sysDic = sysDicRes.findByCode(UKDataContext.UKEFU_SYSTEM_AUTH_DIC) ;
|
||||
if(sysDic!=null){
|
||||
map.addAttribute("resourceList", sysDicRes.findByDicid(sysDic.getId())) ;
|
||||
}
|
||||
|
||||
map.addAttribute("sysDic", sysDic) ;
|
||||
Organ organData = organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)) ;
|
||||
map.addAttribute("organData", organData) ;
|
||||
map.addAttribute("roleList", roleRepository.findByOrgiAndOrgid(super.getOrgiByTenantshare(request),super.getOrgid(request))) ;
|
||||
|
||||
map.addAttribute("organRoleList", organRoleRes.findByOrgiAndOrgan(super.getOrgiByTenantshare(request), organData)) ;
|
||||
|
||||
return request(super.createRequestPageTempletResponse("/admin/organ/auth"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/auth/save")
|
||||
@Menu(type = "admin" , subtype = "role")
|
||||
public ModelAndView authsave(HttpServletRequest request ,@Valid String id ,@Valid String menus) {
|
||||
|
@ -217,6 +217,7 @@ public class AppsController extends Handler {
|
||||
User sessionUser = super.getUser(request) ;
|
||||
tempUser.setRoleList(sessionUser.getRoleList()) ;
|
||||
tempUser.setRoleAuthMap(sessionUser.getRoleAuthMap());
|
||||
tempUser.setMyorgans(sessionUser.getMyorgans());
|
||||
User u = tempUser;
|
||||
u.setOrgi(super.getOrgi(request));
|
||||
super.setUser(request, u);
|
||||
|
@ -17,29 +17,28 @@
|
||||
|
||||
package com.chatopera.cc.webim.web.handler.apps.contacts;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.util.PinYinTools;
|
||||
import com.chatopera.cc.util.UKTools;
|
||||
import com.chatopera.cc.util.exception.CSKefuException;
|
||||
import com.chatopera.cc.util.task.DSData;
|
||||
import com.chatopera.cc.util.task.DSDataEvent;
|
||||
import com.chatopera.cc.util.task.ExcelImportProecess;
|
||||
import com.chatopera.cc.util.task.export.ExcelExporterProcess;
|
||||
import com.chatopera.cc.util.task.process.ContactsProcess;
|
||||
import com.chatopera.cc.webim.service.es.ContactsRepository;
|
||||
import com.chatopera.cc.webim.service.repository.MetadataRepository;
|
||||
import com.chatopera.cc.webim.service.repository.PropertiesEventRepository;
|
||||
import com.chatopera.cc.webim.service.repository.ReporterRepository;
|
||||
import com.chatopera.cc.webim.util.PropertiesEventUtils;
|
||||
import com.chatopera.cc.webim.web.handler.Handler;
|
||||
import com.chatopera.cc.webim.web.model.*;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
@ -50,361 +49,366 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.chatopera.cc.util.UKTools;
|
||||
import com.chatopera.cc.util.task.DSData;
|
||||
import com.chatopera.cc.util.task.DSDataEvent;
|
||||
import com.chatopera.cc.util.task.ExcelImportProecess;
|
||||
import com.chatopera.cc.util.task.export.ExcelExporterProcess;
|
||||
import com.chatopera.cc.util.task.process.ContactsProcess;
|
||||
import com.chatopera.cc.webim.service.es.ContactsRepository;
|
||||
import com.chatopera.cc.webim.service.repository.MetadataRepository;
|
||||
import com.chatopera.cc.webim.service.repository.ReporterRepository;
|
||||
import com.chatopera.cc.webim.web.handler.Handler;
|
||||
import com.chatopera.cc.webim.web.model.Contacts;
|
||||
import com.chatopera.cc.webim.web.model.MetadataTable;
|
||||
import com.chatopera.cc.webim.web.model.PropertiesEvent;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/apps/contacts")
|
||||
public class ContactsController extends Handler{
|
||||
|
||||
@Autowired
|
||||
private ContactsRepository contactsRes ;
|
||||
|
||||
@Autowired
|
||||
private PropertiesEventRepository propertiesEventRes ;
|
||||
|
||||
@Autowired
|
||||
private ReporterRepository reporterRes ;
|
||||
|
||||
@Autowired
|
||||
private MetadataRepository metadataRes ;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
public class ContactsController extends Handler {
|
||||
private final static Logger logger = LoggerFactory.getLogger(ContactsController.class);
|
||||
|
||||
@Autowired
|
||||
private ContactsRepository contactsRes;
|
||||
|
||||
@Autowired
|
||||
private PropertiesEventRepository propertiesEventRes;
|
||||
|
||||
@Autowired
|
||||
private ReporterRepository reporterRes;
|
||||
|
||||
@Autowired
|
||||
private MetadataRepository metadataRes;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
|
||||
|
||||
@RequestMapping("/index")
|
||||
@Menu(type = "customer" , subtype = "index")
|
||||
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String q , @Valid String ckind) {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
if(!StringUtils.isBlank(q)){
|
||||
map.put("q", q) ;
|
||||
@Menu(type = "customer", subtype = "index")
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ckind) throws CSKefuException {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
|
||||
if(!super.esOrganFilter(request, boolQueryBuilder)){
|
||||
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
|
||||
}
|
||||
if(!StringUtils.isBlank(ckind)){
|
||||
boolQueryBuilder.must(termQuery("ckind" , ckind)) ;
|
||||
map.put("ckind", ckind) ;
|
||||
|
||||
if (!StringUtils.isBlank(q)) {
|
||||
map.put("q", q);
|
||||
}
|
||||
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(),super.getOrgi(request), null , null , false, boolQueryBuilder ,q , new PageRequest(super.getP(request) , super.getPs(request)))) ;
|
||||
|
||||
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
|
||||
}
|
||||
|
||||
@RequestMapping("/today")
|
||||
@Menu(type = "customer" , subtype = "today")
|
||||
public ModelAndView today(ModelMap map , HttpServletRequest request , @Valid String q , @Valid String ckind) {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
if(!StringUtils.isBlank(q)){
|
||||
map.put("q", q) ;
|
||||
|
||||
if (!StringUtils.isBlank(ckind)) {
|
||||
boolQueryBuilder.must(termQuery("ckind", ckind));
|
||||
map.put("ckind", ckind);
|
||||
}
|
||||
if(!StringUtils.isBlank(ckind)){
|
||||
boolQueryBuilder.must(termQuery("ckind" , ckind)) ;
|
||||
map.put("ckind", ckind) ;
|
||||
}
|
||||
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request),UKTools.getStartTime() , null , false, boolQueryBuilder ,q , new PageRequest(super.getP(request) , super.getPs(request)))) ;
|
||||
|
||||
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
|
||||
}
|
||||
|
||||
@RequestMapping("/week")
|
||||
@Menu(type = "customer" , subtype = "week")
|
||||
public ModelAndView week(ModelMap map , HttpServletRequest request , @Valid String q , @Valid String ckind) {
|
||||
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
if(!StringUtils.isBlank(q)){
|
||||
map.put("q", q) ;
|
||||
}
|
||||
if(!StringUtils.isBlank(ckind)){
|
||||
boolQueryBuilder.must(termQuery("ckind" , ckind)) ;
|
||||
map.put("ckind", ckind) ;
|
||||
}
|
||||
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(),super.getOrgi(request), UKTools.getWeekStartTime() , null , false, boolQueryBuilder ,q , new PageRequest(super.getP(request) , super.getPs(request)))) ;
|
||||
|
||||
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
|
||||
}
|
||||
|
||||
@RequestMapping("/creater")
|
||||
@Menu(type = "customer" , subtype = "creater")
|
||||
public ModelAndView creater(ModelMap map , HttpServletRequest request , @Valid String q , @Valid String ckind) {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
boolQueryBuilder.must(termQuery("creater" , super.getUser(request).getId())) ;
|
||||
|
||||
if(!StringUtils.isBlank(ckind)){
|
||||
boolQueryBuilder.must(termQuery("ckind" , ckind)) ;
|
||||
map.put("ckind", ckind) ;
|
||||
}
|
||||
if(!StringUtils.isBlank(q)){
|
||||
map.put("q", q) ;
|
||||
}
|
||||
|
||||
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(),super.getOrgi(request), null , null , false, boolQueryBuilder ,q , new PageRequest(super.getP(request) , super.getPs(request)))) ;
|
||||
|
||||
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), null, null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request))));
|
||||
|
||||
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@Menu(type = "contacts" , subtype = "contacts")
|
||||
public ModelAndView delete(HttpServletRequest request ,@Valid Contacts contacts ,@Valid String p) {
|
||||
if(contacts!=null){
|
||||
contacts = contactsRes.findOne(contacts.getId()) ;
|
||||
contacts.setDatastatus(true); //客户和联系人都是 逻辑删除
|
||||
contactsRes.save(contacts) ;
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/index.html?p="+p+"&ckind="+contacts.getCkind()));
|
||||
|
||||
@RequestMapping("/today")
|
||||
@Menu(type = "customer", subtype = "today")
|
||||
public ModelAndView today(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ckind) {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
if (!StringUtils.isBlank(q)) {
|
||||
map.put("q", q);
|
||||
}
|
||||
if (!StringUtils.isBlank(ckind)) {
|
||||
boolQueryBuilder.must(termQuery("ckind", ckind));
|
||||
map.put("ckind", ckind);
|
||||
}
|
||||
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), UKTools.getStartTime(), null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request))));
|
||||
|
||||
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/week")
|
||||
@Menu(type = "customer", subtype = "week")
|
||||
public ModelAndView week(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ckind) {
|
||||
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
if (!StringUtils.isBlank(q)) {
|
||||
map.put("q", q);
|
||||
}
|
||||
if (!StringUtils.isBlank(ckind)) {
|
||||
boolQueryBuilder.must(termQuery("ckind", ckind));
|
||||
map.put("ckind", ckind);
|
||||
}
|
||||
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), UKTools.getWeekStartTime(), null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request))));
|
||||
|
||||
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
|
||||
}
|
||||
|
||||
@RequestMapping("/creater")
|
||||
@Menu(type = "customer", subtype = "creater")
|
||||
public ModelAndView creater(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ckind) {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
boolQueryBuilder.must(termQuery("creater", super.getUser(request).getId()));
|
||||
|
||||
if (!StringUtils.isBlank(ckind)) {
|
||||
boolQueryBuilder.must(termQuery("ckind", ckind));
|
||||
map.put("ckind", ckind);
|
||||
}
|
||||
if (!StringUtils.isBlank(q)) {
|
||||
map.put("q", q);
|
||||
}
|
||||
|
||||
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), null, null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request))));
|
||||
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@Menu(type = "contacts", subtype = "contacts")
|
||||
public ModelAndView delete(HttpServletRequest request, @Valid Contacts contacts, @Valid String p) {
|
||||
if (contacts != null) {
|
||||
contacts = contactsRes.findOne(contacts.getId());
|
||||
contacts.setDatastatus(true); //客户和联系人都是 逻辑删除
|
||||
contactsRes.save(contacts);
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/index.html?p=" + p + "&ckind=" + contacts.getCkind()));
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
@Menu(type = "contacts" , subtype = "add")
|
||||
public ModelAndView add(ModelMap map , HttpServletRequest request,@Valid String ckind) {
|
||||
map.addAttribute("ckind",ckind);
|
||||
@Menu(type = "contacts", subtype = "add")
|
||||
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String ckind) {
|
||||
map.addAttribute("ckind", ckind);
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/contacts/add"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/save")
|
||||
@Menu(type = "contacts" , subtype = "save")
|
||||
public ModelAndView save(HttpServletRequest request , @Valid Contacts contacts) {
|
||||
contacts.setCreater(super.getUser(request).getId());
|
||||
contacts.setOrgi(super.getOrgi(request));
|
||||
contacts.setOrgan(super.getUser(request).getOrgan());
|
||||
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
|
||||
if(StringUtils.isBlank(contacts.getCusbirthday())) {
|
||||
contacts.setCusbirthday(null);
|
||||
}
|
||||
contactsRes.save(contacts) ;
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/index.html?ckind="+contacts.getCkind()));
|
||||
@Menu(type = "contacts", subtype = "save")
|
||||
public ModelAndView save(HttpServletRequest request, @Valid Contacts contacts) {
|
||||
contacts.setCreater(super.getUser(request).getId());
|
||||
contacts.setOrgi(super.getOrgi(request));
|
||||
contacts.setOrgan(super.getUser(request).getOrgan());
|
||||
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
|
||||
if (StringUtils.isBlank(contacts.getCusbirthday())) {
|
||||
contacts.setCusbirthday(null);
|
||||
}
|
||||
contactsRes.save(contacts);
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/index.html?ckind=" + contacts.getCkind()));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/edit")
|
||||
@Menu(type = "contacts" , subtype = "contacts")
|
||||
public ModelAndView edit(ModelMap map , HttpServletRequest request , @Valid String id) {
|
||||
map.addAttribute("contacts", contactsRes.findOne(id));
|
||||
@Menu(type = "contacts", subtype = "contacts")
|
||||
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
|
||||
map.addAttribute("contacts", contactsRes.findOne(id));
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/contacts/edit"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/detail")
|
||||
@Menu(type = "customer" , subtype = "index")
|
||||
public ModelAndView detail(ModelMap map , HttpServletRequest request , @Valid String id) {
|
||||
map.addAttribute("contacts", contactsRes.findOne(id)) ;
|
||||
return request(super.createAppsTempletResponse("/apps/business/contacts/detail"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping( "/update")
|
||||
@Menu(type = "contacts" , subtype = "contacts")
|
||||
public ModelAndView update(HttpServletRequest request , @Valid Contacts contacts) {
|
||||
Contacts data = contactsRes.findOne(contacts.getId()) ;
|
||||
if(data!=null){
|
||||
List<PropertiesEvent> events = PropertiesEventUtils.processPropertiesModify(request, contacts , data , "id" , "orgi" , "creater" ,"createtime" , "updatetime") ; //记录 数据变更 历史
|
||||
if(events.size()>0){
|
||||
String modifyid = UKTools.getUUID() ;
|
||||
Date modifytime = new Date();
|
||||
for(PropertiesEvent event : events){
|
||||
event.setDataid(contacts.getId());
|
||||
event.setCreater(super.getUser(request).getId());
|
||||
event.setOrgi(super.getOrgi(request));
|
||||
event.setModifyid(modifyid);
|
||||
event.setCreatetime(modifytime);
|
||||
propertiesEventRes.save(event) ;
|
||||
}
|
||||
}
|
||||
|
||||
contacts.setCreater(data.getCreater());
|
||||
contacts.setCreatetime(data.getCreatetime());
|
||||
contacts.setOrgi(super.getOrgi(request));
|
||||
contacts.setOrgan(super.getUser(request).getOrgan());
|
||||
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
|
||||
if(StringUtils.isBlank(contacts.getCusbirthday())) {
|
||||
contacts.setCusbirthday(null);
|
||||
}
|
||||
contactsRes.save(contacts);
|
||||
}
|
||||
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/index.html?ckind="+contacts.getCkind()));
|
||||
|
||||
|
||||
@RequestMapping("/update")
|
||||
@Menu(type = "contacts", subtype = "contacts")
|
||||
public ModelAndView update(HttpServletRequest request, @Valid Contacts contacts) {
|
||||
Contacts data = contactsRes.findOne(contacts.getId());
|
||||
if (data != null) {
|
||||
List<PropertiesEvent> events = PropertiesEventUtils.processPropertiesModify(request, contacts, data, "id", "orgi", "creater", "createtime", "updatetime"); //记录 数据变更 历史
|
||||
if (events.size() > 0) {
|
||||
String modifyid = UKTools.getUUID();
|
||||
Date modifytime = new Date();
|
||||
for (PropertiesEvent event : events) {
|
||||
event.setDataid(contacts.getId());
|
||||
event.setCreater(super.getUser(request).getId());
|
||||
event.setOrgi(super.getOrgi(request));
|
||||
event.setModifyid(modifyid);
|
||||
event.setCreatetime(modifytime);
|
||||
propertiesEventRes.save(event);
|
||||
}
|
||||
}
|
||||
|
||||
contacts.setCreater(data.getCreater());
|
||||
contacts.setCreatetime(data.getCreatetime());
|
||||
contacts.setOrgi(super.getOrgi(request));
|
||||
contacts.setOrgan(super.getUser(request).getOrgan());
|
||||
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
|
||||
if (StringUtils.isBlank(contacts.getCusbirthday())) {
|
||||
contacts.setCusbirthday(null);
|
||||
}
|
||||
contactsRes.save(contacts);
|
||||
}
|
||||
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/index.html?ckind=" + contacts.getCkind()));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/imp")
|
||||
@Menu(type = "contacts" , subtype = "contacts")
|
||||
public ModelAndView imp(ModelMap map , HttpServletRequest request,@Valid String ckind) {
|
||||
map.addAttribute("ckind",ckind);
|
||||
@Menu(type = "contacts", subtype = "contacts")
|
||||
public ModelAndView imp(ModelMap map, HttpServletRequest request, @Valid String ckind) {
|
||||
map.addAttribute("ckind", ckind);
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/contacts/imp"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/impsave")
|
||||
@Menu(type = "contacts" , subtype = "contacts")
|
||||
public ModelAndView impsave(ModelMap map , HttpServletRequest request , @RequestParam(value = "cusfile", required = false) MultipartFile cusfile,@Valid String ckind) throws IOException {
|
||||
DSDataEvent event = new DSDataEvent();
|
||||
String fileName = "contacts/"+UKTools.getUUID()+cusfile.getOriginalFilename().substring(cusfile.getOriginalFilename().lastIndexOf(".")) ;
|
||||
File excelFile = new File(path , fileName) ;
|
||||
if(!excelFile.getParentFile().exists()){
|
||||
excelFile.getParentFile().mkdirs() ;
|
||||
}
|
||||
MetadataTable table = metadataRes.findByTablename("uk_contacts") ;
|
||||
if(table!=null){
|
||||
FileUtils.writeByteArrayToFile(new File(path , fileName), cusfile.getBytes());
|
||||
event.setDSData(new DSData(table,excelFile , cusfile.getContentType(), super.getUser(request)));
|
||||
event.getDSData().setClazz(Contacts.class);
|
||||
event.getDSData().setProcess(new ContactsProcess(contactsRes));
|
||||
event.setOrgi(super.getOrgi(request));
|
||||
@Menu(type = "contacts", subtype = "contacts")
|
||||
public ModelAndView impsave(ModelMap map, HttpServletRequest request, @RequestParam(value = "cusfile", required = false) MultipartFile cusfile, @Valid String ckind) throws IOException {
|
||||
DSDataEvent event = new DSDataEvent();
|
||||
String fileName = "contacts/" + UKTools.getUUID() + cusfile.getOriginalFilename().substring(cusfile.getOriginalFilename().lastIndexOf("."));
|
||||
File excelFile = new File(path, fileName);
|
||||
if (!excelFile.getParentFile().exists()) {
|
||||
excelFile.getParentFile().mkdirs();
|
||||
}
|
||||
MetadataTable table = metadataRes.findByTablename("uk_contacts");
|
||||
if (table != null) {
|
||||
FileUtils.writeByteArrayToFile(new File(path, fileName), cusfile.getBytes());
|
||||
event.setDSData(new DSData(table, excelFile, cusfile.getContentType(), super.getUser(request)));
|
||||
event.getDSData().setClazz(Contacts.class);
|
||||
event.getDSData().setProcess(new ContactsProcess(contactsRes));
|
||||
event.setOrgi(super.getOrgi(request));
|
||||
/*if(!StringUtils.isBlank(ckind)){
|
||||
event.getValues().put("ckind", ckind) ;
|
||||
}*/
|
||||
event.getValues().put("creater", super.getUser(request).getId()) ;
|
||||
reporterRes.save(event.getDSData().getReport()) ;
|
||||
new ExcelImportProecess(event).process() ; //启动导入任务
|
||||
}
|
||||
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/index.html"));
|
||||
event.getValues().put("creater", super.getUser(request).getId());
|
||||
reporterRes.save(event.getDSData().getReport());
|
||||
new ExcelImportProecess(event).process(); //启动导入任务
|
||||
}
|
||||
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/index.html"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/expids")
|
||||
@Menu(type = "contacts" , subtype = "contacts")
|
||||
public void expids(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String[] ids) throws IOException {
|
||||
if(ids!=null && ids.length > 0){
|
||||
Iterable<Contacts> contactsList = contactsRes.findAll(Arrays.asList(ids)) ;
|
||||
MetadataTable table = metadataRes.findByTablename("uk_contacts") ;
|
||||
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
|
||||
for(Contacts contacts : contactsList){
|
||||
values.add(UKTools.transBean2Map(contacts)) ;
|
||||
}
|
||||
|
||||
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Contacts-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
|
||||
|
||||
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
|
||||
excelProcess.process();
|
||||
}
|
||||
|
||||
return ;
|
||||
@Menu(type = "contacts", subtype = "contacts")
|
||||
public void expids(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String[] ids) throws IOException {
|
||||
if (ids != null && ids.length > 0) {
|
||||
Iterable<Contacts> contactsList = contactsRes.findAll(Arrays.asList(ids));
|
||||
MetadataTable table = metadataRes.findByTablename("uk_contacts");
|
||||
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
|
||||
for (Contacts contacts : contactsList) {
|
||||
values.add(UKTools.transBean2Map(contacts));
|
||||
}
|
||||
|
||||
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Contacts-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
|
||||
|
||||
ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream());
|
||||
excelProcess.process();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/expall")
|
||||
@Menu(type = "contacts" , subtype = "contacts")
|
||||
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response) throws IOException {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
boolQueryBuilder.must(termQuery("datastatus" , false)) ; //只导出 数据删除状态 为 未删除的 数据
|
||||
Iterable<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request),null , null , false, boolQueryBuilder , null , new PageRequest(super.getP(request) , super.getPs(request)));
|
||||
|
||||
MetadataTable table = metadataRes.findByTablename("uk_contacts") ;
|
||||
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
|
||||
for(Contacts contacts : contactsList){
|
||||
values.add(UKTools.transBean2Map(contacts)) ;
|
||||
}
|
||||
|
||||
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Contacts-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
|
||||
|
||||
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
|
||||
excelProcess.process();
|
||||
return ;
|
||||
@Menu(type = "contacts", subtype = "contacts")
|
||||
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
boolQueryBuilder.must(termQuery("datastatus", false)); //只导出 数据删除状态 为 未删除的 数据
|
||||
Iterable<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), null, null, false, boolQueryBuilder, null, new PageRequest(super.getP(request), super.getPs(request)));
|
||||
|
||||
MetadataTable table = metadataRes.findByTablename("uk_contacts");
|
||||
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
|
||||
for (Contacts contacts : contactsList) {
|
||||
values.add(UKTools.transBean2Map(contacts));
|
||||
}
|
||||
|
||||
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Contacts-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
|
||||
|
||||
ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream());
|
||||
excelProcess.process();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/expsearch")
|
||||
@Menu(type = "contacts" , subtype = "contacts")
|
||||
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String q , @Valid String ekind) throws IOException {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
if(!StringUtils.isBlank(q)){
|
||||
map.put("q", q) ;
|
||||
@Menu(type = "contacts", subtype = "contacts")
|
||||
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String q, @Valid String ekind) throws IOException {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
if (!StringUtils.isBlank(q)) {
|
||||
map.put("q", q);
|
||||
}
|
||||
if(!StringUtils.isBlank(ekind)){
|
||||
boolQueryBuilder.must(termQuery("ekind" , ekind)) ;
|
||||
map.put("ekind", ekind) ;
|
||||
if (!StringUtils.isBlank(ekind)) {
|
||||
boolQueryBuilder.must(termQuery("ekind", ekind));
|
||||
map.put("ekind", ekind);
|
||||
}
|
||||
|
||||
Iterable<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(),super.getOrgi(request), null , null , false, boolQueryBuilder ,q , new PageRequest(super.getP(request) , super.getPs(request)));
|
||||
MetadataTable table = metadataRes.findByTablename("uk_contacts") ;
|
||||
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
|
||||
for(Contacts contacts : contactsList){
|
||||
values.add(UKTools.transBean2Map(contacts)) ;
|
||||
}
|
||||
|
||||
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Contacts-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
|
||||
Iterable<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), null, null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request)));
|
||||
MetadataTable table = metadataRes.findByTablename("uk_contacts");
|
||||
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
|
||||
for (Contacts contacts : contactsList) {
|
||||
values.add(UKTools.transBean2Map(contacts));
|
||||
}
|
||||
|
||||
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
|
||||
excelProcess.process();
|
||||
|
||||
return ;
|
||||
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Contacts-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
|
||||
|
||||
ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream());
|
||||
excelProcess.process();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/embed/index")
|
||||
@Menu(type = "customer" , subtype = "embed")
|
||||
public ModelAndView embed(ModelMap map , HttpServletRequest request , @Valid String q , @Valid String ckind) {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
if(!StringUtils.isBlank(q)){
|
||||
map.put("q", q) ;
|
||||
@Menu(type = "customer", subtype = "embed")
|
||||
public ModelAndView embed(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ckind) {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
if (!StringUtils.isBlank(q)) {
|
||||
map.put("q", q);
|
||||
}
|
||||
if(!StringUtils.isBlank(ckind)){
|
||||
boolQueryBuilder.must(termQuery("ckind" , ckind)) ;
|
||||
map.put("ckind", ckind) ;
|
||||
if (!StringUtils.isBlank(ckind)) {
|
||||
boolQueryBuilder.must(termQuery("ckind", ckind));
|
||||
map.put("ckind", ckind);
|
||||
}
|
||||
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request),null , null , false, boolQueryBuilder ,q , new PageRequest(super.getP(request) , super.getPs(request)))) ;
|
||||
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/contacts/embed/index"));
|
||||
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), null, null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request))));
|
||||
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/contacts/embed/index"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/embed/add")
|
||||
@Menu(type = "contacts" , subtype = "embedadd")
|
||||
public ModelAndView embedadd(ModelMap map , HttpServletRequest request) {
|
||||
@Menu(type = "contacts", subtype = "embedadd")
|
||||
public ModelAndView embedadd(ModelMap map, HttpServletRequest request) {
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/contacts/embed/add"));
|
||||
}
|
||||
|
||||
@RequestMapping( "/embed/save")
|
||||
@Menu(type = "contacts" , subtype = "embedsave")
|
||||
public ModelAndView embedsave(HttpServletRequest request , @Valid Contacts contacts) {
|
||||
contacts.setCreater(super.getUser(request).getId());
|
||||
contacts.setOrgi(super.getOrgi(request));
|
||||
contacts.setOrgan(super.getUser(request).getOrgan());
|
||||
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
|
||||
if(StringUtils.isBlank(contacts.getCusbirthday())) {
|
||||
contacts.setCusbirthday(null);
|
||||
}
|
||||
contactsRes.save(contacts) ;
|
||||
|
||||
@RequestMapping("/embed/save")
|
||||
@Menu(type = "contacts", subtype = "embedsave")
|
||||
public ModelAndView embedsave(HttpServletRequest request, @Valid Contacts contacts) {
|
||||
contacts.setCreater(super.getUser(request).getId());
|
||||
contacts.setOrgi(super.getOrgi(request));
|
||||
contacts.setOrgan(super.getUser(request).getOrgan());
|
||||
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
|
||||
if (StringUtils.isBlank(contacts.getCusbirthday())) {
|
||||
contacts.setCusbirthday(null);
|
||||
}
|
||||
contactsRes.save(contacts);
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/embed/edit")
|
||||
@Menu(type = "contacts" , subtype = "embededit")
|
||||
public ModelAndView embededit(ModelMap map , HttpServletRequest request , @Valid String id) {
|
||||
map.addAttribute("contacts", contactsRes.findOne(id)) ;
|
||||
@Menu(type = "contacts", subtype = "embededit")
|
||||
public ModelAndView embededit(ModelMap map, HttpServletRequest request, @Valid String id) {
|
||||
map.addAttribute("contacts", contactsRes.findOne(id));
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/contacts/embed/edit"));
|
||||
}
|
||||
|
||||
@RequestMapping( "/embed/update")
|
||||
@Menu(type = "contacts" , subtype = "embedupdate")
|
||||
public ModelAndView embedupdate(HttpServletRequest request , @Valid Contacts contacts) {
|
||||
Contacts data = contactsRes.findOne(contacts.getId()) ;
|
||||
if(data!=null){
|
||||
List<PropertiesEvent> events = PropertiesEventUtils.processPropertiesModify(request, contacts , data , "id" , "orgi" , "creater" ,"createtime" , "updatetime") ; //记录 数据变更 历史
|
||||
if(events.size()>0){
|
||||
String modifyid = UKTools.getUUID() ;
|
||||
Date modifytime = new Date();
|
||||
for(PropertiesEvent event : events){
|
||||
event.setDataid(contacts.getId());
|
||||
event.setCreater(super.getUser(request).getId());
|
||||
event.setOrgi(super.getOrgi(request));
|
||||
event.setModifyid(modifyid);
|
||||
event.setCreatetime(modifytime);
|
||||
propertiesEventRes.save(event) ;
|
||||
}
|
||||
}
|
||||
|
||||
contacts.setCreater(data.getCreater());
|
||||
contacts.setCreatetime(data.getCreatetime());
|
||||
contacts.setOrgi(super.getOrgi(request));
|
||||
contacts.setOrgan(super.getUser(request).getOrgan());
|
||||
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
|
||||
if(StringUtils.isBlank(contacts.getCusbirthday())) {
|
||||
contacts.setCusbirthday(null);
|
||||
}
|
||||
contactsRes.save(contacts);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/embed/update")
|
||||
@Menu(type = "contacts", subtype = "embedupdate")
|
||||
public ModelAndView embedupdate(HttpServletRequest request, @Valid Contacts contacts) {
|
||||
Contacts data = contactsRes.findOne(contacts.getId());
|
||||
if (data != null) {
|
||||
List<PropertiesEvent> events = PropertiesEventUtils.processPropertiesModify(request, contacts, data, "id", "orgi", "creater", "createtime", "updatetime"); //记录 数据变更 历史
|
||||
if (events.size() > 0) {
|
||||
String modifyid = UKTools.getUUID();
|
||||
Date modifytime = new Date();
|
||||
for (PropertiesEvent event : events) {
|
||||
event.setDataid(contacts.getId());
|
||||
event.setCreater(super.getUser(request).getId());
|
||||
event.setOrgi(super.getOrgi(request));
|
||||
event.setModifyid(modifyid);
|
||||
event.setCreatetime(modifytime);
|
||||
propertiesEventRes.save(event);
|
||||
}
|
||||
}
|
||||
|
||||
contacts.setCreater(data.getCreater());
|
||||
contacts.setCreatetime(data.getCreatetime());
|
||||
contacts.setOrgi(super.getOrgi(request));
|
||||
contacts.setOrgan(super.getUser(request).getOrgan());
|
||||
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
|
||||
if (StringUtils.isBlank(contacts.getCusbirthday())) {
|
||||
contacts.setCusbirthday(null);
|
||||
}
|
||||
contactsRes.save(contacts);
|
||||
}
|
||||
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html"));
|
||||
}
|
||||
}
|
@ -17,11 +17,7 @@
|
||||
package com.chatopera.cc.webim.web.model;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@ -104,6 +100,7 @@ public class User implements java.io.Serializable{
|
||||
private int fans; //粉丝
|
||||
private int follows; //关注
|
||||
private int integral; //积分
|
||||
private HashSet<String> myorgans = new HashSet<>();
|
||||
private List<Role> roleList = new ArrayList<Role>();
|
||||
private Map<String ,Object> roleAuthMap = new HashMap<String ,Object>();
|
||||
|
||||
@ -517,4 +514,13 @@ public class User implements java.io.Serializable{
|
||||
public void setOrdertype(String ordertype) {
|
||||
this.ordertype = ordertype;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public HashSet<String> getMyorgans() {
|
||||
return myorgans;
|
||||
}
|
||||
|
||||
public void setMyorgans(HashSet<String> myorgans) {
|
||||
this.myorgans = myorgans;
|
||||
}
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
<div class="uk-layui-form">
|
||||
<form class="layui-form uk-form" action="/admin/organ/auth/save.html">
|
||||
<input type="hidden" name="id" value="${organData.id!''}">
|
||||
<input type="hidden" name="menus" id="menus" value="<#if organRoleList??><#list organRoleList as organRole><#if organRole_index gt 0>,</#if>${organRole.dicid!''}</#list></#if>">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-inline">
|
||||
<ul id="organTree" class="ztree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-button">
|
||||
<div class="layui-button-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<SCRIPT type="text/javascript">
|
||||
var setting = {
|
||||
check: {
|
||||
enable: true
|
||||
},
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onCheck: zTreeOnCheck
|
||||
}
|
||||
};
|
||||
|
||||
//获取所有选中节点的值
|
||||
function zTreeOnCheck() {
|
||||
var treeObj = $.fn.zTree.getZTreeObj("organTree");
|
||||
var nodes = treeObj.getCheckedNodes(true);
|
||||
var msg = "";
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
if(msg!='' && nodes[i].id != ''){
|
||||
msg = msg+"," ;
|
||||
}
|
||||
msg += nodes[i].id;
|
||||
}
|
||||
$("#menus").val(msg);
|
||||
}
|
||||
|
||||
|
||||
var zNodes =[
|
||||
<#if sysDic??>{ id:'${sysDic.id!''}', pId:'0', name:"菜单资源", open:true , value : ""}</#if>
|
||||
<#if resourceList??>
|
||||
<#list resourceList as dic>
|
||||
,{ id:'${dic.id}', pId:'${dic.parentid!''}' <#if organRoleList??><#list organRoleList as organRole><#if organRole.dicid?? && organRole.dicid == dic.id>,checked:true</#if></#list></#if> , name:"${dic.name!''}" , value : "${dic.code!''}", open:true , icon : "<#if dic.level?? && (dic.level == '1' || dic.level == '2')>/images/dir.png<#else>/images/menu.png</#if>"}
|
||||
</#list>
|
||||
</#if>
|
||||
];
|
||||
|
||||
$(document).ready(function(){
|
||||
$.fn.zTree.init($("#organTree"), setting, zNodes);
|
||||
});
|
||||
</SCRIPT>
|
@ -31,9 +31,6 @@
|
||||
<button class="layui-btn layui-btn-danger layui-btn-small" href="/admin/organ/delete.html?id=${organData.id!''}" data-toggle="tip" data-title="请确认是否删除该部门?">
|
||||
删除部门
|
||||
</button>
|
||||
<button class="layui-btn layui-btn-danger layui-btn-small" href="/admin/organ/auth.html?id=${organData.id!''}" data-toggle="ajax" title="给机构授权角色" data-width="400" data-height="450">
|
||||
部门授权
|
||||
</button>
|
||||
</#if>
|
||||
</span>
|
||||
</h1>
|
||||
|
Loading…
x
Reference in New Issue
Block a user