mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
#122 支持更多自定义logo
This commit is contained in:
parent
a2ef70e7cb
commit
41763967a9
@ -21,9 +21,12 @@ import com.chatopera.cc.app.basic.MainUtils;
|
||||
import com.chatopera.cc.app.basic.Viewport;
|
||||
import com.chatopera.cc.app.cache.CacheHelper;
|
||||
import com.chatopera.cc.app.handler.api.rest.QueryParams;
|
||||
import com.chatopera.cc.app.model.StreamingFile;
|
||||
import com.chatopera.cc.app.model.SystemConfig;
|
||||
import com.chatopera.cc.app.model.Tenant;
|
||||
import com.chatopera.cc.app.model.User;
|
||||
import com.chatopera.cc.app.persistence.blob.JpaBlobHelper;
|
||||
import com.chatopera.cc.app.persistence.repository.StreamingFileRepository;
|
||||
import com.chatopera.cc.app.persistence.repository.TenantRepository;
|
||||
import com.chatopera.cc.exception.CSKefuException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -38,10 +41,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
||||
@ -56,6 +61,12 @@ public class Handler {
|
||||
@Autowired
|
||||
private TenantRepository tenantRes;
|
||||
|
||||
@Autowired
|
||||
private JpaBlobHelper jpaBlobHelper;
|
||||
|
||||
@Autowired
|
||||
private StreamingFileRepository streamingFileRes;
|
||||
|
||||
public final static int PAGE_SIZE_BG = 1;
|
||||
public final static int PAGE_SIZE_TW = 20;
|
||||
public final static int PAGE_SIZE_FV = 50;
|
||||
@ -461,4 +472,17 @@ public class Handler {
|
||||
public void setStarttime(long starttime) {
|
||||
this.starttime = starttime;
|
||||
}
|
||||
|
||||
public String saveImageFileWithMultipart(MultipartFile multipart) throws IOException {
|
||||
StreamingFile sf = new StreamingFile();
|
||||
final String fileid = MainUtils.getUUID();
|
||||
sf.setId(fileid);
|
||||
sf.setMime(multipart.getContentType());
|
||||
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
|
||||
sf.setName(multipart.getOriginalFilename());
|
||||
streamingFileRes.save(sf);
|
||||
return fileid;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -69,24 +69,6 @@ public class WebIMController extends Handler {
|
||||
@Autowired
|
||||
private SNSAccountRepository snsAccountRes;
|
||||
|
||||
@Autowired
|
||||
private JpaBlobHelper jpaBlobHelper;
|
||||
|
||||
@Autowired
|
||||
private StreamingFileRepository streamingFileRes;
|
||||
|
||||
|
||||
private String saveImageFile(MultipartFile multipart) throws IOException {
|
||||
StreamingFile sf = new StreamingFile();
|
||||
final String fileid = MainUtils.getUUID();
|
||||
sf.setId(fileid);
|
||||
sf.setMime(multipart.getContentType());
|
||||
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
|
||||
sf.setName(multipart.getOriginalFilename());
|
||||
streamingFileRes.save(sf);
|
||||
return fileid;
|
||||
}
|
||||
|
||||
@RequestMapping("/index")
|
||||
@Menu(type = "app", subtype = "app", admin = true)
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String snsid) {
|
||||
@ -125,12 +107,12 @@ public class WebIMController extends Handler {
|
||||
inviteData.setOrgi(super.getOrgi(request));
|
||||
// 网页品牌标识
|
||||
if (webimlogo != null && webimlogo.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
inviteData.setConsult_dialog_logo(saveImageFile(webimlogo));
|
||||
inviteData.setConsult_dialog_logo(super.saveImageFileWithMultipart(webimlogo));
|
||||
}
|
||||
|
||||
// 网页坐席头像
|
||||
if (agentheadimg != null && agentheadimg.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
inviteData.setConsult_dialog_headimg(saveImageFile(agentheadimg));
|
||||
inviteData.setConsult_dialog_headimg(super.saveImageFileWithMultipart(agentheadimg));
|
||||
}
|
||||
invite.save(inviteData);
|
||||
CacheHelper.getSystemCacheBean().put(inviteData.getSnsaccountid(), inviteData, inviteData.getOrgi());
|
||||
@ -208,7 +190,7 @@ public class WebIMController extends Handler {
|
||||
tempInviteData.setCtrlenter(inviteData.isCtrlenter());
|
||||
|
||||
if (dialogad != null && !StringUtils.isBlank(dialogad.getName()) && dialogad.getBytes() != null && dialogad.getBytes().length > 0) {
|
||||
tempInviteData.setDialog_ad(saveImageFile(dialogad));
|
||||
tempInviteData.setDialog_ad(super.saveImageFileWithMultipart(dialogad));
|
||||
}
|
||||
invite.save(tempInviteData);
|
||||
inviteData = tempInviteData;
|
||||
@ -248,7 +230,7 @@ public class WebIMController extends Handler {
|
||||
tempInviteData.setConsult_invite_color(inviteData.getConsult_invite_color());
|
||||
|
||||
if (invotebg != null && !StringUtils.isBlank(invotebg.getName()) && invotebg.getBytes() != null && invotebg.getBytes().length > 0) {
|
||||
tempInviteData.setConsult_invite_bg(saveImageFile(invotebg));
|
||||
tempInviteData.setConsult_invite_bg(super.saveImageFileWithMultipart(invotebg));
|
||||
}
|
||||
invite.save(tempInviteData);
|
||||
inviteData = tempInviteData;
|
||||
|
@ -16,28 +16,20 @@
|
||||
*/
|
||||
package com.chatopera.cc.app.handler.admin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.chatopera.cc.app.basic.MainContext;
|
||||
import com.chatopera.cc.app.basic.MainUtils;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.app.cache.CacheHelper;
|
||||
import com.chatopera.cc.app.handler.Handler;
|
||||
import com.chatopera.cc.app.model.Secret;
|
||||
import com.chatopera.cc.app.model.SysDic;
|
||||
import com.chatopera.cc.app.model.SystemConfig;
|
||||
import com.chatopera.cc.app.model.UKeFuDic;
|
||||
import com.chatopera.cc.app.persistence.repository.SecretRepository;
|
||||
import com.chatopera.cc.app.persistence.repository.SystemConfigRepository;
|
||||
import com.chatopera.cc.app.persistence.repository.SystemMessageRepository;
|
||||
import com.chatopera.cc.app.persistence.repository.TemplateRepository;
|
||||
import com.chatopera.cc.app.model.Secret;
|
||||
import com.chatopera.cc.app.model.SysDic;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.corundumstudio.socketio.SocketIOServer;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -50,222 +42,223 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.corundumstudio.socketio.SocketIOServer;
|
||||
import com.chatopera.cc.app.handler.Handler;
|
||||
import com.chatopera.cc.app.model.SystemConfig;
|
||||
import com.chatopera.cc.app.model.UKeFuDic;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin/config")
|
||||
public class SystemConfigController extends Handler{
|
||||
|
||||
@Value("${uk.im.server.port}")
|
||||
public class SystemConfigController extends Handler {
|
||||
|
||||
@Value("${uk.im.server.port}")
|
||||
private Integer port;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
|
||||
@Autowired
|
||||
private SocketIOServer server ;
|
||||
|
||||
@Autowired
|
||||
private SystemConfigRepository systemConfigRes ;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SystemMessageRepository systemMessageRes ;
|
||||
|
||||
@Autowired
|
||||
private SecretRepository secRes ;
|
||||
|
||||
@Autowired
|
||||
private TemplateRepository templateRes ;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SocketIOServer server;
|
||||
|
||||
@Autowired
|
||||
private SystemConfigRepository systemConfigRes;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SystemMessageRepository systemMessageRes;
|
||||
|
||||
@Autowired
|
||||
private SecretRepository secRes;
|
||||
|
||||
@Autowired
|
||||
private TemplateRepository templateRes;
|
||||
|
||||
@RequestMapping("/index")
|
||||
@Menu(type = "admin" , subtype = "config" , admin = true)
|
||||
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String execute) throws SQLException {
|
||||
map.addAttribute("server", server) ;
|
||||
if(MainContext.model.get("im")!=null){
|
||||
map.addAttribute("entim", MainContext.model.get("im")) ;
|
||||
}
|
||||
if(request.getSession().getAttribute(MainContext.UKEFU_SYSTEM_INFOACQ)!=null){
|
||||
map.addAttribute("entim", request.getSession().getAttribute(MainContext.UKEFU_SYSTEM_INFOACQ)) ;
|
||||
}
|
||||
map.addAttribute("server", server) ;
|
||||
map.addAttribute("imServerStatus", MainContext.getIMServerStatus()) ;
|
||||
List<Secret> secretConfig = secRes.findByOrgi(super.getOrgi(request)) ;
|
||||
if(secretConfig!=null && secretConfig.size() > 0){
|
||||
map.addAttribute("secret", secretConfig.get(0)) ;
|
||||
}
|
||||
List<SysDic> dicList = UKeFuDic.getInstance().getDic(MainContext.UKEFU_SYSTEM_DIC) ;
|
||||
SysDic callCenterDic = null , workOrderDic = null , smsDic = null ;
|
||||
for(SysDic dic : dicList){
|
||||
if(dic.getCode().equals(MainContext.UKEFU_SYSTEM_CALLCENTER)){
|
||||
callCenterDic = dic ;
|
||||
}
|
||||
if(dic.getCode().equals(MainContext.UKEFU_SYSTEM_WORKORDEREMAIL)){
|
||||
workOrderDic = dic ;
|
||||
}
|
||||
if(dic.getCode().equals(MainContext.UKEFU_SYSTEM_SMSEMAIL)){
|
||||
smsDic = dic ;
|
||||
}
|
||||
}
|
||||
if(callCenterDic!=null){
|
||||
map.addAttribute("templateList", templateRes.findByTemplettypeAndOrgi(callCenterDic.getId(), super.getOrgi(request))) ;
|
||||
}
|
||||
if(workOrderDic!=null){
|
||||
map.addAttribute("workOrderList", templateRes.findByTemplettypeAndOrgi(workOrderDic.getId(), super.getOrgi(request))) ;
|
||||
}
|
||||
if(smsDic!=null){
|
||||
map.addAttribute("smsList", templateRes.findByTemplettypeAndOrgi(smsDic.getId(), super.getOrgi(request))) ;
|
||||
}
|
||||
|
||||
map.addAttribute("sysMessageList", systemMessageRes.findByMsgtypeAndOrgi(MainContext.SystemMessageType.EMAIL.toString(), super.getOrgi(request))) ;
|
||||
|
||||
if(!StringUtils.isBlank(execute) && execute.equals("false")){
|
||||
map.addAttribute("execute", execute) ;
|
||||
}
|
||||
if(!StringUtils.isBlank(request.getParameter("msg"))){
|
||||
map.addAttribute("msg", request.getParameter("msg")) ;
|
||||
}
|
||||
@Menu(type = "admin", subtype = "config", admin = true)
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String execute) throws SQLException {
|
||||
map.addAttribute("server", server);
|
||||
if (MainContext.model.get("im") != null) {
|
||||
map.addAttribute("entim", MainContext.model.get("im"));
|
||||
}
|
||||
if (request.getSession().getAttribute(MainContext.UKEFU_SYSTEM_INFOACQ) != null) {
|
||||
map.addAttribute("entim", request.getSession().getAttribute(MainContext.UKEFU_SYSTEM_INFOACQ));
|
||||
}
|
||||
map.addAttribute("server", server);
|
||||
map.addAttribute("imServerStatus", MainContext.getIMServerStatus());
|
||||
List<Secret> secretConfig = secRes.findByOrgi(super.getOrgi(request));
|
||||
if (secretConfig != null && secretConfig.size() > 0) {
|
||||
map.addAttribute("secret", secretConfig.get(0));
|
||||
}
|
||||
List<SysDic> dicList = UKeFuDic.getInstance().getDic(MainContext.UKEFU_SYSTEM_DIC);
|
||||
SysDic callCenterDic = null, workOrderDic = null, smsDic = null;
|
||||
for (SysDic dic : dicList) {
|
||||
if (dic.getCode().equals(MainContext.UKEFU_SYSTEM_CALLCENTER)) {
|
||||
callCenterDic = dic;
|
||||
}
|
||||
if (dic.getCode().equals(MainContext.UKEFU_SYSTEM_WORKORDEREMAIL)) {
|
||||
workOrderDic = dic;
|
||||
}
|
||||
if (dic.getCode().equals(MainContext.UKEFU_SYSTEM_SMSEMAIL)) {
|
||||
smsDic = dic;
|
||||
}
|
||||
}
|
||||
if (callCenterDic != null) {
|
||||
map.addAttribute("templateList", templateRes.findByTemplettypeAndOrgi(callCenterDic.getId(), super.getOrgi(request)));
|
||||
}
|
||||
if (workOrderDic != null) {
|
||||
map.addAttribute("workOrderList", templateRes.findByTemplettypeAndOrgi(workOrderDic.getId(), super.getOrgi(request)));
|
||||
}
|
||||
if (smsDic != null) {
|
||||
map.addAttribute("smsList", templateRes.findByTemplettypeAndOrgi(smsDic.getId(), super.getOrgi(request)));
|
||||
}
|
||||
|
||||
map.addAttribute("sysMessageList", systemMessageRes.findByMsgtypeAndOrgi(MainContext.SystemMessageType.EMAIL.toString(), super.getOrgi(request)));
|
||||
|
||||
if (StringUtils.isNotBlank(execute) && execute.equals("false")) {
|
||||
map.addAttribute("execute", execute);
|
||||
}
|
||||
if (StringUtils.isNotBlank(request.getParameter("msg"))) {
|
||||
map.addAttribute("msg", request.getParameter("msg"));
|
||||
}
|
||||
return request(super.createAdminTempletResponse("/admin/config/index"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/stopimserver")
|
||||
@Menu(type = "admin" , subtype = "stopimserver" , access = false , admin = true)
|
||||
public ModelAndView stopimserver(ModelMap map , HttpServletRequest request , @Valid String confirm) throws SQLException {
|
||||
boolean execute = false ;
|
||||
if(execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)){
|
||||
server.stop();
|
||||
MainContext.setIMServerStatus(false);
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute="+execute));
|
||||
@Menu(type = "admin", subtype = "stopimserver", access = false, admin = true)
|
||||
public ModelAndView stopimserver(ModelMap map, HttpServletRequest request, @Valid String confirm) throws SQLException {
|
||||
boolean execute = false;
|
||||
if (execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)) {
|
||||
server.stop();
|
||||
MainContext.setIMServerStatus(false);
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute=" + execute));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/startentim")
|
||||
@Menu(type = "admin" , subtype = "startentim" , access = false , admin = true)
|
||||
public ModelAndView startentim(ModelMap map , HttpServletRequest request) throws SQLException {
|
||||
MainContext.model.put("im", true) ;
|
||||
@Menu(type = "admin", subtype = "startentim", access = false, admin = true)
|
||||
public ModelAndView startentim(ModelMap map, HttpServletRequest request) throws SQLException {
|
||||
MainContext.model.put("im", true);
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/stopentim")
|
||||
@Menu(type = "admin" , subtype = "stopentim" , access = false , admin = true)
|
||||
public ModelAndView stopentim(ModelMap map , HttpServletRequest request) throws SQLException {
|
||||
MainContext.model.remove("im") ;
|
||||
@Menu(type = "admin", subtype = "stopentim", access = false, admin = true)
|
||||
public ModelAndView stopentim(ModelMap map, HttpServletRequest request) throws SQLException {
|
||||
MainContext.model.remove("im");
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 危险操作,请谨慎调用 , WebLogic/WebSphere/Oracle等中间件服务器禁止调用
|
||||
*
|
||||
* @param map
|
||||
* @param request
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
@RequestMapping("/stop")
|
||||
@Menu(type = "admin" , subtype = "stop" , access = false , admin = true)
|
||||
public ModelAndView stop(ModelMap map , HttpServletRequest request , @Valid String confirm) throws SQLException {
|
||||
boolean execute = false ;
|
||||
if(execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)){
|
||||
server.stop();
|
||||
MainContext.setIMServerStatus(false);
|
||||
System.exit(0);
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute="+execute));
|
||||
@Menu(type = "admin", subtype = "stop", access = false, admin = true)
|
||||
public ModelAndView stop(ModelMap map, HttpServletRequest request, @Valid String confirm) throws SQLException {
|
||||
boolean execute = false;
|
||||
if (execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)) {
|
||||
server.stop();
|
||||
MainContext.setIMServerStatus(false);
|
||||
System.exit(0);
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute=" + execute));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/save")
|
||||
@Menu(type = "admin" , subtype = "save" , admin = true)
|
||||
public ModelAndView save(ModelMap map , HttpServletRequest request , @Valid SystemConfig config ,BindingResult result , @RequestParam(value = "keyfile", required = false) MultipartFile keyfile , @RequestParam(value = "loginlogo", required = false) MultipartFile loginlogo , @RequestParam(value = "consolelogo", required = false) MultipartFile consolelogo , @RequestParam(value = "favlogo", required = false) MultipartFile favlogo , @Valid Secret secret) throws SQLException, IOException, NoSuchAlgorithmException {
|
||||
@Menu(type = "admin", subtype = "save", admin = true)
|
||||
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid SystemConfig config, BindingResult result, @RequestParam(value = "keyfile", required = false) MultipartFile keyfile, @RequestParam(value = "loginlogo", required = false) MultipartFile loginlogo, @RequestParam(value = "consolelogo", required = false) MultipartFile consolelogo, @RequestParam(value = "favlogo", required = false) MultipartFile favlogo, @Valid Secret secret) throws SQLException, IOException, NoSuchAlgorithmException {
|
||||
/*SystemConfig systemConfig = systemConfigRes.findByOrgi(super.getOrgi(request)) ;
|
||||
config.setOrgi(super.getOrgi(request));*/
|
||||
SystemConfig systemConfig = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI) ;
|
||||
config.setOrgi(MainContext.SYSTEM_ORGI);
|
||||
String msg = "0" ;
|
||||
if(StringUtils.isBlank(config.getJkspassword())){
|
||||
config.setJkspassword(null);
|
||||
}
|
||||
if(systemConfig == null){
|
||||
config.setCreater(super.getUser(request).getId());
|
||||
config.setCreatetime(new Date());
|
||||
systemConfig = config ;
|
||||
}else{
|
||||
MainUtils.copyProperties(config,systemConfig);
|
||||
}
|
||||
if(config.isEnablessl()){
|
||||
if(keyfile!=null && keyfile.getBytes()!=null && keyfile.getBytes().length > 0 && keyfile.getOriginalFilename()!=null && keyfile.getOriginalFilename().length() > 0){
|
||||
FileUtils.writeByteArrayToFile(new File(path , "ssl/"+keyfile.getOriginalFilename()), keyfile.getBytes());
|
||||
systemConfig.setJksfile(keyfile.getOriginalFilename());
|
||||
File sslFilePath = new File(path , "ssl/https.properties") ;
|
||||
if(!sslFilePath.getParentFile().exists()) {
|
||||
sslFilePath.getParentFile().mkdirs() ;
|
||||
}
|
||||
Properties prop = new Properties();
|
||||
FileOutputStream oFile = new FileOutputStream(sslFilePath);//true表示追加打开
|
||||
prop.setProperty("key-store-password", MainUtils.encryption(systemConfig.getJkspassword())) ;
|
||||
prop.setProperty("key-store",systemConfig.getJksfile()) ;
|
||||
prop.store(oFile , "SSL Properties File");
|
||||
oFile.close();
|
||||
}
|
||||
}else if(new File(path , "ssl").exists()){
|
||||
File[] sslFiles = new File(path , "ssl").listFiles() ;
|
||||
for(File sslFile : sslFiles){
|
||||
sslFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
if(loginlogo!=null && !StringUtils.isBlank(loginlogo.getOriginalFilename()) && loginlogo.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
String logoFileName = "logo/"+ MainUtils.md5(loginlogo.getOriginalFilename())+loginlogo.getOriginalFilename().substring(loginlogo.getOriginalFilename().lastIndexOf(".")) ;
|
||||
FileUtils.writeByteArrayToFile(new File(path ,logoFileName), loginlogo.getBytes());
|
||||
systemConfig.setLoginlogo(logoFileName);
|
||||
}
|
||||
if(consolelogo!=null && !StringUtils.isBlank(consolelogo.getOriginalFilename()) && consolelogo.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
String consoleLogoFileName = "logo/"+ MainUtils.md5(consolelogo.getOriginalFilename())+consolelogo.getOriginalFilename().substring(consolelogo.getOriginalFilename().lastIndexOf(".")) ;
|
||||
FileUtils.writeByteArrayToFile(new File(path ,consoleLogoFileName), consolelogo.getBytes());
|
||||
systemConfig.setConsolelogo(consoleLogoFileName);
|
||||
}
|
||||
if(favlogo!=null && !StringUtils.isBlank(favlogo.getOriginalFilename()) && consolelogo.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
String favLogoFileName = "logo/"+ MainUtils.md5(favlogo.getOriginalFilename())+favlogo.getOriginalFilename().substring(favlogo.getOriginalFilename().lastIndexOf(".")) ;
|
||||
FileUtils.writeByteArrayToFile(new File(path ,favLogoFileName), favlogo.getBytes());
|
||||
systemConfig.setFavlogo(favLogoFileName);
|
||||
}
|
||||
|
||||
if(secret!=null && !StringUtils.isBlank(secret.getPassword())){
|
||||
List<Secret> secretConfig = secRes.findByOrgi(super.getOrgi(request)) ;
|
||||
String repassword = request.getParameter("repassword") ;
|
||||
if(!StringUtils.isBlank(repassword) && repassword.equals(secret.getPassword())){
|
||||
if(secretConfig!=null && secretConfig.size() > 0){
|
||||
Secret tempSecret = secretConfig.get(0) ;
|
||||
String oldpass = request.getParameter("oldpass") ;
|
||||
if(!StringUtils.isBlank(oldpass) && MainUtils.md5(oldpass).equals(tempSecret.getPassword())){
|
||||
tempSecret.setPassword(MainUtils.md5(secret.getPassword()));
|
||||
msg = "1" ;
|
||||
tempSecret.setEnable(true);
|
||||
secRes.save(tempSecret) ;
|
||||
}else{
|
||||
msg = "3" ;
|
||||
}
|
||||
}else{
|
||||
secret.setOrgi(super.getOrgi(request));
|
||||
secret.setCreater(super.getUser(request).getId());
|
||||
secret.setCreatetime(new Date());
|
||||
secret.setPassword(MainUtils.md5(secret.getPassword()));
|
||||
secret.setEnable(true);
|
||||
msg = "1" ;
|
||||
secRes.save(secret) ;
|
||||
}
|
||||
}else{
|
||||
msg = "2" ;
|
||||
}
|
||||
map.addAttribute("msg", msg) ;
|
||||
}
|
||||
systemConfigRes.save(systemConfig) ;
|
||||
|
||||
CacheHelper.getSystemCacheBean().put("systemConfig", systemConfig , super.getOrgi(request));
|
||||
map.addAttribute("imServerStatus", MainContext.getIMServerStatus()) ;
|
||||
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?msg="+msg));
|
||||
SystemConfig systemConfig = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI);
|
||||
config.setOrgi(MainContext.SYSTEM_ORGI);
|
||||
String msg = "0";
|
||||
if (StringUtils.isBlank(config.getJkspassword())) {
|
||||
config.setJkspassword(null);
|
||||
}
|
||||
if (systemConfig == null) {
|
||||
config.setCreater(super.getUser(request).getId());
|
||||
config.setCreatetime(new Date());
|
||||
systemConfig = config;
|
||||
} else {
|
||||
MainUtils.copyProperties(config, systemConfig);
|
||||
}
|
||||
if (config.isEnablessl()) {
|
||||
if (keyfile != null && keyfile.getBytes() != null && keyfile.getBytes().length > 0 && keyfile.getOriginalFilename() != null && keyfile.getOriginalFilename().length() > 0) {
|
||||
FileUtils.writeByteArrayToFile(new File(path, "ssl/" + keyfile.getOriginalFilename()), keyfile.getBytes());
|
||||
systemConfig.setJksfile(keyfile.getOriginalFilename());
|
||||
File sslFilePath = new File(path, "ssl/https.properties");
|
||||
if (!sslFilePath.getParentFile().exists()) {
|
||||
sslFilePath.getParentFile().mkdirs();
|
||||
}
|
||||
Properties prop = new Properties();
|
||||
FileOutputStream oFile = new FileOutputStream(sslFilePath);//true表示追加打开
|
||||
prop.setProperty("key-store-password", MainUtils.encryption(systemConfig.getJkspassword()));
|
||||
prop.setProperty("key-store", systemConfig.getJksfile());
|
||||
prop.store(oFile, "SSL Properties File");
|
||||
oFile.close();
|
||||
}
|
||||
} else if (new File(path, "ssl").exists()) {
|
||||
File[] sslFiles = new File(path, "ssl").listFiles();
|
||||
for (File sslFile : sslFiles) {
|
||||
sslFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (loginlogo != null && StringUtils.isNotBlank(loginlogo.getOriginalFilename()) && loginlogo.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
systemConfig.setLoginlogo(super.saveImageFileWithMultipart(loginlogo));
|
||||
}
|
||||
if (consolelogo != null && StringUtils.isNotBlank(consolelogo.getOriginalFilename()) && consolelogo.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
systemConfig.setConsolelogo(super.saveImageFileWithMultipart(consolelogo));
|
||||
}
|
||||
if (favlogo != null && StringUtils.isNotBlank(favlogo.getOriginalFilename()) && consolelogo.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
systemConfig.setFavlogo(super.saveImageFileWithMultipart(favlogo));
|
||||
}
|
||||
|
||||
if (secret != null && StringUtils.isNotBlank(secret.getPassword())) {
|
||||
List<Secret> secretConfig = secRes.findByOrgi(super.getOrgi(request));
|
||||
String repassword = request.getParameter("repassword");
|
||||
if (StringUtils.isNotBlank(repassword) && repassword.equals(secret.getPassword())) {
|
||||
if (secretConfig != null && secretConfig.size() > 0) {
|
||||
Secret tempSecret = secretConfig.get(0);
|
||||
String oldpass = request.getParameter("oldpass");
|
||||
if (StringUtils.isNotBlank(oldpass) && MainUtils.md5(oldpass).equals(tempSecret.getPassword())) {
|
||||
tempSecret.setPassword(MainUtils.md5(secret.getPassword()));
|
||||
msg = "1";
|
||||
tempSecret.setEnable(true);
|
||||
secRes.save(tempSecret);
|
||||
} else {
|
||||
msg = "3";
|
||||
}
|
||||
} else {
|
||||
secret.setOrgi(super.getOrgi(request));
|
||||
secret.setCreater(super.getUser(request).getId());
|
||||
secret.setCreatetime(new Date());
|
||||
secret.setPassword(MainUtils.md5(secret.getPassword()));
|
||||
secret.setEnable(true);
|
||||
msg = "1";
|
||||
secRes.save(secret);
|
||||
}
|
||||
} else {
|
||||
msg = "2";
|
||||
}
|
||||
map.addAttribute("msg", msg);
|
||||
}
|
||||
systemConfigRes.save(systemConfig);
|
||||
|
||||
CacheHelper.getSystemCacheBean().put("systemConfig", systemConfig, super.getOrgi(request));
|
||||
map.addAttribute("imServerStatus", MainContext.getIMServerStatus());
|
||||
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?msg=" + msg));
|
||||
}
|
||||
}
|
@ -16,26 +16,15 @@
|
||||
*/
|
||||
package com.chatopera.cc.app.handler.apps.setting;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.chatopera.cc.app.algorithm.AutomaticServiceDist;
|
||||
import com.chatopera.cc.app.basic.MainContext;
|
||||
import com.chatopera.cc.app.basic.MainUtils;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.app.algorithm.AutomaticServiceDist;
|
||||
import com.chatopera.cc.app.cache.CacheHelper;
|
||||
import com.chatopera.cc.app.persistence.repository.AdTypeRepository;
|
||||
import com.chatopera.cc.app.persistence.repository.SessionConfigRepository;
|
||||
import com.chatopera.cc.app.persistence.repository.TagRepository;
|
||||
import com.chatopera.cc.app.persistence.repository.TemplateRepository;
|
||||
import com.chatopera.cc.app.model.AdType;
|
||||
import com.chatopera.cc.app.model.SysDic;
|
||||
import com.chatopera.cc.app.model.Tag;
|
||||
import com.chatopera.cc.app.handler.Handler;
|
||||
import com.chatopera.cc.app.model.*;
|
||||
import com.chatopera.cc.app.persistence.blob.JpaBlobHelper;
|
||||
import com.chatopera.cc.app.persistence.repository.*;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -43,297 +32,289 @@ import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.chatopera.cc.app.persistence.repository.BlackListRepository;
|
||||
import com.chatopera.cc.app.handler.Handler;
|
||||
import com.chatopera.cc.app.model.BlackEntity;
|
||||
import com.chatopera.cc.app.model.SessionConfig;
|
||||
import com.chatopera.cc.app.model.UKeFuDic;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/setting")
|
||||
public class IMAgentController extends Handler{
|
||||
|
||||
@Autowired
|
||||
private SessionConfigRepository sessionConfigRes ;
|
||||
|
||||
@Autowired
|
||||
private TagRepository tagRes ;
|
||||
|
||||
@Autowired
|
||||
private BlackListRepository blackListRes;
|
||||
|
||||
@Autowired
|
||||
private AdTypeRepository adTypeRes;
|
||||
|
||||
@Autowired
|
||||
private TemplateRepository templateRes ;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
public class IMAgentController extends Handler {
|
||||
|
||||
@Autowired
|
||||
private SessionConfigRepository sessionConfigRes;
|
||||
|
||||
@Autowired
|
||||
private TagRepository tagRes;
|
||||
|
||||
@Autowired
|
||||
private BlackListRepository blackListRes;
|
||||
|
||||
@Autowired
|
||||
private AdTypeRepository adTypeRes;
|
||||
|
||||
@Autowired
|
||||
private TemplateRepository templateRes;
|
||||
|
||||
|
||||
@Autowired
|
||||
private StreamingFileRepository streamingFileRes;
|
||||
|
||||
@Autowired
|
||||
private JpaBlobHelper jpaBlobHelper;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
|
||||
@RequestMapping("/agent/index")
|
||||
@Menu(type = "setting" , subtype = "sessionconfig" , admin= false)
|
||||
public ModelAndView index(ModelMap map , HttpServletRequest request) {
|
||||
SessionConfig sessionConfig = sessionConfigRes.findByOrgi(super.getOrgi(request)) ;
|
||||
if(sessionConfig == null){
|
||||
sessionConfig = new SessionConfig() ;
|
||||
}
|
||||
map.put("sessionConfig", sessionConfig) ;
|
||||
|
||||
|
||||
List<SysDic> dicList = UKeFuDic.getInstance().getDic(MainContext.UKEFU_SYSTEM_DIC) ;
|
||||
SysDic inputDic = null , outputDic = null ;
|
||||
for(SysDic dic : dicList){
|
||||
if(dic.getCode().equals(MainContext.UKEFU_SYSTEM_AI_INPUT)){
|
||||
inputDic = dic ;
|
||||
}
|
||||
if(dic.getCode().equals(MainContext.UKEFU_SYSTEM_AI_OUTPUT)){
|
||||
outputDic = dic ;
|
||||
}
|
||||
}
|
||||
if(inputDic!=null){
|
||||
map.addAttribute("innputtemlet", templateRes.findByTemplettypeAndOrgi(inputDic.getId(), super.getOrgi(request))) ;
|
||||
}
|
||||
if(outputDic!=null){
|
||||
map.addAttribute("outputtemlet", templateRes.findByTemplettypeAndOrgi(outputDic.getId(), super.getOrgi(request))) ;
|
||||
}
|
||||
|
||||
@Menu(type = "setting", subtype = "sessionconfig", admin = false)
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
||||
SessionConfig sessionConfig = sessionConfigRes.findByOrgi(super.getOrgi(request));
|
||||
if (sessionConfig == null) {
|
||||
sessionConfig = new SessionConfig();
|
||||
}
|
||||
map.put("sessionConfig", sessionConfig);
|
||||
|
||||
|
||||
List<SysDic> dicList = UKeFuDic.getInstance().getDic(MainContext.UKEFU_SYSTEM_DIC);
|
||||
SysDic inputDic = null, outputDic = null;
|
||||
for (SysDic dic : dicList) {
|
||||
if (dic.getCode().equals(MainContext.UKEFU_SYSTEM_AI_INPUT)) {
|
||||
inputDic = dic;
|
||||
}
|
||||
if (dic.getCode().equals(MainContext.UKEFU_SYSTEM_AI_OUTPUT)) {
|
||||
outputDic = dic;
|
||||
}
|
||||
}
|
||||
if (inputDic != null) {
|
||||
map.addAttribute("innputtemlet", templateRes.findByTemplettypeAndOrgi(inputDic.getId(), super.getOrgi(request)));
|
||||
}
|
||||
if (outputDic != null) {
|
||||
map.addAttribute("outputtemlet", templateRes.findByTemplettypeAndOrgi(outputDic.getId(), super.getOrgi(request)));
|
||||
}
|
||||
|
||||
return request(super.createAppsTempletResponse("/apps/setting/agent/index"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/agent/sessionconfig/save")
|
||||
@Menu(type = "setting" , subtype = "sessionconfig" , admin= false)
|
||||
public ModelAndView sessionconfig(ModelMap map , HttpServletRequest request , @Valid SessionConfig sessionConfig) {
|
||||
SessionConfig tempSessionConfig = sessionConfigRes.findByOrgi(super.getOrgi(request)) ;
|
||||
if(tempSessionConfig == null){
|
||||
tempSessionConfig = sessionConfig;
|
||||
tempSessionConfig.setCreater(super.getUser(request).getId());
|
||||
}else{
|
||||
MainUtils.copyProperties(sessionConfig, tempSessionConfig);
|
||||
}
|
||||
tempSessionConfig.setOrgi(super.getOrgi(request));
|
||||
sessionConfigRes.save(tempSessionConfig) ;
|
||||
|
||||
CacheHelper.getSystemCacheBean().put(MainContext.SYSTEM_CACHE_SESSION_CONFIG+"_"+super.getOrgi(request),tempSessionConfig, super.getOrgi(request)) ;
|
||||
|
||||
CacheHelper.getSystemCacheBean().delete(MainContext.SYSTEM_CACHE_SESSION_CONFIG_LIST , MainContext.SYSTEM_ORGI) ;
|
||||
|
||||
AutomaticServiceDist.initSessionConfigList() ;
|
||||
map.put("sessionConfig", tempSessionConfig) ;
|
||||
|
||||
|
||||
|
||||
@Menu(type = "setting", subtype = "sessionconfig", admin = false)
|
||||
public ModelAndView sessionconfig(ModelMap map, HttpServletRequest request, @Valid SessionConfig sessionConfig) {
|
||||
SessionConfig tempSessionConfig = sessionConfigRes.findByOrgi(super.getOrgi(request));
|
||||
if (tempSessionConfig == null) {
|
||||
tempSessionConfig = sessionConfig;
|
||||
tempSessionConfig.setCreater(super.getUser(request).getId());
|
||||
} else {
|
||||
MainUtils.copyProperties(sessionConfig, tempSessionConfig);
|
||||
}
|
||||
tempSessionConfig.setOrgi(super.getOrgi(request));
|
||||
sessionConfigRes.save(tempSessionConfig);
|
||||
|
||||
CacheHelper.getSystemCacheBean().put(MainContext.SYSTEM_CACHE_SESSION_CONFIG + "_" + super.getOrgi(request), tempSessionConfig, super.getOrgi(request));
|
||||
|
||||
CacheHelper.getSystemCacheBean().delete(MainContext.SYSTEM_CACHE_SESSION_CONFIG_LIST, MainContext.SYSTEM_ORGI);
|
||||
|
||||
AutomaticServiceDist.initSessionConfigList();
|
||||
map.put("sessionConfig", tempSessionConfig);
|
||||
|
||||
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/agent/index.html"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/blacklist")
|
||||
@Menu(type = "setting" , subtype = "blacklist" , admin= false)
|
||||
public ModelAndView blacklist(ModelMap map , HttpServletRequest request) {
|
||||
map.put("blackList", blackListRes.findByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "endtime"))) ;
|
||||
map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type")) ;
|
||||
return request(super.createAppsTempletResponse("/apps/setting/agent/blacklist"));
|
||||
@Menu(type = "setting", subtype = "blacklist", admin = false)
|
||||
public ModelAndView blacklist(ModelMap map, HttpServletRequest request) {
|
||||
map.put("blackList", blackListRes.findByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "endtime")));
|
||||
map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type"));
|
||||
return request(super.createAppsTempletResponse("/apps/setting/agent/blacklist"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/blacklist/delete")
|
||||
@Menu(type = "setting" , subtype = "tag" , admin= false)
|
||||
public ModelAndView blacklistdelete(ModelMap map , HttpServletRequest request , @Valid String id) {
|
||||
if(!StringUtils.isBlank(id)){
|
||||
BlackEntity tempBlackEntity = blackListRes.findByIdAndOrgi(id, super.getOrgi(request)) ;
|
||||
if(tempBlackEntity!=null){
|
||||
blackListRes.delete(tempBlackEntity);
|
||||
CacheHelper.getSystemCacheBean().delete(tempBlackEntity.getUserid(), MainContext.SYSTEM_ORGI) ;
|
||||
}
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/blacklist.html"));
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView blacklistdelete(ModelMap map, HttpServletRequest request, @Valid String id) {
|
||||
if (!StringUtils.isBlank(id)) {
|
||||
BlackEntity tempBlackEntity = blackListRes.findByIdAndOrgi(id, super.getOrgi(request));
|
||||
if (tempBlackEntity != null) {
|
||||
blackListRes.delete(tempBlackEntity);
|
||||
CacheHelper.getSystemCacheBean().delete(tempBlackEntity.getUserid(), MainContext.SYSTEM_ORGI);
|
||||
}
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/blacklist.html"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/tag")
|
||||
@Menu(type = "setting" , subtype = "tag" , admin= false)
|
||||
public ModelAndView tag(ModelMap map , HttpServletRequest request , @Valid String code) {
|
||||
SysDic tagType = null ;
|
||||
List<SysDic> tagList = UKeFuDic.getInstance().getDic("com.dic.tag.type") ;
|
||||
if(tagList.size() > 0){
|
||||
|
||||
if(!StringUtils.isBlank(code)){
|
||||
for(SysDic dic : tagList){
|
||||
if(code.equals(dic.getCode())){
|
||||
tagType = dic ;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
tagType = tagList.get(0) ;
|
||||
}
|
||||
map.put("tagType", tagType) ;
|
||||
}
|
||||
if(tagType!=null){
|
||||
map.put("tagList", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , tagType.getCode() , new PageRequest(super.getP(request), super.getPs(request)))) ;
|
||||
}
|
||||
map.put("tagTypeList", tagList) ;
|
||||
return request(super.createAppsTempletResponse("/apps/setting/agent/tag"));
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tag(ModelMap map, HttpServletRequest request, @Valid String code) {
|
||||
SysDic tagType = null;
|
||||
List<SysDic> tagList = UKeFuDic.getInstance().getDic("com.dic.tag.type");
|
||||
if (tagList.size() > 0) {
|
||||
|
||||
if (!StringUtils.isBlank(code)) {
|
||||
for (SysDic dic : tagList) {
|
||||
if (code.equals(dic.getCode())) {
|
||||
tagType = dic;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tagType = tagList.get(0);
|
||||
}
|
||||
map.put("tagType", tagType);
|
||||
}
|
||||
if (tagType != null) {
|
||||
map.put("tagList", tagRes.findByOrgiAndTagtype(super.getOrgi(request), tagType.getCode(), new PageRequest(super.getP(request), super.getPs(request))));
|
||||
}
|
||||
map.put("tagTypeList", tagList);
|
||||
return request(super.createAppsTempletResponse("/apps/setting/agent/tag"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/tag/add")
|
||||
@Menu(type = "setting" , subtype = "tag" , admin= false)
|
||||
public ModelAndView tagadd(ModelMap map , HttpServletRequest request , @Valid String tagtype) {
|
||||
map.addAttribute("tagtype", tagtype) ;
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tagadd(ModelMap map, HttpServletRequest request, @Valid String tagtype) {
|
||||
map.addAttribute("tagtype", tagtype);
|
||||
return request(super.createRequestPageTempletResponse("/apps/setting/agent/tagadd"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/tag/edit")
|
||||
@Menu(type = "setting" , subtype = "tag" , admin= false)
|
||||
public ModelAndView tagedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String tagtype) {
|
||||
map.put("tag", tagRes.findOne(id)) ;
|
||||
map.addAttribute("tagtype", tagtype) ;
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tagedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tagtype) {
|
||||
map.put("tag", tagRes.findOne(id));
|
||||
map.addAttribute("tagtype", tagtype);
|
||||
return request(super.createRequestPageTempletResponse("/apps/setting/agent/tagedit"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/tag/update")
|
||||
@Menu(type = "setting" , subtype = "tag" , admin= false)
|
||||
public ModelAndView tagupdate(ModelMap map , HttpServletRequest request , @Valid Tag tag , @Valid String tagtype) {
|
||||
Tag temptag = tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag()) ;
|
||||
if(temptag == null || tag.getId().equals(temptag.getId())){
|
||||
tag.setOrgi(super.getOrgi(request));
|
||||
tag.setCreater(super.getUser(request).getId());
|
||||
tagRes.save(tag) ;
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code="+tagtype));
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tagupdate(ModelMap map, HttpServletRequest request, @Valid Tag tag, @Valid String tagtype) {
|
||||
Tag temptag = tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag());
|
||||
if (temptag == null || tag.getId().equals(temptag.getId())) {
|
||||
tag.setOrgi(super.getOrgi(request));
|
||||
tag.setCreater(super.getUser(request).getId());
|
||||
tagRes.save(tag);
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/tag/save")
|
||||
@Menu(type = "setting" , subtype = "tag" , admin= false)
|
||||
public ModelAndView tagsave(ModelMap map , HttpServletRequest request , @Valid Tag tag , @Valid String tagtype) {
|
||||
if(tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag()) == null){
|
||||
tag.setOrgi(super.getOrgi(request));
|
||||
tag.setCreater(super.getUser(request).getId());
|
||||
tagRes.save(tag) ;
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code="+tagtype));
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tagsave(ModelMap map, HttpServletRequest request, @Valid Tag tag, @Valid String tagtype) {
|
||||
if (tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag()) == null) {
|
||||
tag.setOrgi(super.getOrgi(request));
|
||||
tag.setCreater(super.getUser(request).getId());
|
||||
tagRes.save(tag);
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/tag/delete")
|
||||
@Menu(type = "setting" , subtype = "tag" , admin= false)
|
||||
public ModelAndView tagdelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String tagtype) {
|
||||
tagRes.delete(id);
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code="+tagtype));
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tagdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tagtype) {
|
||||
tagRes.delete(id);
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/acd")
|
||||
@Menu(type = "setting" , subtype = "acd" , admin= false)
|
||||
public ModelAndView acd(ModelMap map , HttpServletRequest request) {
|
||||
map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type")) ;
|
||||
return request(super.createAppsTempletResponse("/apps/setting/agent/acd"));
|
||||
@Menu(type = "setting", subtype = "acd", admin = false)
|
||||
public ModelAndView acd(ModelMap map, HttpServletRequest request) {
|
||||
map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type"));
|
||||
return request(super.createAppsTempletResponse("/apps/setting/agent/acd"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/adv")
|
||||
@Menu(type = "setting" , subtype = "adv" , admin= false)
|
||||
public ModelAndView adv(ModelMap map , HttpServletRequest request , @Valid String adpos) {
|
||||
SysDic advType = null ;
|
||||
List<SysDic> tagList = UKeFuDic.getInstance().getDic("com.dic.adv.type") ;
|
||||
if(tagList.size() > 0){
|
||||
if(!StringUtils.isBlank(adpos)){
|
||||
for(SysDic dic : tagList){
|
||||
if(adpos.equals(dic.getId())){
|
||||
advType = dic ;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
advType = tagList.get(0) ;
|
||||
}
|
||||
map.put("advType", advType) ;
|
||||
}
|
||||
if(advType!=null){
|
||||
map.put("adTypeList", adTypeRes.findByAdposAndOrgi(advType.getId() , super.getOrgi(request))) ;
|
||||
}
|
||||
|
||||
map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type")) ;
|
||||
|
||||
map.put("advTypeList", UKeFuDic.getInstance().getDic("com.dic.adv.type")) ;
|
||||
|
||||
return request(super.createAppsTempletResponse("/apps/setting/agent/adv"));
|
||||
@Menu(type = "setting", subtype = "adv", admin = false)
|
||||
public ModelAndView adv(ModelMap map, HttpServletRequest request, @Valid String adpos) {
|
||||
SysDic advType = null;
|
||||
List<SysDic> tagList = UKeFuDic.getInstance().getDic("com.dic.adv.type");
|
||||
if (tagList.size() > 0) {
|
||||
if (!StringUtils.isBlank(adpos)) {
|
||||
for (SysDic dic : tagList) {
|
||||
if (adpos.equals(dic.getId())) {
|
||||
advType = dic;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
advType = tagList.get(0);
|
||||
}
|
||||
map.put("advType", advType);
|
||||
}
|
||||
if (advType != null) {
|
||||
map.put("adTypeList", adTypeRes.findByAdposAndOrgi(advType.getId(), super.getOrgi(request)));
|
||||
}
|
||||
|
||||
map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type"));
|
||||
|
||||
map.put("advTypeList", UKeFuDic.getInstance().getDic("com.dic.adv.type"));
|
||||
|
||||
return request(super.createAppsTempletResponse("/apps/setting/agent/adv"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/adv/add")
|
||||
@Menu(type = "setting" , subtype = "adv" , admin= false)
|
||||
public ModelAndView advadd(ModelMap map , HttpServletRequest request , @Valid String adpos) {
|
||||
map.addAttribute("adpos", adpos) ;
|
||||
@Menu(type = "setting", subtype = "adv", admin = false)
|
||||
public ModelAndView advadd(ModelMap map, HttpServletRequest request, @Valid String adpos) {
|
||||
map.addAttribute("adpos", adpos);
|
||||
return request(super.createRequestPageTempletResponse("/apps/setting/agent/adadd"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/adv/save")
|
||||
@Menu(type = "setting" , subtype = "adv" , admin= false)
|
||||
public ModelAndView advsave(ModelMap map , HttpServletRequest request , @Valid AdType adv , @Valid String advtype , @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException {
|
||||
adv.setOrgi(super.getOrgi(request));
|
||||
adv.setCreater(super.getUser(request).getId());
|
||||
if(!StringUtils.isBlank(adv.getContent())){
|
||||
adv.setContent(adv.getContent().replaceAll("\"", "'"));
|
||||
}
|
||||
adv.setCreatetime(new Date());
|
||||
if(imgfile!=null && imgfile.getSize() > 0){
|
||||
File adDir = new File(path , "adv");
|
||||
if(!adDir.exists()){
|
||||
adDir.mkdirs() ;
|
||||
}
|
||||
String fileName = "adv/"+ MainUtils.getUUID()+imgfile.getOriginalFilename().substring(imgfile.getOriginalFilename().lastIndexOf(".")) ;
|
||||
FileCopyUtils.copy(imgfile.getBytes(), new File(path , fileName));
|
||||
adv.setImgurl("/res/image.html?id="+java.net.URLEncoder.encode(fileName , "UTF-8"));
|
||||
}
|
||||
adTypeRes.save(adv) ;
|
||||
|
||||
MainUtils.initAdv(super.getOrgi(request));
|
||||
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos="+adv.getAdpos()));
|
||||
@Menu(type = "setting", subtype = "adv", admin = false)
|
||||
public ModelAndView advsave(ModelMap map, HttpServletRequest request, @Valid AdType adv, @Valid String advtype, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException {
|
||||
adv.setOrgi(super.getOrgi(request));
|
||||
adv.setCreater(super.getUser(request).getId());
|
||||
if (StringUtils.isNotBlank(adv.getContent())) {
|
||||
adv.setContent(adv.getContent().replaceAll("\"", "'"));
|
||||
}
|
||||
adv.setCreatetime(new Date());
|
||||
if (imgfile != null && imgfile.getSize() > 0) {
|
||||
adv.setImgurl("/res/image.html?id=" + super.saveImageFileWithMultipart(imgfile));
|
||||
}
|
||||
adTypeRes.save(adv);
|
||||
|
||||
MainUtils.initAdv(super.getOrgi(request));
|
||||
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adv.getAdpos()));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/adv/edit")
|
||||
@Menu(type = "setting" , subtype = "adv" , admin= false)
|
||||
public ModelAndView advedit(ModelMap map , HttpServletRequest request , @Valid String adpos, @Valid String id) {
|
||||
map.addAttribute("adpos", adpos) ;
|
||||
map.put("ad", adTypeRes.findByIdAndOrgi(id , super.getOrgi(request))) ;
|
||||
@Menu(type = "setting", subtype = "adv", admin = false)
|
||||
public ModelAndView advedit(ModelMap map, HttpServletRequest request, @Valid String adpos, @Valid String id) {
|
||||
map.addAttribute("adpos", adpos);
|
||||
map.put("ad", adTypeRes.findByIdAndOrgi(id, super.getOrgi(request)));
|
||||
return request(super.createRequestPageTempletResponse("/apps/setting/agent/adedit"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/adv/update")
|
||||
@Menu(type = "setting" , subtype = "adv" , admin= false)
|
||||
public ModelAndView advupdate(ModelMap map , HttpServletRequest request , @Valid AdType ad, @Valid String adpos, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException {
|
||||
AdType tempad = adTypeRes.findByIdAndOrgi(ad.getId(),super.getOrgi(request)) ;
|
||||
if(tempad != null){
|
||||
ad.setOrgi(super.getOrgi(request));
|
||||
ad.setCreater(tempad.getCreater());
|
||||
ad.setCreatetime(tempad.getCreatetime());
|
||||
if(!StringUtils.isBlank(ad.getContent())){
|
||||
ad.setContent(ad.getContent().replaceAll("\"", "'"));
|
||||
}
|
||||
if(imgfile!=null && imgfile.getSize() > 0){
|
||||
File adDir = new File(path , "adv");
|
||||
if(!adDir.exists()){
|
||||
adDir.mkdirs() ;
|
||||
}
|
||||
String fileName = "adv/"+ MainUtils.getUUID()+imgfile.getOriginalFilename().substring(imgfile.getOriginalFilename().lastIndexOf(".")) ;
|
||||
FileCopyUtils.copy(imgfile.getBytes(), new File(path , fileName));
|
||||
ad.setImgurl("/res/image.html?id="+java.net.URLEncoder.encode(fileName , "UTF-8"));
|
||||
}else{
|
||||
ad.setImgurl(tempad.getImgurl());
|
||||
}
|
||||
adTypeRes.save(ad) ;
|
||||
MainUtils.initAdv(super.getOrgi(request));
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos="+adpos));
|
||||
@Menu(type = "setting", subtype = "adv", admin = false)
|
||||
public ModelAndView advupdate(ModelMap map, HttpServletRequest request, @Valid AdType ad, @Valid String adpos, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException {
|
||||
AdType tempad = adTypeRes.findByIdAndOrgi(ad.getId(), super.getOrgi(request));
|
||||
if (tempad != null) {
|
||||
ad.setOrgi(super.getOrgi(request));
|
||||
ad.setCreater(tempad.getCreater());
|
||||
ad.setCreatetime(tempad.getCreatetime());
|
||||
if (StringUtils.isNotBlank(ad.getContent())) {
|
||||
ad.setContent(ad.getContent().replaceAll("\"", "'"));
|
||||
}
|
||||
if (imgfile != null && imgfile.getSize() > 0) {
|
||||
ad.setImgurl("/res/image.html?id=" + super.saveImageFileWithMultipart(imgfile));
|
||||
} else {
|
||||
ad.setImgurl(tempad.getImgurl());
|
||||
}
|
||||
adTypeRes.save(ad);
|
||||
MainUtils.initAdv(super.getOrgi(request));
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adpos));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/adv/delete")
|
||||
@Menu(type = "setting" , subtype = "adv" , admin= false)
|
||||
public ModelAndView advdelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String adpos) {
|
||||
adTypeRes.delete(id);
|
||||
MainUtils.initAdv(super.getOrgi(request));
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos="+adpos));
|
||||
@Menu(type = "setting", subtype = "adv", admin = false)
|
||||
public ModelAndView advdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String adpos) {
|
||||
adTypeRes.delete(id);
|
||||
MainUtils.initAdv(super.getOrgi(request));
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adpos));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user