mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Fix SysDicRepository related class
This commit is contained in:
parent
a3e5b1660e
commit
4f4616ccba
@ -31,8 +31,9 @@ import com.chatopera.cc.persistence.repository.UserRepository;
|
|||||||
import com.chatopera.cc.proxy.OnlineUserProxy;
|
import com.chatopera.cc.proxy.OnlineUserProxy;
|
||||||
import com.chatopera.cc.socketio.client.NettyClients;
|
import com.chatopera.cc.socketio.client.NettyClients;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -45,28 +46,29 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class AdminController extends Handler {
|
public class AdminController extends Handler {
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private ACDWorkMonitor acdWorkMonitor;
|
private final ACDWorkMonitor acdWorkMonitor;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private UserRepository userRes;
|
private final UserRepository userRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private OnlineUserRepository onlineUserRes;
|
private final OnlineUserRepository onlineUserRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private UserEventRepository userEventRes;
|
private final UserEventRepository userEventRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private SysDicRepository sysDicRes;
|
private final SysDicRepository sysDicRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private Cache cache;
|
private final Cache cache;
|
||||||
|
|
||||||
@RequestMapping("/admin")
|
@RequestMapping("/admin")
|
||||||
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
public ModelAndView index(HttpServletRequest request) {
|
||||||
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
|
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
|
||||||
User user = super.getUser(request);
|
User user = super.getUser(request);
|
||||||
view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(user.getOrgi()));
|
view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(user.getOrgi()));
|
||||||
@ -107,13 +109,13 @@ public class AdminController extends Handler {
|
|||||||
|
|
||||||
private List<User> getAgent(HttpServletRequest request) {
|
private List<User> getAgent(HttpServletRequest request) {
|
||||||
//获取当前产品or租户坐席数
|
//获取当前产品or租户坐席数
|
||||||
List<User> userList = new ArrayList<>();
|
List<User> userList;
|
||||||
if (super.isEnabletneant()) {
|
if (super.isEnabletneant()) {
|
||||||
userList = userRes.findByOrgidAndAgentAndDatastatus(super.getOrgid(request), true, false);
|
userList = userRes.findByOrgidAndAgentAndDatastatus(super.getOrgid(request), true, false);
|
||||||
} else {
|
} else {
|
||||||
userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
|
userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
|
||||||
}
|
}
|
||||||
return userList.isEmpty() ? new ArrayList<User>() : userList;
|
return userList.isEmpty() ? new ArrayList<>() : userList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/admin/content")
|
@RequestMapping("/admin/content")
|
||||||
@ -131,7 +133,7 @@ public class AdminController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/admin/auth/infoacq")
|
@RequestMapping("/admin/auth/infoacq")
|
||||||
@Menu(type = "admin", subtype = "infoacq", admin = true)
|
@Menu(type = "admin", subtype = "infoacq", admin = true)
|
||||||
public ModelAndView infoacq(ModelMap map, HttpServletRequest request) {
|
public ModelAndView infoacq(HttpServletRequest request) {
|
||||||
String inacq = (String) request.getSession().getAttribute(Constants.CSKEFU_SYSTEM_INFOACQ);
|
String inacq = (String) request.getSession().getAttribute(Constants.CSKEFU_SYSTEM_INFOACQ);
|
||||||
if (StringUtils.isNotBlank(inacq)) {
|
if (StringUtils.isNotBlank(inacq)) {
|
||||||
request.getSession().removeAttribute(Constants.CSKEFU_SYSTEM_INFOACQ);
|
request.getSession().removeAttribute(Constants.CSKEFU_SYSTEM_INFOACQ);
|
||||||
@ -143,7 +145,7 @@ public class AdminController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/admin/auth/event")
|
@RequestMapping("/admin/auth/event")
|
||||||
@Menu(type = "admin", subtype = "authevent")
|
@Menu(type = "admin", subtype = "authevent")
|
||||||
public ModelAndView authevent(ModelMap map, HttpServletRequest request, @Valid String title, @Valid String url, @Valid String iconstr, @Valid String icontext) {
|
public ModelAndView authevent(ModelMap map, @Valid String title, @Valid String url, @Valid String iconstr, @Valid String icontext) {
|
||||||
map.addAttribute("title", title);
|
map.addAttribute("title", title);
|
||||||
map.addAttribute("url", url);
|
map.addAttribute("url", url);
|
||||||
if (StringUtils.isNotBlank(iconstr) && StringUtils.isNotBlank(icontext)) {
|
if (StringUtils.isNotBlank(iconstr) && StringUtils.isNotBlank(icontext)) {
|
||||||
@ -154,7 +156,7 @@ public class AdminController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/admin/auth/save")
|
@RequestMapping("/admin/auth/save")
|
||||||
@Menu(type = "admin", subtype = "authsave")
|
@Menu(type = "admin", subtype = "authsave")
|
||||||
public ModelAndView authsave(ModelMap map, HttpServletRequest request, @Valid String title, @Valid SysDic dic) {
|
public ModelAndView authsave(HttpServletRequest request, @Valid SysDic dic) {
|
||||||
SysDic sysDic = sysDicRes.findByCode(Constants.CSKEFU_SYSTEM_AUTH_DIC);
|
SysDic sysDic = sysDicRes.findByCode(Constants.CSKEFU_SYSTEM_AUTH_DIC);
|
||||||
boolean newdic = false;
|
boolean newdic = false;
|
||||||
if (sysDic != null && StringUtils.isNotBlank(dic.getName())) {
|
if (sysDic != null && StringUtils.isNotBlank(dic.getName())) {
|
||||||
|
@ -1,127 +1,125 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.chatopera.cc.controller.admin;
|
package com.chatopera.cc.controller.admin;
|
||||||
|
|
||||||
import com.chatopera.cc.basic.Constants;
|
import com.chatopera.cc.basic.Constants;
|
||||||
import com.chatopera.cc.basic.MainUtils;
|
import com.chatopera.cc.basic.MainUtils;
|
||||||
import com.chatopera.cc.controller.Handler;
|
import com.chatopera.cc.controller.Handler;
|
||||||
import com.chatopera.cc.model.AreaType;
|
import com.chatopera.cc.model.AreaType;
|
||||||
import com.chatopera.cc.model.Dict;
|
import com.chatopera.cc.model.Dict;
|
||||||
import com.chatopera.cc.model.SysDic;
|
import com.chatopera.cc.model.SysDic;
|
||||||
import com.chatopera.cc.persistence.repository.AreaTypeRepository;
|
import com.chatopera.cc.persistence.repository.AreaTypeRepository;
|
||||||
import com.chatopera.cc.persistence.repository.SysDicRepository;
|
import com.chatopera.cc.persistence.repository.SysDicRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import javax.validation.Valid;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author <a href="http://blog.didispace.com">程序猿DD</a>
|
||||||
* @author 程序猿DD
|
* @version 1.0.0
|
||||||
* @version 1.0.0
|
*/
|
||||||
* @blog http://blog.didispace.com
|
@Controller
|
||||||
*
|
@RequestMapping("/admin/area")
|
||||||
*/
|
@RequiredArgsConstructor
|
||||||
@Controller
|
public class AreaController extends Handler {
|
||||||
@RequestMapping("/admin/area")
|
|
||||||
public class AreaController extends Handler{
|
@NonNull
|
||||||
|
private final AreaTypeRepository areaRepository;
|
||||||
@Autowired
|
|
||||||
private AreaTypeRepository areaRepository;
|
@NonNull
|
||||||
|
private final SysDicRepository sysDicRepository;
|
||||||
@Autowired
|
|
||||||
private SysDicRepository sysDicRepository;
|
@RequestMapping("/index")
|
||||||
|
@Menu(type = "admin", subtype = "area")
|
||||||
@RequestMapping("/index")
|
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
||||||
@Menu(type = "admin" , subtype = "area")
|
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi(request)));
|
||||||
public ModelAndView index(ModelMap map , HttpServletRequest request) throws IOException {
|
return request(super.createAdminTempletResponse("/admin/area/index"));
|
||||||
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi(request)));
|
}
|
||||||
return request(super.createAdminTempletResponse("/admin/area/index"));
|
|
||||||
}
|
@RequestMapping("/add")
|
||||||
|
@Menu(type = "admin", subtype = "area")
|
||||||
@RequestMapping("/add")
|
public ModelAndView add(ModelMap map) {
|
||||||
@Menu(type = "admin" , subtype = "area")
|
SysDic sysDic = sysDicRepository.findByCode(Constants.CSKEFU_SYSTEM_AREA_DIC);
|
||||||
public ModelAndView add(ModelMap map , HttpServletRequest request) {
|
if (sysDic != null) {
|
||||||
SysDic sysDic = sysDicRepository.findByCode(Constants.CSKEFU_SYSTEM_AREA_DIC) ;
|
map.addAttribute("sysarea", sysDic);
|
||||||
if(sysDic!=null){
|
map.addAttribute("areaList", sysDicRepository.findByDicid(sysDic.getId()));
|
||||||
map.addAttribute("sysarea", sysDic) ;
|
}
|
||||||
map.addAttribute("areaList", sysDicRepository.findByDicid(sysDic.getId())) ;
|
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC));
|
||||||
}
|
return request(super.createRequestPageTempletResponse("/admin/area/add"));
|
||||||
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC)) ;
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/admin/area/add"));
|
|
||||||
}
|
@RequestMapping("/save")
|
||||||
|
@Menu(type = "admin", subtype = "area")
|
||||||
@RequestMapping("/save")
|
public ModelAndView save(HttpServletRequest request, @Valid AreaType area) {
|
||||||
@Menu(type = "admin" , subtype = "area")
|
int areas = areaRepository.countByNameAndOrgi(area.getName(), super.getOrgi(request));
|
||||||
public ModelAndView save(HttpServletRequest request ,@Valid AreaType area) {
|
if (areas == 0) {
|
||||||
int areas = areaRepository.countByNameAndOrgi(area.getName(), super.getOrgi(request)) ;
|
area.setOrgi(super.getOrgi(request));
|
||||||
if(areas == 0){
|
area.setCreatetime(new Date());
|
||||||
area.setOrgi(super.getOrgi(request));
|
area.setCreater(super.getUser(request).getId());
|
||||||
area.setCreatetime(new Date());
|
areaRepository.save(area);
|
||||||
area.setCreater(super.getUser(request).getId());
|
MainUtils.initSystemArea();
|
||||||
areaRepository.save(area) ;
|
}
|
||||||
MainUtils.initSystemArea();
|
return request(super.createRequestPageTempletResponse("redirect:/admin/area/index.html"));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/area/index.html"));
|
|
||||||
}
|
@RequestMapping("/edit")
|
||||||
|
@Menu(type = "admin", subtype = "area")
|
||||||
@RequestMapping("/edit")
|
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
|
||||||
@Menu(type = "admin" , subtype = "area")
|
map.addAttribute("area", areaRepository.findByIdAndOrgi(id, super.getOrgi(request)));
|
||||||
public ModelAndView edit(ModelMap map ,HttpServletRequest request , @Valid String id) {
|
|
||||||
map.addAttribute("area", areaRepository.findByIdAndOrgi(id, super.getOrgi(request))) ;
|
SysDic sysDic = sysDicRepository.findByCode(Constants.CSKEFU_SYSTEM_AREA_DIC);
|
||||||
|
if (sysDic != null) {
|
||||||
SysDic sysDic = sysDicRepository.findByCode(Constants.CSKEFU_SYSTEM_AREA_DIC) ;
|
map.addAttribute("sysarea", sysDic);
|
||||||
if(sysDic!=null){
|
map.addAttribute("areaList", sysDicRepository.findByDicid(sysDic.getId()));
|
||||||
map.addAttribute("sysarea", sysDic) ;
|
}
|
||||||
map.addAttribute("areaList", sysDicRepository.findByDicid(sysDic.getId())) ;
|
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC));
|
||||||
}
|
return request(super.createRequestPageTempletResponse("/admin/area/edit"));
|
||||||
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC)) ;
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/admin/area/edit"));
|
|
||||||
}
|
@RequestMapping("/update")
|
||||||
|
@Menu(type = "admin", subtype = "area", admin = true)
|
||||||
@RequestMapping("/update")
|
public ModelAndView update(HttpServletRequest request, @Valid AreaType area) {
|
||||||
@Menu(type = "admin" , subtype = "area" , admin = true)
|
AreaType areaType = areaRepository.findByIdAndOrgi(area.getId(), super.getOrgi(request));
|
||||||
public ModelAndView update(HttpServletRequest request ,@Valid AreaType area) {
|
if (areaType != null) {
|
||||||
AreaType areaType = areaRepository.findByIdAndOrgi(area.getId(), super.getOrgi(request)) ;
|
area.setCreatetime(areaType.getCreatetime());
|
||||||
if(areaType != null){
|
area.setOrgi(super.getOrgi(request));
|
||||||
area.setCreatetime(areaType.getCreatetime());
|
area.setCreater(areaType.getCreater());
|
||||||
area.setOrgi(super.getOrgi(request));
|
areaRepository.save(area);
|
||||||
area.setCreater(areaType.getCreater());
|
MainUtils.initSystemArea();
|
||||||
areaRepository.save(area) ;
|
}
|
||||||
MainUtils.initSystemArea();
|
return request(super.createRequestPageTempletResponse("redirect:/admin/area/index.html"));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/area/index.html"));
|
|
||||||
}
|
@RequestMapping("/delete")
|
||||||
|
@Menu(type = "admin", subtype = "area")
|
||||||
@RequestMapping("/delete")
|
public ModelAndView delete(HttpServletRequest request, @Valid AreaType area) {
|
||||||
@Menu(type = "admin" , subtype = "area")
|
AreaType areaType = areaRepository.findByIdAndOrgi(area.getId(), super.getOrgi(request));
|
||||||
public ModelAndView delete(HttpServletRequest request ,@Valid AreaType area) {
|
if (areaType != null) {
|
||||||
AreaType areaType = areaRepository.findByIdAndOrgi(area.getId(), super.getOrgi(request)) ;
|
areaRepository.delete(areaType);
|
||||||
if(areaType!=null){
|
MainUtils.initSystemArea();
|
||||||
areaRepository.delete(areaType);
|
}
|
||||||
MainUtils.initSystemArea();
|
return request(super.createRequestPageTempletResponse("redirect:/admin/area/index.html"));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/area/index.html"));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,377 +1,368 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.chatopera.cc.controller.admin;
|
package com.chatopera.cc.controller.admin;
|
||||||
|
|
||||||
import com.chatopera.cc.basic.Constants;
|
import com.chatopera.cc.basic.Constants;
|
||||||
import com.chatopera.cc.basic.MainContext;
|
import com.chatopera.cc.basic.MainContext;
|
||||||
import com.chatopera.cc.cache.Cache;
|
import com.chatopera.cc.cache.Cache;
|
||||||
import com.chatopera.cc.controller.Handler;
|
import com.chatopera.cc.controller.Handler;
|
||||||
import com.chatopera.cc.model.*;
|
import com.chatopera.cc.model.*;
|
||||||
import com.chatopera.cc.persistence.repository.*;
|
import com.chatopera.cc.persistence.repository.*;
|
||||||
import com.chatopera.cc.proxy.OnlineUserProxy;
|
import com.chatopera.cc.proxy.OnlineUserProxy;
|
||||||
import com.chatopera.cc.proxy.OrganProxy;
|
import com.chatopera.cc.proxy.OrganProxy;
|
||||||
import com.chatopera.cc.proxy.UserProxy;
|
import com.chatopera.cc.proxy.UserProxy;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.slf4j.Logger;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.ArrayList;
|
import javax.validation.Valid;
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
/**
|
|
||||||
* @author 程序猿DD
|
/**
|
||||||
* @version 1.0.0
|
* @author <a href="http://blog.didispace.com">程序猿DD</a>
|
||||||
* @blog http://blog.didispace.com
|
* @version 1.0.0
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/admin/organ")
|
@RequiredArgsConstructor
|
||||||
public class OrganController extends Handler {
|
@RequestMapping("/admin/organ")
|
||||||
|
public class OrganController extends Handler {
|
||||||
private final static Logger logger = LoggerFactory.getLogger(OrganController.class);
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(OrganController.class);
|
||||||
@Autowired
|
|
||||||
private OrganRepository organRepository;
|
@NonNull
|
||||||
|
private final OrganRepository organRepository;
|
||||||
@Autowired
|
|
||||||
private OrganUserRepository organUserRes;
|
@NonNull
|
||||||
|
private final OrganUserRepository organUserRes;
|
||||||
@Autowired
|
|
||||||
private RoleRepository roleRepository;
|
@NonNull
|
||||||
|
private final RoleRepository roleRepository;
|
||||||
@Autowired
|
|
||||||
private SysDicRepository sysDicRepository;
|
@NonNull
|
||||||
|
private final SysDicRepository sysDicRepository;
|
||||||
@Autowired
|
|
||||||
private AreaTypeRepository areaRepository;
|
@NonNull
|
||||||
|
private final AreaTypeRepository areaRepository;
|
||||||
@Autowired
|
|
||||||
private UserRepository userRepository;
|
@NonNull
|
||||||
|
private final UserRepository userRepository;
|
||||||
@Autowired
|
|
||||||
private OrganRoleRepository organRoleRes;
|
@NonNull
|
||||||
|
private final OrganRoleRepository organRoleRes;
|
||||||
@Autowired
|
|
||||||
private OrganProxy organProxy;
|
@NonNull
|
||||||
|
private final OrganProxy organProxy;
|
||||||
@Autowired
|
|
||||||
private Cache cache;
|
@NonNull
|
||||||
|
private final Cache cache;
|
||||||
@Autowired
|
|
||||||
private UserProxy userProxy;
|
@NonNull
|
||||||
|
private final UserProxy userProxy;
|
||||||
@RequestMapping("/index")
|
|
||||||
@Menu(type = "admin", subtype = "organ")
|
@RequestMapping("/index")
|
||||||
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String organ, @Valid String msg) {
|
@Menu(type = "admin", subtype = "organ")
|
||||||
List<Organ> organList = organRepository.findByOrgiAndOrgid(
|
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String organ, @Valid String msg) {
|
||||||
super.getOrgiByTenantshare(request), super.getOrgid(request));
|
List<Organ> organList = organRepository.findByOrgiAndOrgid(
|
||||||
map.addAttribute("organList", organList);
|
super.getOrgiByTenantshare(request), super.getOrgid(request));
|
||||||
if (organList.size() > 0) {
|
map.addAttribute("organList", organList);
|
||||||
Organ organData = null;
|
if (organList.size() > 0) {
|
||||||
if (!StringUtils.isBlank(organ) && !"null".equals(organ)) {
|
Organ organData = null;
|
||||||
for (Organ data : organList) {
|
if (!StringUtils.isBlank(organ) && !"null".equals(organ)) {
|
||||||
if (data.getId().equals(organ)) {
|
for (Organ data : organList) {
|
||||||
map.addAttribute("organData", data);
|
if (data.getId().equals(organ)) {
|
||||||
organData = data;
|
map.addAttribute("organData", data);
|
||||||
}
|
organData = data;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
map.addAttribute("organData", organData = organList.get(0));
|
} else {
|
||||||
}
|
map.addAttribute("organData", organData = organList.get(0));
|
||||||
if (organData != null) {
|
}
|
||||||
map.addAttribute(
|
if (organData != null) {
|
||||||
"userList", userProxy.findByOrganAndOrgiAndDatastatus(
|
map.addAttribute(
|
||||||
organData.getId(),
|
"userList", userProxy.findByOrganAndOrgiAndDatastatus(
|
||||||
super.getOrgiByTenantshare(request),
|
organData.getId(),
|
||||||
false));
|
super.getOrgiByTenantshare(request),
|
||||||
}
|
false));
|
||||||
}
|
}
|
||||||
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
|
}
|
||||||
map.addAttribute(
|
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
|
||||||
"roleList", roleRepository.findByOrgiAndOrgid(
|
map.addAttribute(
|
||||||
super.getOrgiByTenantshare(request),
|
"roleList", roleRepository.findByOrgiAndOrgid(
|
||||||
super.getOrgid(request)));
|
super.getOrgiByTenantshare(request),
|
||||||
map.put("msg", msg);
|
super.getOrgid(request)));
|
||||||
return request(super.createAdminTempletResponse("/admin/organ/index"));
|
map.put("msg", msg);
|
||||||
}
|
return request(super.createAdminTempletResponse("/admin/organ/index"));
|
||||||
|
}
|
||||||
@RequestMapping("/add")
|
|
||||||
@Menu(type = "admin", subtype = "organ")
|
@RequestMapping("/add")
|
||||||
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String parent, @Valid String area) {
|
@Menu(type = "admin", subtype = "organ")
|
||||||
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
|
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String parent, @Valid String area) {
|
||||||
if (!StringUtils.isBlank(parent)) {
|
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
|
||||||
map.addAttribute("organ", organRepository.findByIdAndOrgi(parent, super.getOrgiByTenantshare(request)));
|
if (!StringUtils.isBlank(parent)) {
|
||||||
}
|
map.addAttribute("organ", organRepository.findByIdAndOrgi(parent, super.getOrgiByTenantshare(request)));
|
||||||
if (!StringUtils.isBlank(area)) {
|
}
|
||||||
map.addAttribute("area", areaRepository.findByIdAndOrgi(area, super.getOrgiByTenantshare(request)));
|
if (!StringUtils.isBlank(area)) {
|
||||||
}
|
map.addAttribute("area", areaRepository.findByIdAndOrgi(area, super.getOrgiByTenantshare(request)));
|
||||||
|
}
|
||||||
map.addAttribute(
|
|
||||||
"organList", organRepository.findByOrgiAndOrgid(
|
map.addAttribute(
|
||||||
super.getOrgiByTenantshare(request),
|
"organList", organRepository.findByOrgiAndOrgid(
|
||||||
super.getOrgid(request)));
|
super.getOrgiByTenantshare(request),
|
||||||
|
super.getOrgid(request)));
|
||||||
return request(super.createRequestPageTempletResponse("/admin/organ/add"));
|
|
||||||
}
|
return request(super.createRequestPageTempletResponse("/admin/organ/add"));
|
||||||
|
}
|
||||||
@RequestMapping("/save")
|
|
||||||
@Menu(type = "admin", subtype = "organ")
|
@RequestMapping("/save")
|
||||||
public ModelAndView save(HttpServletRequest request, @Valid Organ organ) {
|
@Menu(type = "admin", subtype = "organ")
|
||||||
Organ tempOrgan = organRepository.findByNameAndOrgiAndOrgid(
|
public ModelAndView save(HttpServletRequest request, @Valid Organ organ) {
|
||||||
organ.getName(), super.getOrgiByTenantshare(request), super.getOrgid(request));
|
Organ tempOrgan = organRepository.findByNameAndOrgiAndOrgid(
|
||||||
String msg = "admin_organ_new_success";
|
organ.getName(), super.getOrgiByTenantshare(request), super.getOrgid(request));
|
||||||
String firstId = null;
|
String msg = "admin_organ_new_success";
|
||||||
if (tempOrgan != null) {
|
String firstId = null;
|
||||||
msg = "admin_organ_update_name_not"; //分类名字重复
|
if (tempOrgan != null) {
|
||||||
} else {
|
msg = "admin_organ_update_name_not"; //分类名字重复
|
||||||
organ.setOrgi(super.getOrgiByTenantshare(request));
|
} else {
|
||||||
|
organ.setOrgi(super.getOrgiByTenantshare(request));
|
||||||
if (!StringUtils.isBlank(super.getUser(request).getOrgid())) {
|
|
||||||
organ.setOrgid(super.getUser(request).getOrgid());
|
if (!StringUtils.isBlank(super.getUser(request).getOrgid())) {
|
||||||
} else {
|
organ.setOrgid(super.getUser(request).getOrgid());
|
||||||
organ.setOrgid(MainContext.SYSTEM_ORGI);
|
} else {
|
||||||
}
|
organ.setOrgid(MainContext.SYSTEM_ORGI);
|
||||||
firstId = organ.getId();
|
}
|
||||||
|
firstId = organ.getId();
|
||||||
organRepository.save(organ);
|
|
||||||
|
organRepository.save(organ);
|
||||||
OnlineUserProxy.clean(super.getOrgi(request));
|
|
||||||
}
|
OnlineUserProxy.clean(super.getOrgi(request));
|
||||||
return request(super.createRequestPageTempletResponse(
|
}
|
||||||
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + firstId));
|
return request(super.createRequestPageTempletResponse(
|
||||||
}
|
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + firstId));
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 添加用户到当前部门时选择坐席
|
/**
|
||||||
*
|
* 添加用户到当前部门时选择坐席
|
||||||
* @param map
|
*/
|
||||||
* @param request
|
@RequestMapping("/seluser")
|
||||||
* @param organ
|
@Menu(type = "admin", subtype = "seluser", admin = true)
|
||||||
* @return
|
public ModelAndView seluser(ModelMap map, HttpServletRequest request, @Valid String organ) {
|
||||||
*/
|
map.addAttribute(
|
||||||
@RequestMapping("/seluser")
|
"userList", userRepository.findByOrgiAndDatastatusAndOrgid(super.getOrgiByTenantshare(request), false,
|
||||||
@Menu(type = "admin", subtype = "seluser", admin = true)
|
super.getOrgid(request)));
|
||||||
public ModelAndView seluser(ModelMap map, HttpServletRequest request, @Valid String organ) {
|
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgiByTenantshare(request));
|
||||||
map.addAttribute(
|
map.addAttribute("userOrganList", userProxy
|
||||||
"userList", userRepository.findByOrgiAndDatastatusAndOrgid(super.getOrgiByTenantshare(request), false,
|
.findByOrganAndOrgiAndDatastatus(organ, super.getOrgiByTenantshare(request), false));
|
||||||
super.getOrgid(request)));
|
map.addAttribute("organ", organData);
|
||||||
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgiByTenantshare(request));
|
return request(super.createRequestPageTempletResponse("/admin/organ/seluser"));
|
||||||
map.addAttribute("userOrganList", userProxy
|
}
|
||||||
.findByOrganAndOrgiAndDatastatus(organ, super.getOrgiByTenantshare(request), false));
|
|
||||||
map.addAttribute("organ", organData);
|
|
||||||
return request(super.createRequestPageTempletResponse("/admin/organ/seluser"));
|
/**
|
||||||
}
|
* 执行添加用户到组织中
|
||||||
|
*/
|
||||||
|
@RequestMapping("/saveuser")
|
||||||
/**
|
@Menu(type = "admin", subtype = "saveuser", admin = true)
|
||||||
* 执行添加用户到组织中
|
public ModelAndView saveuser(
|
||||||
*
|
HttpServletRequest request,
|
||||||
* @param request
|
final @Valid String[] users,
|
||||||
* @param users
|
final @Valid String organ
|
||||||
* @param organ
|
) {
|
||||||
* @return
|
logger.info("[saveuser] save users {} into organ {}", StringUtils.join(users, ","), organ);
|
||||||
*/
|
final User loginUser = super.getUser(request);
|
||||||
@RequestMapping("/saveuser")
|
|
||||||
@Menu(type = "admin", subtype = "saveuser", admin = true)
|
if (users != null && users.length > 0) {
|
||||||
public ModelAndView saveuser(
|
List<String> chosen = new ArrayList<>(Arrays.asList(users));
|
||||||
HttpServletRequest request,
|
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgiByTenantshare(request));
|
||||||
final @Valid String[] users,
|
List<User> organUserList = userRepository.findAllById(chosen);
|
||||||
final @Valid String organ
|
for (final User user : organUserList) {
|
||||||
) {
|
OrganUser ou = organUserRes.findByUseridAndOrgan(user.getId(), organ);
|
||||||
logger.info("[saveuser] save users {} into organ {}", StringUtils.join(users, ","), organ);
|
|
||||||
final User loginUser = super.getUser(request);
|
/*
|
||||||
|
* 检查人员和技能组关系
|
||||||
if (users != null && users.length > 0) {
|
*/
|
||||||
List<String> chosen = new ArrayList<String>(Arrays.asList(users));
|
if (organData.isSkill()) {
|
||||||
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgiByTenantshare(request));
|
// 该组织机构是技能组
|
||||||
List<User> organUserList = userRepository.findAll(chosen);
|
if (!user.isAgent()) {
|
||||||
for (final User user : organUserList) {
|
// 该人员不是坐席
|
||||||
OrganUser ou = organUserRes.findByUseridAndOrgan(user.getId(), organ);
|
if (ou != null) {
|
||||||
|
organUserRes.delete(ou);
|
||||||
/**
|
}
|
||||||
* 检查人员和技能组关系
|
continue;
|
||||||
*/
|
}
|
||||||
if (organData.isSkill()) {
|
}
|
||||||
// 该组织机构是技能组
|
|
||||||
if (!user.isAgent()) {
|
if (ou == null) {
|
||||||
// 该人员不是坐席
|
ou = new OrganUser();
|
||||||
if (ou != null) {
|
}
|
||||||
organUserRes.delete(ou);
|
|
||||||
}
|
ou.setCreator(loginUser.getId());
|
||||||
continue;
|
ou.setUserid(user.getId());
|
||||||
}
|
ou.setOrgan(organ);
|
||||||
}
|
|
||||||
|
organUserRes.save(ou);
|
||||||
if (ou == null) {
|
|
||||||
ou = new OrganUser();
|
if (user.isAgent()) {
|
||||||
}
|
/*
|
||||||
|
* 以下更新技能组状态
|
||||||
ou.setCreator(loginUser.getId());
|
*/
|
||||||
ou.setUserid(user.getId());
|
AgentStatus agentStatus = cache.findOneAgentStatusByAgentnoAndOrig(
|
||||||
ou.setOrgan(organ);
|
user.getId(), super.getOrgiByTenantshare(request));
|
||||||
|
|
||||||
organUserRes.save(ou);
|
// TODO 因为一个用户可以包含在多个技能组中,所以,skill应该对应
|
||||||
|
// 一个List列表,此处需要重构Skill为列表
|
||||||
if (user.isAgent()) {
|
if (agentStatus != null) {
|
||||||
/**
|
userProxy.attachOrgansPropertiesForUser(user);
|
||||||
* 以下更新技能组状态
|
agentStatus.setSkills(user.getSkills());
|
||||||
*/
|
cache.putAgentStatusByOrgi(agentStatus, super.getOrgiByTenantshare(request));
|
||||||
AgentStatus agentStatus = cache.findOneAgentStatusByAgentnoAndOrig(
|
}
|
||||||
user.getId(), super.getOrgiByTenantshare(request));
|
}
|
||||||
|
}
|
||||||
// TODO 因为一个用户可以包含在多个技能组中,所以,skill应该对应
|
userRepository.saveAll(organUserList);
|
||||||
// 一个List列表,此处需要重构Skill为列表
|
OnlineUserProxy.clean(super.getOrgi(request));
|
||||||
if (agentStatus != null) {
|
}
|
||||||
userProxy.attachOrgansPropertiesForUser(user);
|
|
||||||
agentStatus.setSkills(user.getSkills());
|
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ));
|
||||||
cache.putAgentStatusByOrgi(agentStatus, super.getOrgiByTenantshare(request));
|
}
|
||||||
}
|
|
||||||
}
|
@RequestMapping("/user/delete")
|
||||||
}
|
@Menu(type = "admin", subtype = "role")
|
||||||
userRepository.save(organUserList);
|
public ModelAndView userroledelete(
|
||||||
OnlineUserProxy.clean(super.getOrgi(request));
|
final HttpServletRequest request,
|
||||||
}
|
final @Valid String id,
|
||||||
|
final @Valid String organ
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ));
|
) {
|
||||||
}
|
logger.info("[userroledelete] user id {}, organ {}", id, organ);
|
||||||
|
if (id != null) {
|
||||||
@RequestMapping("/user/delete")
|
organUserRes.deleteOrganUserByUseridAndOrgan(id, organ);
|
||||||
@Menu(type = "admin", subtype = "role")
|
OnlineUserProxy.clean(super.getOrgi(request));
|
||||||
public ModelAndView userroledelete(
|
}
|
||||||
final HttpServletRequest request,
|
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ));
|
||||||
final @Valid String id,
|
}
|
||||||
final @Valid String organ
|
|
||||||
) {
|
@RequestMapping("/edit")
|
||||||
logger.info("[userroledelete] user id {}, organ {}", id, organ);
|
@Menu(type = "admin", subtype = "organ")
|
||||||
if (id != null) {
|
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
|
||||||
organUserRes.deleteOrganUserByUseridAndOrgan(id, organ);
|
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/organ/edit"));
|
||||||
OnlineUserProxy.clean(super.getOrgi(request));
|
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
|
||||||
}
|
view.addObject("organData", organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ));
|
|
||||||
}
|
map.addAttribute(
|
||||||
|
"organList", organRepository.findByOrgiAndOrgid(
|
||||||
@RequestMapping("/edit")
|
super.getOrgiByTenantshare(request),
|
||||||
@Menu(type = "admin", subtype = "organ")
|
super.getOrgid(request)));
|
||||||
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
|
return view;
|
||||||
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/organ/edit"));
|
}
|
||||||
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
|
|
||||||
view.addObject("organData", organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
|
@RequestMapping("/update")
|
||||||
|
@Menu(type = "admin", subtype = "organ")
|
||||||
map.addAttribute(
|
public ModelAndView update(HttpServletRequest request, @Valid Organ organ) {
|
||||||
"organList", organRepository.findByOrgiAndOrgid(
|
String msg = organProxy.updateOrgan(organ, super.getOrgi(request), super.getUser(request));
|
||||||
super.getOrgiByTenantshare(request),
|
return request(super.createRequestPageTempletResponse(
|
||||||
super.getOrgid(request)));
|
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + organ.getId()));
|
||||||
return view;
|
}
|
||||||
}
|
|
||||||
|
@RequestMapping("/area")
|
||||||
@RequestMapping("/update")
|
@Menu(type = "admin", subtype = "area")
|
||||||
@Menu(type = "admin", subtype = "organ")
|
public ModelAndView area(ModelMap map, HttpServletRequest request, @Valid String id) {
|
||||||
public ModelAndView update(HttpServletRequest request, @Valid Organ organ) {
|
|
||||||
String msg = organProxy.updateOrgan(organ, super.getOrgi(request), super.getUser(request));
|
SysDic sysDic = sysDicRepository.findByCode(Constants.CSKEFU_SYSTEM_AREA_DIC);
|
||||||
return request(super.createRequestPageTempletResponse(
|
if (sysDic != null) {
|
||||||
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + organ.getId()));
|
map.addAttribute("sysarea", sysDic);
|
||||||
}
|
map.addAttribute("areaList", sysDicRepository.findByDicid(sysDic.getId()));
|
||||||
|
}
|
||||||
@RequestMapping("/area")
|
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC));
|
||||||
@Menu(type = "admin", subtype = "area")
|
|
||||||
public ModelAndView area(ModelMap map, HttpServletRequest request, @Valid String id) {
|
map.addAttribute("organData", organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
|
||||||
|
return request(super.createRequestPageTempletResponse("/admin/organ/area"));
|
||||||
SysDic sysDic = sysDicRepository.findByCode(Constants.CSKEFU_SYSTEM_AREA_DIC);
|
}
|
||||||
if (sysDic != null) {
|
|
||||||
map.addAttribute("sysarea", sysDic);
|
|
||||||
map.addAttribute("areaList", sysDicRepository.findByDicid(sysDic.getId()));
|
@RequestMapping("/area/update")
|
||||||
}
|
@Menu(type = "admin", subtype = "organ")
|
||||||
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC));
|
public ModelAndView areaupdate(HttpServletRequest request, @Valid Organ organ) {
|
||||||
|
Organ tempOrgan = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgiByTenantshare(request));
|
||||||
map.addAttribute("organData", organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
|
String msg = "admin_organ_update_success";
|
||||||
return request(super.createRequestPageTempletResponse("/admin/organ/area"));
|
if (tempOrgan != null) {
|
||||||
}
|
tempOrgan.setArea(organ.getArea());
|
||||||
|
organRepository.save(tempOrgan);
|
||||||
|
OnlineUserProxy.clean(super.getOrgi(request));
|
||||||
@RequestMapping("/area/update")
|
} else {
|
||||||
@Menu(type = "admin", subtype = "organ")
|
msg = "admin_organ_update_not_exist";
|
||||||
public ModelAndView areaupdate(HttpServletRequest request, @Valid Organ organ) {
|
}
|
||||||
Organ tempOrgan = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgiByTenantshare(request));
|
return request(super.createRequestPageTempletResponse(
|
||||||
String msg = "admin_organ_update_success";
|
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + organ.getId()));
|
||||||
if (tempOrgan != null) {
|
}
|
||||||
tempOrgan.setArea(organ.getArea());
|
|
||||||
organRepository.save(tempOrgan);
|
@RequestMapping("/delete")
|
||||||
OnlineUserProxy.clean(super.getOrgi(request));
|
@Menu(type = "admin", subtype = "organ")
|
||||||
} else {
|
public ModelAndView delete(HttpServletRequest request, @Valid Organ organ) {
|
||||||
msg = "admin_organ_update_not_exist";
|
String msg = "admin_organ_delete";
|
||||||
}
|
|
||||||
return request(super.createRequestPageTempletResponse(
|
if (organ != null) {
|
||||||
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + organ.getId()));
|
Organ organSelf = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgiByTenantshare(request));
|
||||||
}
|
List<Organ> organParentAre = organRepository.findByOrgiAndParent(organSelf.getOrgi(), organSelf.getId());
|
||||||
|
if (organParentAre != null && organParentAre.size() > 0) {
|
||||||
@RequestMapping("/delete")
|
msg = "admin_oran_not_delete";
|
||||||
@Menu(type = "admin", subtype = "organ")
|
} else {
|
||||||
public ModelAndView delete(HttpServletRequest request, @Valid Organ organ) {
|
List<OrganUser> organUsers = organUserRes.findByOrgan(organ.getId());
|
||||||
String msg = "admin_organ_delete";
|
organUserRes.deleteInBatch(organUsers);
|
||||||
|
organRepository.delete(organ);
|
||||||
Organ organSelf = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgiByTenantshare(request));
|
OnlineUserProxy.clean(super.getOrgi(request));
|
||||||
List<Organ> organParentAre = organRepository.findByOrgiAndParent(organSelf.getOrgi(), organSelf.getId());
|
}
|
||||||
if (organ != null && organParentAre != null && organParentAre.size() > 0) {
|
}
|
||||||
msg = "admin_oran_not_delete";
|
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?msg=" + msg));
|
||||||
} else if (organ != null) {
|
}
|
||||||
List<OrganUser> organUsers = organUserRes.findByOrgan(organ.getId());
|
|
||||||
organUserRes.deleteInBatch(organUsers);
|
@RequestMapping("/auth/save")
|
||||||
organRepository.delete(organ);
|
@Menu(type = "admin", subtype = "role")
|
||||||
OnlineUserProxy.clean(super.getOrgi(request));
|
public ModelAndView authsave(HttpServletRequest request, @Valid String id, @Valid String menus) {
|
||||||
} else {
|
Organ organData = organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request));
|
||||||
msg = "admin_organ_not_exist";
|
List<OrganRole> organRoleList = organRoleRes.findByOrgiAndOrgan(super.getOrgiByTenantshare(request), organData);
|
||||||
}
|
organRoleRes.deleteAll(organRoleList);
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?msg=" + msg));
|
if (!StringUtils.isBlank(menus)) {
|
||||||
}
|
String[] menusarray = menus.split(",");
|
||||||
|
for (String menu : menusarray) {
|
||||||
@RequestMapping("/auth/save")
|
OrganRole organRole = new OrganRole();
|
||||||
@Menu(type = "admin", subtype = "role")
|
SysDic sysDic = Dict.getInstance().getDicItem(menu);
|
||||||
public ModelAndView authsave(HttpServletRequest request, @Valid String id, @Valid String menus) {
|
if (sysDic != null && !"0".equals(sysDic.getParentid())) {
|
||||||
Organ organData = organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request));
|
organRole.setDicid(menu);
|
||||||
List<OrganRole> organRoleList = organRoleRes.findByOrgiAndOrgan(super.getOrgiByTenantshare(request), organData);
|
organRole.setDicvalue(sysDic.getCode());
|
||||||
organRoleRes.delete(organRoleList);
|
|
||||||
if (!StringUtils.isBlank(menus)) {
|
organRole.setOrgan(organData);
|
||||||
String[] menusarray = menus.split(",");
|
organRole.setCreater(super.getUser(request).getId());
|
||||||
for (String menu : menusarray) {
|
organRole.setOrgi(super.getOrgiByTenantshare(request));
|
||||||
OrganRole organRole = new OrganRole();
|
organRole.setCreatetime(new Date());
|
||||||
SysDic sysDic = Dict.getInstance().getDicItem(menu);
|
organRoleRes.save(organRole);
|
||||||
if (sysDic != null && !"0".equals(sysDic.getParentid())) {
|
}
|
||||||
organRole.setDicid(menu);
|
|
||||||
organRole.setDicvalue(sysDic.getCode());
|
}
|
||||||
|
}
|
||||||
organRole.setOrgan(organData);
|
return request(
|
||||||
organRole.setCreater(super.getUser(request).getId());
|
super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organData.getId()));
|
||||||
organRole.setOrgi(super.getOrgiByTenantshare(request));
|
}
|
||||||
organRole.setCreatetime(new Date());
|
}
|
||||||
organRoleRes.save(organRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return request(
|
|
||||||
super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organData.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -22,11 +22,12 @@ import com.chatopera.cc.controller.Handler;
|
|||||||
import com.chatopera.cc.model.*;
|
import com.chatopera.cc.model.*;
|
||||||
import com.chatopera.cc.persistence.repository.*;
|
import com.chatopera.cc.persistence.repository.*;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -38,25 +39,26 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/admin/role")
|
@RequestMapping("/admin/role")
|
||||||
public class RoleController extends Handler {
|
public class RoleController extends Handler {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(RoleController.class);
|
private final static Logger logger = LoggerFactory.getLogger(RoleController.class);
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private RoleRepository roleRepository;
|
private final RoleRepository roleRepository;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private UserRoleRepository userRoleRes;
|
private final UserRoleRepository userRoleRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private RoleAuthRepository roleAuthRes;
|
private final RoleAuthRepository roleAuthRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private SysDicRepository sysDicRes;
|
private final SysDicRepository sysDicRes;
|
||||||
|
|
||||||
@RequestMapping("/index")
|
@RequestMapping("/index")
|
||||||
@Menu(type = "admin", subtype = "role")
|
@Menu(type = "admin", subtype = "role")
|
||||||
@ -85,7 +87,7 @@ public class RoleController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/add")
|
@RequestMapping("/add")
|
||||||
@Menu(type = "admin", subtype = "role")
|
@Menu(type = "admin", subtype = "role")
|
||||||
public ModelAndView add(ModelMap map, HttpServletRequest request) {
|
public ModelAndView add() {
|
||||||
return request(super.createRequestPageTempletResponse("/admin/role/add"));
|
return request(super.createRequestPageTempletResponse("/admin/role/add"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,10 +137,10 @@ public class RoleController extends Handler {
|
|||||||
for (UserRole userRole : userRoleList) {
|
for (UserRole userRole : userRoleList) {
|
||||||
if (user.equals(userRole.getUser().getId())) {
|
if (user.equals(userRole.getUser().getId())) {
|
||||||
exist = true;
|
exist = true;
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exist == false) {
|
if (!exist) {
|
||||||
UserRole userRole = new UserRole();
|
UserRole userRole = new UserRole();
|
||||||
userRole.setUser(new User(user));
|
userRole.setUser(new User(user));
|
||||||
userRole.setRole(new Role(role));
|
userRole.setRole(new Role(role));
|
||||||
@ -153,16 +155,16 @@ public class RoleController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/user/delete")
|
@RequestMapping("/user/delete")
|
||||||
@Menu(type = "admin", subtype = "role")
|
@Menu(type = "admin", subtype = "role")
|
||||||
public ModelAndView userroledelete(HttpServletRequest request, @Valid String id, @Valid String role) {
|
public ModelAndView userroledelete(@Valid String id, @Valid String role) {
|
||||||
if (role != null) {
|
if (role != null) {
|
||||||
userRoleRes.delete(id);
|
userRoleRes.deleteById(id);
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?role=" + role));
|
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?role=" + role));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/edit")
|
@RequestMapping("/edit")
|
||||||
@Menu(type = "admin", subtype = "role")
|
@Menu(type = "admin", subtype = "role")
|
||||||
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
|
public ModelAndView edit(HttpServletRequest request, @Valid String id) {
|
||||||
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/role/edit"));
|
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/role/edit"));
|
||||||
view.addObject("roleData", roleRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
|
view.addObject("roleData", roleRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
|
||||||
return view;
|
return view;
|
||||||
@ -197,7 +199,7 @@ public class RoleController extends Handler {
|
|||||||
public ModelAndView delete(HttpServletRequest request, @Valid Role role) {
|
public ModelAndView delete(HttpServletRequest request, @Valid Role role) {
|
||||||
String msg = "admin_role_delete";
|
String msg = "admin_role_delete";
|
||||||
if (role != null) {
|
if (role != null) {
|
||||||
userRoleRes.delete(userRoleRes.findByOrgiAndRole(super.getOrgiByTenantshare(request), role));
|
userRoleRes.deleteAll(userRoleRes.findByOrgiAndRole(super.getOrgiByTenantshare(request), role));
|
||||||
roleRepository.delete(role);
|
roleRepository.delete(role);
|
||||||
} else {
|
} else {
|
||||||
msg = "admin_role_not_exist";
|
msg = "admin_role_not_exist";
|
||||||
@ -226,7 +228,7 @@ public class RoleController extends Handler {
|
|||||||
logger.info("[authsave] id {}, menus {}", id, menus);
|
logger.info("[authsave] id {}, menus {}", id, menus);
|
||||||
|
|
||||||
List<RoleAuth> roleAuthList = roleAuthRes.findByRoleidAndOrgi(id, super.getOrgiByTenantshare(request));
|
List<RoleAuth> roleAuthList = roleAuthRes.findByRoleidAndOrgi(id, super.getOrgiByTenantshare(request));
|
||||||
roleAuthRes.delete(roleAuthList);
|
roleAuthRes.deleteAll(roleAuthList);
|
||||||
if (StringUtils.isNotBlank(menus)) {
|
if (StringUtils.isNotBlank(menus)) {
|
||||||
String[] menuarray = menus.split(",");
|
String[] menuarray = menus.split(",");
|
||||||
|
|
||||||
|
@ -21,13 +21,16 @@ import com.chatopera.cc.controller.Handler;
|
|||||||
import com.chatopera.cc.model.SysDic;
|
import com.chatopera.cc.model.SysDic;
|
||||||
import com.chatopera.cc.persistence.repository.SysDicRepository;
|
import com.chatopera.cc.persistence.repository.SysDicRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
import org.springframework.data.domain.Sort.Direction;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -36,15 +39,14 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/admin/sysdic")
|
@RequestMapping("/admin/sysdic")
|
||||||
public class SysDicController extends Handler {
|
public class SysDicController extends Handler {
|
||||||
|
@NonNull
|
||||||
|
private final SysDicRepository sysDicRes;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Autowired
|
private final Cache cache;
|
||||||
private SysDicRepository sysDicRes;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Cache cache;
|
|
||||||
|
|
||||||
@RequestMapping("/index")
|
@RequestMapping("/index")
|
||||||
@Menu(type = "admin", subtype = "sysdic")
|
@Menu(type = "admin", subtype = "sysdic")
|
||||||
@ -55,7 +57,7 @@ public class SysDicController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/add")
|
@RequestMapping("/add")
|
||||||
@Menu(type = "admin", subtype = "sysdic")
|
@Menu(type = "admin", subtype = "sysdic")
|
||||||
public ModelAndView add(ModelMap map, HttpServletRequest request) {
|
public ModelAndView add() {
|
||||||
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/add"));
|
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/add"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +82,7 @@ public class SysDicController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/edit")
|
@RequestMapping("/edit")
|
||||||
@Menu(type = "admin", subtype = "sysdic")
|
@Menu(type = "admin", subtype = "sysdic")
|
||||||
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
|
public ModelAndView edit(ModelMap map, @Valid String id, @Valid String p) {
|
||||||
map.addAttribute("sysDic", sysDicRes.findById(id));
|
map.addAttribute("sysDic", sysDicRes.findById(id));
|
||||||
map.addAttribute("p", p);
|
map.addAttribute("p", p);
|
||||||
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/edit"));
|
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/edit"));
|
||||||
@ -91,7 +93,8 @@ public class SysDicController extends Handler {
|
|||||||
public ModelAndView update(HttpServletRequest request, @Valid SysDic dic, @Valid String p) {
|
public ModelAndView update(HttpServletRequest request, @Valid SysDic dic, @Valid String p) {
|
||||||
List<SysDic> sysDicList = sysDicRes.findByCodeOrName(dic.getCode(), dic.getName());
|
List<SysDic> sysDicList = sysDicRes.findByCodeOrName(dic.getCode(), dic.getName());
|
||||||
if (sysDicList.size() == 0 || (sysDicList.size() == 1 && sysDicList.get(0).getId().equals(dic.getId()))) {
|
if (sysDicList.size() == 0 || (sysDicList.size() == 1 && sysDicList.get(0).getId().equals(dic.getId()))) {
|
||||||
SysDic sysDic = sysDicRes.findById(dic.getId());
|
SysDic sysDic = sysDicRes.findById(dic.getId())
|
||||||
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Value not found for " + dic.getId()));
|
||||||
sysDic.setName(dic.getName());
|
sysDic.setName(dic.getName());
|
||||||
sysDic.setCode(dic.getCode());
|
sysDic.setCode(dic.getCode());
|
||||||
sysDic.setCtype(dic.getCtype());
|
sysDic.setCtype(dic.getCtype());
|
||||||
@ -107,9 +110,10 @@ public class SysDicController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
@Menu(type = "admin", subtype = "sysdic")
|
@Menu(type = "admin", subtype = "sysdic")
|
||||||
public ModelAndView delete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
|
public ModelAndView delete(HttpServletRequest request, @Valid String id, @Valid String p) {
|
||||||
SysDic sysDic = sysDicRes.findById(id);
|
SysDic sysDic = sysDicRes.findById(id)
|
||||||
sysDicRes.delete(sysDicRes.findByDicid(id));
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Value not found for " + id));
|
||||||
|
sysDicRes.deleteAll(sysDicRes.findByDicid(id));
|
||||||
sysDicRes.delete(sysDic);
|
sysDicRes.delete(sysDic);
|
||||||
|
|
||||||
reloadSysDicItem(sysDic, super.getOrgi(request));
|
reloadSysDicItem(sysDic, super.getOrgi(request));
|
||||||
@ -127,7 +131,7 @@ public class SysDicController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/dicitem/add")
|
@RequestMapping("/dicitem/add")
|
||||||
@Menu(type = "admin", subtype = "sysdic")
|
@Menu(type = "admin", subtype = "sysdic")
|
||||||
public ModelAndView dicitemadd(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
|
public ModelAndView dicitemadd(ModelMap map, @Valid String id, @Valid String p) {
|
||||||
map.addAttribute("sysDic", sysDicRes.findById(id));
|
map.addAttribute("sysDic", sysDicRes.findById(id));
|
||||||
map.addAttribute("p", p);
|
map.addAttribute("p", p);
|
||||||
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/dicitemadd"));
|
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/dicitemadd"));
|
||||||
@ -154,8 +158,6 @@ public class SysDicController extends Handler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新系统词典缓存
|
* 更新系统词典缓存
|
||||||
* @param dic
|
|
||||||
* @param orgi
|
|
||||||
*/
|
*/
|
||||||
public void reloadSysDicItem(final SysDic dic, final String orgi) {
|
public void reloadSysDicItem(final SysDic dic, final String orgi) {
|
||||||
cache.putSysDicByOrgi(dic.getId(), orgi, dic);
|
cache.putSysDicByOrgi(dic.getId(), orgi, dic);
|
||||||
@ -176,7 +178,7 @@ public class SysDicController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/dicitem/batadd")
|
@RequestMapping("/dicitem/batadd")
|
||||||
@Menu(type = "admin", subtype = "sysdic")
|
@Menu(type = "admin", subtype = "sysdic")
|
||||||
public ModelAndView dicitembatadd(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
|
public ModelAndView dicitembatadd(ModelMap map, @Valid String id, @Valid String p) {
|
||||||
map.addAttribute("sysDic", sysDicRes.findById(id));
|
map.addAttribute("sysDic", sysDicRes.findById(id));
|
||||||
map.addAttribute("p", p);
|
map.addAttribute("p", p);
|
||||||
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/batadd"));
|
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/batadd"));
|
||||||
@ -185,11 +187,11 @@ public class SysDicController extends Handler {
|
|||||||
@RequestMapping("/dicitem/batsave")
|
@RequestMapping("/dicitem/batsave")
|
||||||
@Menu(type = "admin", subtype = "sysdic")
|
@Menu(type = "admin", subtype = "sysdic")
|
||||||
public ModelAndView dicitembatsave(HttpServletRequest request, @Valid SysDic sysDic, @Valid String content, @Valid String p) {
|
public ModelAndView dicitembatsave(HttpServletRequest request, @Valid SysDic sysDic, @Valid String content, @Valid String p) {
|
||||||
String[] dicitems = content.split("[\n\r\n]");
|
String[] dicitems = content.split("[\n\r]");
|
||||||
int count = 0;
|
int count = 0;
|
||||||
String orig = super.getOrgi(request);
|
String orig = super.getOrgi(request);
|
||||||
for (String dicitem : dicitems) {
|
for (String dicitem : dicitems) {
|
||||||
String[] dicValues = dicitem.split("[\t, ;]{1,}");
|
String[] dicValues = dicitem.split("[\t, ;]+");
|
||||||
if (dicValues.length == 2 && dicValues[0].length() > 0 && dicValues[1].length() > 0) {
|
if (dicValues.length == 2 && dicValues[0].length() > 0 && dicValues[1].length() > 0) {
|
||||||
SysDic dic = new SysDic();
|
SysDic dic = new SysDic();
|
||||||
dic.setOrgi(orig);
|
dic.setOrgi(orig);
|
||||||
@ -215,7 +217,7 @@ public class SysDicController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/dicitem/edit")
|
@RequestMapping("/dicitem/edit")
|
||||||
@Menu(type = "admin", subtype = "sysdic")
|
@Menu(type = "admin", subtype = "sysdic")
|
||||||
public ModelAndView dicitemedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
|
public ModelAndView dicitemedit(ModelMap map, @Valid String id, @Valid String p) {
|
||||||
map.addAttribute("sysDic", sysDicRes.findById(id));
|
map.addAttribute("sysDic", sysDicRes.findById(id));
|
||||||
map.addAttribute("p", p);
|
map.addAttribute("p", p);
|
||||||
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/dicitemedit"));
|
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/dicitemedit"));
|
||||||
@ -227,7 +229,8 @@ public class SysDicController extends Handler {
|
|||||||
List<SysDic> sysDicList = sysDicRes.findByDicidAndName(dic.getDicid(), dic.getName());
|
List<SysDic> sysDicList = sysDicRes.findByDicidAndName(dic.getDicid(), dic.getName());
|
||||||
String orgi = super.getOrgi(request);
|
String orgi = super.getOrgi(request);
|
||||||
if (sysDicList.size() == 0 || (sysDicList.size() == 1 && sysDicList.get(0).getId().equals(dic.getId()))) {
|
if (sysDicList.size() == 0 || (sysDicList.size() == 1 && sysDicList.get(0).getId().equals(dic.getId()))) {
|
||||||
SysDic sysDic = sysDicRes.findById(dic.getId());
|
SysDic sysDic = sysDicRes.findById(dic.getId())
|
||||||
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Value not found for " + dic.getId()));
|
||||||
sysDic.setName(dic.getName());
|
sysDic.setName(dic.getName());
|
||||||
sysDic.setCode(dic.getCode());
|
sysDic.setCode(dic.getCode());
|
||||||
sysDic.setCtype(dic.getCtype());
|
sysDic.setCtype(dic.getCtype());
|
||||||
@ -245,8 +248,8 @@ public class SysDicController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/dicitem/delete")
|
@RequestMapping("/dicitem/delete")
|
||||||
@Menu(type = "admin", subtype = "sysdic")
|
@Menu(type = "admin", subtype = "sysdic")
|
||||||
public ModelAndView dicitemdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
|
public ModelAndView dicitemdelete(HttpServletRequest request, @Valid String id, @Valid String p) {
|
||||||
sysDicRes.delete(sysDicRes.findByDicid(id));
|
sysDicRes.deleteAll(sysDicRes.findByDicid(id));
|
||||||
SysDic dic = sysDicRes.getOne(id);
|
SysDic dic = sysDicRes.getOne(id);
|
||||||
sysDicRes.delete(dic);
|
sysDicRes.delete(dic);
|
||||||
reloadSysDicItem(dic, super.getOrgi(request));
|
reloadSysDicItem(dic, super.getOrgi(request));
|
||||||
|
@ -1,192 +1,189 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.chatopera.cc.controller.admin.system;
|
package com.chatopera.cc.controller.admin.system;
|
||||||
|
|
||||||
import com.chatopera.cc.basic.Constants;
|
import com.chatopera.cc.basic.Constants;
|
||||||
import com.chatopera.cc.basic.MainUtils;
|
import com.chatopera.cc.basic.MainUtils;
|
||||||
import com.chatopera.cc.cache.Cache;
|
import com.chatopera.cc.cache.Cache;
|
||||||
import com.chatopera.cc.controller.Handler;
|
import com.chatopera.cc.controller.Handler;
|
||||||
import com.chatopera.cc.model.Dict;
|
import com.chatopera.cc.model.Dict;
|
||||||
import com.chatopera.cc.model.SysDic;
|
import com.chatopera.cc.model.SysDic;
|
||||||
import com.chatopera.cc.model.Template;
|
import com.chatopera.cc.model.Template;
|
||||||
import com.chatopera.cc.persistence.repository.SysDicRepository;
|
import com.chatopera.cc.persistence.repository.SysDicRepository;
|
||||||
import com.chatopera.cc.persistence.repository.TemplateRepository;
|
import com.chatopera.cc.persistence.repository.TemplateRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.Valid;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.text.SimpleDateFormat;
|
import javax.validation.Valid;
|
||||||
import java.util.Date;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
@Controller
|
|
||||||
@RequestMapping("/admin/template")
|
@Controller
|
||||||
public class TemplateController extends Handler{
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/admin/template")
|
||||||
|
public class TemplateController extends Handler {
|
||||||
@Autowired
|
|
||||||
private TemplateRepository templateRes;
|
@NonNull
|
||||||
|
private final TemplateRepository templateRes;
|
||||||
@Autowired
|
|
||||||
private SysDicRepository dicRes;
|
@NonNull
|
||||||
|
private final SysDicRepository dicRes;
|
||||||
@Autowired
|
|
||||||
private Cache cache;
|
@NonNull
|
||||||
|
private final Cache cache;
|
||||||
@RequestMapping("/index")
|
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
@RequestMapping("/index")
|
||||||
public ModelAndView index(ModelMap map , HttpServletRequest request) {
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
map.addAttribute("sysDicList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_DIC));
|
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
||||||
return request(super.createAdminTempletResponse("/admin/system/template/index"));
|
map.addAttribute("sysDicList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_DIC));
|
||||||
}
|
return request(super.createAdminTempletResponse("/admin/system/template/index"));
|
||||||
|
}
|
||||||
@RequestMapping("/expall")
|
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
@RequestMapping("/expall")
|
||||||
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response) throws Exception {
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
List<Template> templateList = templateRes.findByOrgi(super.getOrgi(request)) ;
|
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Template-Export-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".data");
|
List<Template> templateList = templateRes.findByOrgi(super.getOrgi(request));
|
||||||
response.getOutputStream().write(MainUtils.toBytes(templateList));
|
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Template-Export-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".data");
|
||||||
return ;
|
response.getOutputStream().write(MainUtils.toBytes(templateList));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
@RequestMapping("/imp")
|
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
@RequestMapping("/imp")
|
||||||
public ModelAndView imp(ModelMap map , HttpServletRequest request) {
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
return request(super.createRequestPageTempletResponse("/admin/system/template/imp"));
|
public ModelAndView imp(ModelMap map, HttpServletRequest request) {
|
||||||
}
|
return request(super.createRequestPageTempletResponse("/admin/system/template/imp"));
|
||||||
|
}
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@RequestMapping("/impsave")
|
@SuppressWarnings("unchecked")
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
@RequestMapping("/impsave")
|
||||||
public ModelAndView impsave(ModelMap map , HttpServletRequest request , @RequestParam(value = "dataFile", required = false) MultipartFile dataFile) throws Exception {
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
if(dataFile!=null && dataFile.getSize() > 0){
|
public ModelAndView impsave(ModelMap map, HttpServletRequest request, @RequestParam(value = "dataFile", required = false) MultipartFile dataFile) throws Exception {
|
||||||
List<Template> templateList = (List<Template>) MainUtils.toObject(dataFile.getBytes()) ;
|
if (dataFile != null && dataFile.getSize() > 0) {
|
||||||
if(templateList!=null && templateList.size() >0){
|
List<Template> templateList = (List<Template>) MainUtils.toObject(dataFile.getBytes());
|
||||||
templateRes.deleteInBatch(templateList);
|
if (templateList != null && templateList.size() > 0) {
|
||||||
for(Template template : templateList){
|
templateRes.deleteInBatch(templateList);
|
||||||
templateRes.save(template) ;
|
for (Template template : templateList) {
|
||||||
}
|
templateRes.save(template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/template/index.html"));
|
}
|
||||||
}
|
return request(super.createRequestPageTempletResponse("redirect:/admin/template/index.html"));
|
||||||
|
}
|
||||||
@RequestMapping("/list")
|
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
@RequestMapping("/list")
|
||||||
public ModelAndView list(ModelMap map , HttpServletRequest request ,@Valid String type) {
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
map.addAttribute("sysDic", dicRes.findById(type));
|
public ModelAndView list(ModelMap map, HttpServletRequest request, @Valid String type) {
|
||||||
map.addAttribute("templateList", templateRes.findByTemplettypeAndOrgi(type, super.getOrgi(request)));
|
map.addAttribute("sysDic", dicRes.findById(type));
|
||||||
return request(super.createAdminTempletResponse("/admin/system/template/list"));
|
map.addAttribute("templateList", templateRes.findByTemplettypeAndOrgi(type, super.getOrgi(request)));
|
||||||
}
|
return request(super.createAdminTempletResponse("/admin/system/template/list"));
|
||||||
|
}
|
||||||
@RequestMapping("/add")
|
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
@RequestMapping("/add")
|
||||||
public ModelAndView add(ModelMap map , HttpServletRequest request ,@Valid String type) {
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
map.addAttribute("sysDic", dicRes.findById(type));
|
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String type) {
|
||||||
return request(super.createRequestPageTempletResponse("/admin/system/template/add"));
|
map.addAttribute("sysDic", dicRes.findById(type));
|
||||||
}
|
return request(super.createRequestPageTempletResponse("/admin/system/template/add"));
|
||||||
|
}
|
||||||
@RequestMapping( "/save")
|
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
@RequestMapping("/save")
|
||||||
public ModelAndView save(HttpServletRequest request , @Valid Template template) {
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
template.setOrgi(super.getOrgi(request));
|
public ModelAndView save(HttpServletRequest request, @Valid Template template) {
|
||||||
template.setCreatetime(new Date());
|
template.setOrgi(super.getOrgi(request));
|
||||||
|
template.setCreatetime(new Date());
|
||||||
SysDic dic = dicRes.findById(template.getTemplettype());
|
|
||||||
if(dic!=null && StringUtils.isBlank(template.getCode())) {
|
String dicId = template.getTemplettype();
|
||||||
template.setCode(dic.getCode());
|
SysDic dic = dicRes.findById(dicId).orElse(null);
|
||||||
}
|
if (dic != null && StringUtils.isBlank(template.getCode())) {
|
||||||
templateRes.save(template) ;
|
template.setCode(dic.getCode());
|
||||||
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type="+template.getTemplettype()));
|
templateRes.save(template);
|
||||||
}
|
|
||||||
|
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type=" + dicId));
|
||||||
@RequestMapping("/edit")
|
}
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
|
||||||
public ModelAndView edit(ModelMap map , HttpServletRequest request , @Valid String id, @Valid String type) {
|
@RequestMapping("/edit")
|
||||||
map.addAttribute("sysDic", dicRes.findById(type));
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request))) ;
|
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String type) {
|
||||||
return request(super.createRequestPageTempletResponse("/admin/system/template/edit"));
|
map.addAttribute("sysDic", dicRes.findById(type));
|
||||||
}
|
map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request)));
|
||||||
|
return request(super.createRequestPageTempletResponse("/admin/system/template/edit"));
|
||||||
@RequestMapping( "/update")
|
}
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
|
||||||
public ModelAndView update(HttpServletRequest request , @Valid Template template) {
|
@RequestMapping("/update")
|
||||||
Template oldTemplate = templateRes.findByIdAndOrgi(template.getId(), super.getOrgi(request)) ;
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
if(oldTemplate!=null){
|
public ModelAndView update(HttpServletRequest request, @Valid Template template) {
|
||||||
SysDic dic = dicRes.findById(oldTemplate.getTemplettype());
|
Template oldTemplate = templateRes.findByIdAndOrgi(template.getId(), super.getOrgi(request));
|
||||||
if(dic!=null) {
|
if (oldTemplate != null) {
|
||||||
oldTemplate.setCode(dic.getCode());
|
String dicId = oldTemplate.getTemplettype();
|
||||||
}
|
dicRes.findById(dicId).ifPresent(dic -> oldTemplate.setCode(dic.getCode()));
|
||||||
if(!StringUtils.isBlank(template.getCode())) {
|
if (!StringUtils.isBlank(template.getCode())) {
|
||||||
oldTemplate.setCode(template.getCode());
|
oldTemplate.setCode(template.getCode());
|
||||||
}
|
}
|
||||||
oldTemplate.setName(template.getName());
|
oldTemplate.setName(template.getName());
|
||||||
oldTemplate.setLayoutcols(template.getLayoutcols());
|
oldTemplate.setLayoutcols(template.getLayoutcols());
|
||||||
oldTemplate.setIconstr(template.getIconstr());
|
oldTemplate.setIconstr(template.getIconstr());
|
||||||
oldTemplate.setDatatype(template.getDatatype());
|
oldTemplate.setDatatype(template.getDatatype());
|
||||||
oldTemplate.setCharttype(template.getCharttype());
|
oldTemplate.setCharttype(template.getCharttype());
|
||||||
templateRes.save(oldTemplate) ;
|
templateRes.save(oldTemplate);
|
||||||
|
|
||||||
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));
|
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type="+template.getTemplettype()));
|
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type=" + template.getTemplettype()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/code")
|
@RequestMapping("/code")
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
public ModelAndView code(ModelMap map , HttpServletRequest request , @Valid String id, @Valid String type) {
|
public ModelAndView code(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String type) {
|
||||||
map.addAttribute("sysDic", dicRes.findById(type));
|
map.addAttribute("sysDic", dicRes.findById(type));
|
||||||
map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request))) ;
|
map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request)));
|
||||||
return request(super.createRequestPageTempletResponse("/admin/system/template/code"));
|
return request(super.createRequestPageTempletResponse("/admin/system/template/code"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping( "/codesave")
|
@RequestMapping("/codesave")
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
public ModelAndView codesave(HttpServletRequest request , @Valid Template template) {
|
public ModelAndView codesave(HttpServletRequest request, @Valid Template template) {
|
||||||
Template oldTemplate = templateRes.findByIdAndOrgi(template.getId(), super.getOrgi(request)) ;
|
Template oldTemplate = templateRes.findByIdAndOrgi(template.getId(), super.getOrgi(request));
|
||||||
if(oldTemplate!=null){
|
if (oldTemplate != null) {
|
||||||
oldTemplate.setTemplettext(template.getTemplettext());
|
oldTemplate.setTemplettext(template.getTemplettext());
|
||||||
oldTemplate.setTemplettitle(template.getTemplettitle());
|
oldTemplate.setTemplettitle(template.getTemplettitle());
|
||||||
templateRes.save(oldTemplate) ;
|
templateRes.save(oldTemplate);
|
||||||
|
|
||||||
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));
|
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type="+template.getTemplettype()));
|
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type=" + template.getTemplettype()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
|
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||||
public ModelAndView delete(HttpServletRequest request ,@Valid Template template) {
|
public ModelAndView delete(HttpServletRequest request, @Valid Template template) {
|
||||||
if(template!=null){
|
templateRes.delete(template);
|
||||||
templateRes.delete(template) ;
|
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));
|
||||||
|
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type=" + template.getTemplettype()));
|
||||||
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));
|
}
|
||||||
}
|
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type="+template.getTemplettype()));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -1,46 +1,46 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.chatopera.cc.persistence.repository;
|
package com.chatopera.cc.persistence.repository;
|
||||||
|
|
||||||
import com.chatopera.cc.model.SysDic;
|
import com.chatopera.cc.model.SysDic;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface SysDicRepository extends JpaRepository<SysDic, String>{
|
public interface SysDicRepository extends JpaRepository<SysDic, String> {
|
||||||
|
|
||||||
|
|
||||||
SysDic findById(String id);
|
// SysDic findById(String id);
|
||||||
|
|
||||||
SysDic findByCode(String code);
|
SysDic findByCode(String code);
|
||||||
|
|
||||||
Page<SysDic> findAll(Pageable paramPageable);
|
Page<SysDic> findAll(Pageable paramPageable);
|
||||||
|
|
||||||
List<SysDic> findByCodeOrName(String code, String name);
|
List<SysDic> findByCodeOrName(String code, String name);
|
||||||
|
|
||||||
List<SysDic> findByDicidAndName(String dicid, String name);
|
List<SysDic> findByDicidAndName(String dicid, String name);
|
||||||
|
|
||||||
Page<SysDic> findByParentid(String type, Pageable paramPageable);
|
Page<SysDic> findByParentid(String type, Pageable paramPageable);
|
||||||
|
|
||||||
List<SysDic> findByParentid(String type);
|
List<SysDic> findByParentid(String type);
|
||||||
|
|
||||||
List<SysDic> findByDicid(String id);
|
List<SysDic> findByDicid(String id);
|
||||||
|
|
||||||
int countByName(String name);
|
int countByName(String name);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user