mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Fix TagRepository related class
This commit is contained in:
parent
3b039cce3c
commit
226171df3d
@ -19,24 +19,22 @@ package com.chatopera.cc.controller.api;
|
|||||||
import com.chatopera.cc.basic.MainContext;
|
import com.chatopera.cc.basic.MainContext;
|
||||||
import com.chatopera.cc.controller.Handler;
|
import com.chatopera.cc.controller.Handler;
|
||||||
import com.chatopera.cc.controller.api.request.RestUtils;
|
import com.chatopera.cc.controller.api.request.RestUtils;
|
||||||
import com.chatopera.cc.exception.CSKefuRestException;
|
|
||||||
import com.chatopera.cc.model.Tag;
|
import com.chatopera.cc.model.Tag;
|
||||||
import com.chatopera.cc.model.TagRelation;
|
import com.chatopera.cc.model.TagRelation;
|
||||||
import com.chatopera.cc.persistence.repository.TagRelationRepository;
|
import com.chatopera.cc.persistence.repository.TagRelationRepository;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import com.chatopera.cc.persistence.repository.UserRepository;
|
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
import com.chatopera.cc.util.json.GsonTools;
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
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.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
@ -51,26 +49,20 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/contacts/tags")
|
@RequestMapping("/api/contacts/tags")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class ApiContactTagsController extends Handler {
|
public class ApiContactTagsController extends Handler {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ApiContactTagsController.class);
|
private static final Logger logger = LoggerFactory.getLogger(ApiContactTagsController.class);
|
||||||
private static final String TAGTYPE_USER = "user";
|
private static final String TAGTYPE_USER = "user";
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRelationRepository tagRelationRes;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TagRelationRepository tagRelationRes;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserRepository userRes;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取联系人标签
|
* 获取联系人标签
|
||||||
*
|
|
||||||
* @param j
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private JsonObject fetch(JsonObject j) {
|
private JsonObject fetch(JsonObject j) {
|
||||||
JsonObject resp = new JsonObject();
|
JsonObject resp = new JsonObject();
|
||||||
@ -78,7 +70,7 @@ public class ApiContactTagsController extends Handler {
|
|||||||
String contactid = j.get("contactid").getAsString();
|
String contactid = j.get("contactid").getAsString();
|
||||||
// 获取联系人所有标签
|
// 获取联系人所有标签
|
||||||
List<TagRelation> rels = tagRelationRes.findByUserid(contactid);
|
List<TagRelation> rels = tagRelationRes.findByUserid(contactid);
|
||||||
HashMap<String, String> tagged = new HashMap<String, String>();
|
HashMap<String, String> tagged = new HashMap<>();
|
||||||
|
|
||||||
for (TagRelation t : rels) {
|
for (TagRelation t : rels) {
|
||||||
tagged.put(t.getTagid(), t.getId());
|
tagged.put(t.getTagid(), t.getId());
|
||||||
@ -114,9 +106,6 @@ public class ApiContactTagsController extends Handler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建联系人标签关系
|
* 创建联系人标签关系
|
||||||
*
|
|
||||||
* @param j
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private JsonObject create(JsonObject j) {
|
private JsonObject create(JsonObject j) {
|
||||||
JsonObject resp = new JsonObject();
|
JsonObject resp = new JsonObject();
|
||||||
@ -135,9 +124,8 @@ public class ApiContactTagsController extends Handler {
|
|||||||
|
|
||||||
final String tagId = j.get("tagId").getAsString();
|
final String tagId = j.get("tagId").getAsString();
|
||||||
final String contactid = j.get("contactid").getAsString();
|
final String contactid = j.get("contactid").getAsString();
|
||||||
Tag tag = tagRes.findOne(tagId);
|
|
||||||
|
|
||||||
if (tag == null) {
|
if (!tagRes.existsById(tagId)) {
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_ERROR, "不存在该标签。");
|
resp.addProperty(RestUtils.RESP_KEY_ERROR, "不存在该标签。");
|
||||||
return resp;
|
return resp;
|
||||||
@ -161,9 +149,6 @@ public class ApiContactTagsController extends Handler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 去掉标签
|
* 去掉标签
|
||||||
*
|
|
||||||
* @param j
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private JsonObject remove(JsonObject j) {
|
private JsonObject remove(JsonObject j) {
|
||||||
JsonObject resp = new JsonObject();
|
JsonObject resp = new JsonObject();
|
||||||
@ -173,14 +158,14 @@ public class ApiContactTagsController extends Handler {
|
|||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
TagRelation t = tagRelationRes.findOne(j.get("xid").getAsString());
|
String tagId = j.get("xid").getAsString();
|
||||||
if (t == null) {
|
if (!tagRelationRes.existsById(tagId)) {
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_ERROR, "该联系人没有打这个标签。");
|
resp.addProperty(RestUtils.RESP_KEY_ERROR, "该联系人没有打这个标签。");
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
tagRelationRes.delete(t);
|
tagRelationRes.deleteById(tagId);
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
data.addProperty("msg", "删除成功。");
|
data.addProperty("msg", "删除成功。");
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
|
||||||
@ -191,8 +176,8 @@ public class ApiContactTagsController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@RequestMapping(method = RequestMethod.POST)
|
||||||
@Menu(type = "apps", subtype = "contacttags", access = true)
|
@Menu(type = "apps", subtype = "contacttags", access = true)
|
||||||
public ResponseEntity<String> operations(HttpServletRequest request, @RequestBody final String body) throws CSKefuRestException, GsonTools.JsonObjectExtensionConflictException {
|
public ResponseEntity<String> operations(HttpServletRequest request, @RequestBody final String body) {
|
||||||
final JsonObject j = (new JsonParser()).parse(body).getAsJsonObject();
|
final JsonObject j = JsonParser.parseString(body).getAsJsonObject();
|
||||||
logger.info("[contact tags] operations payload {}", j.toString());
|
logger.info("[contact tags] operations payload {}", j.toString());
|
||||||
JsonObject json = new JsonObject();
|
JsonObject json = new JsonObject();
|
||||||
HttpHeaders headers = RestUtils.header();
|
HttpHeaders headers = RestUtils.header();
|
||||||
@ -219,7 +204,7 @@ public class ApiContactTagsController extends Handler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ResponseEntity<String>(json.toString(), headers, HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), headers, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,24 +18,23 @@ package com.chatopera.cc.controller.api;
|
|||||||
|
|
||||||
import com.chatopera.cc.controller.Handler;
|
import com.chatopera.cc.controller.Handler;
|
||||||
import com.chatopera.cc.controller.api.request.RestUtils;
|
import com.chatopera.cc.controller.api.request.RestUtils;
|
||||||
import com.chatopera.cc.exception.CSKefuRestException;
|
|
||||||
import com.chatopera.cc.model.Tag;
|
import com.chatopera.cc.model.Tag;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
import com.chatopera.cc.util.json.GsonTools;
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
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.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
@ -49,18 +48,15 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/repo/tags")
|
@RequestMapping("/api/repo/tags")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class ApiTagsController extends Handler {
|
public class ApiTagsController extends Handler {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ApiTagsController.class);
|
private static final Logger logger = LoggerFactory.getLogger(ApiTagsController.class);
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取标签
|
* 获取标签
|
||||||
*
|
|
||||||
* @param j
|
|
||||||
* @param request
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private JsonObject fetch(final JsonObject j, final HttpServletRequest request) {
|
private JsonObject fetch(final JsonObject j, final HttpServletRequest request) {
|
||||||
JsonObject resp = new JsonObject();
|
JsonObject resp = new JsonObject();
|
||||||
@ -97,17 +93,11 @@ public class ApiTagsController extends Handler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系人标签
|
* 联系人标签
|
||||||
*
|
|
||||||
* @param request
|
|
||||||
* @param body
|
|
||||||
* @return
|
|
||||||
* @throws CSKefuRestException
|
|
||||||
* @throws GsonTools.JsonObjectExtensionConflictException
|
|
||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@RequestMapping(method = RequestMethod.POST)
|
||||||
@Menu(type = "apps", subtype = "tags", access = true)
|
@Menu(type = "apps", subtype = "tags", access = true)
|
||||||
public ResponseEntity<String> operations(HttpServletRequest request, @RequestBody final String body) throws CSKefuRestException, GsonTools.JsonObjectExtensionConflictException {
|
public ResponseEntity<String> operations(HttpServletRequest request, @RequestBody final String body) {
|
||||||
final JsonObject j = (new JsonParser()).parse(body).getAsJsonObject();
|
final JsonObject j = JsonParser.parseString(body).getAsJsonObject();
|
||||||
logger.info("[contact tags] operations payload {}", j.toString());
|
logger.info("[contact tags] operations payload {}", j.toString());
|
||||||
JsonObject json = new JsonObject();
|
JsonObject json = new JsonObject();
|
||||||
HttpHeaders headers = RestUtils.header();
|
HttpHeaders headers = RestUtils.header();
|
||||||
@ -118,17 +108,14 @@ public class ApiTagsController extends Handler {
|
|||||||
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
|
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
|
||||||
json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的请求参数。");
|
json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的请求参数。");
|
||||||
} else {
|
} else {
|
||||||
switch (StringUtils.lowerCase(j.get("ops").getAsString())) {
|
if ("fetch".equals(StringUtils.lowerCase(j.get("ops").getAsString()))) {
|
||||||
case "fetch":
|
json = fetch(j, request);
|
||||||
json = fetch(j, request);
|
} else {
|
||||||
break;
|
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
|
||||||
default:
|
json.addProperty(RestUtils.RESP_KEY_ERROR, "不支持的操作。");
|
||||||
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
|
|
||||||
json.addProperty(RestUtils.RESP_KEY_ERROR, "不支持的操作。");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ResponseEntity<String>(json.toString(), headers, HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), headers, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,59 +1,60 @@
|
|||||||
/*
|
/*
|
||||||
* 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.api;
|
package com.chatopera.cc.controller.api;
|
||||||
|
|
||||||
import com.chatopera.cc.basic.MainContext;
|
import com.chatopera.cc.basic.MainContext;
|
||||||
import com.chatopera.cc.controller.Handler;
|
import com.chatopera.cc.controller.Handler;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
import com.chatopera.cc.util.RestResult;
|
import com.chatopera.cc.util.RestResult;
|
||||||
import com.chatopera.cc.util.RestResultType;
|
import com.chatopera.cc.util.RestResultType;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.validation.Valid;
|
||||||
/**
|
|
||||||
* 标签功能
|
/**
|
||||||
* 获取分类标签
|
* 标签功能
|
||||||
*/
|
* 获取分类标签
|
||||||
@RestController
|
*/
|
||||||
@RequestMapping("/api/tags")
|
@RestController
|
||||||
public class UkefuApiTagsController extends Handler {
|
@RequestMapping("/api/tags")
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Autowired
|
public class UkefuApiTagsController extends Handler {
|
||||||
private TagRepository tagRes;
|
|
||||||
|
@NonNull
|
||||||
/**
|
private final TagRepository tagRes;
|
||||||
* 按照分类获取标签列表
|
|
||||||
* 按照分类获取标签列表,Type 参数类型来自于 枚举,可选值目前有三个 : user workorders summary
|
/**
|
||||||
* @param request
|
* 按照分类获取标签列表
|
||||||
* @param type 类型
|
* 按照分类获取标签列表,Type 参数类型来自于 枚举,可选值目前有三个 : user workorders summary
|
||||||
* @return
|
*
|
||||||
*/
|
* @param type 类型
|
||||||
@RequestMapping( method = RequestMethod.GET)
|
*/
|
||||||
@Menu(type = "apps" , subtype = "tags" , access = true)
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
public ResponseEntity<RestResult> list(HttpServletRequest request , @Valid String type) {
|
@Menu(type = "apps", subtype = "tags", access = true)
|
||||||
return new ResponseEntity<>(new RestResult(RestResultType.OK, tagRes.findByOrgiAndTagtype(super.getOrgi(request) , !StringUtils.isBlank(type) ? type : MainContext.ModelType.USER.toString())), HttpStatus.OK);
|
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid String type) {
|
||||||
}
|
return new ResponseEntity<>(new RestResult(RestResultType.OK, tagRes.findByOrgiAndTagtype(super.getOrgi(request), !StringUtils.isBlank(type) ? type : MainContext.ModelType.USER.toString())), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -29,7 +29,8 @@ import com.chatopera.cc.persistence.repository.QualityRepository;
|
|||||||
import com.chatopera.cc.persistence.repository.SessionConfigRepository;
|
import com.chatopera.cc.persistence.repository.SessionConfigRepository;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
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.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;
|
||||||
@ -42,22 +43,23 @@ import java.util.List;
|
|||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/apps/quality")
|
@RequestMapping("/apps/quality")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class AgentQualityController extends Handler {
|
public class AgentQualityController extends Handler {
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private ACDPolicyService acdPolicyService;
|
private final ACDPolicyService acdPolicyService;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private QualityRepository qualityRes;
|
private final QualityRepository qualityRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private SessionConfigRepository sessionConfigRes;
|
private final SessionConfigRepository sessionConfigRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private Cache cache;
|
private final Cache cache;
|
||||||
|
|
||||||
@RequestMapping(value = "/index")
|
@RequestMapping(value = "/index")
|
||||||
@Menu(type = "agent", subtype = "quality")
|
@Menu(type = "agent", subtype = "quality")
|
||||||
@ -71,13 +73,13 @@ public class AgentQualityController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping(value = "/save")
|
@RequestMapping(value = "/save")
|
||||||
@Menu(type = "agent", subtype = "quality")
|
@Menu(type = "agent", subtype = "quality")
|
||||||
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid QualityRequest qualityArray) {
|
public ModelAndView save(HttpServletRequest request, @Valid QualityRequest qualityArray) {
|
||||||
String orgi = super.getOrgi(request);
|
String orgi = super.getOrgi(request);
|
||||||
|
|
||||||
if (qualityArray != null && qualityArray.getTitle() != null) {
|
if (qualityArray != null && qualityArray.getTitle() != null) {
|
||||||
List<Quality> qualityList = qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request));
|
List<Quality> qualityList = qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request));
|
||||||
qualityRes.delete(qualityList);
|
qualityRes.deleteAll(qualityList);
|
||||||
List<Quality> tempList = new ArrayList<Quality>();
|
List<Quality> tempList = new ArrayList<>();
|
||||||
for (int i = 0; i < qualityArray.getTitle().length; i++) {
|
for (int i = 0; i < qualityArray.getTitle().length; i++) {
|
||||||
Quality temp = new Quality();
|
Quality temp = new Quality();
|
||||||
temp.setName(qualityArray.getTitle()[i]);
|
temp.setName(qualityArray.getTitle()[i]);
|
||||||
@ -92,7 +94,7 @@ public class AgentQualityController extends Handler {
|
|||||||
tempList.add(temp);
|
tempList.add(temp);
|
||||||
}
|
}
|
||||||
if (tempList.size() > 0) {
|
if (tempList.size() > 0) {
|
||||||
qualityRes.save(tempList);
|
qualityRes.saveAll(tempList);
|
||||||
}
|
}
|
||||||
SessionConfig config = acdPolicyService.initSessionConfig(super.getOrgi(request));
|
SessionConfig config = acdPolicyService.initSessionConfig(super.getOrgi(request));
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
@ -106,12 +108,12 @@ public class AgentQualityController extends Handler {
|
|||||||
cache.putSessionConfigByOrgi(config, orgi);
|
cache.putSessionConfigByOrgi(config, orgi);
|
||||||
cache.deleteSessionConfigListByOrgi(orgi);
|
cache.deleteSessionConfigListByOrgi(orgi);
|
||||||
}
|
}
|
||||||
if (qualityArray != null && qualityArray.getTag() != null && qualityArray.getTag().length > 0) {
|
if (qualityArray.getTag() != null && qualityArray.getTag().length > 0) {
|
||||||
List<Tag> tagList = tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.TagType.QUALITY.toString());
|
List<Tag> tagList = tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.TagType.QUALITY.toString());
|
||||||
if (tagList.size() > 0) {
|
if (tagList.size() > 0) {
|
||||||
tagRes.delete(tagList);
|
tagRes.deleteAll(tagList);
|
||||||
}
|
}
|
||||||
List<Tag> tagTempList = new ArrayList<Tag>();
|
List<Tag> tagTempList = new ArrayList<>();
|
||||||
for (String tag : qualityArray.getTag()) {
|
for (String tag : qualityArray.getTag()) {
|
||||||
Tag temp = new Tag();
|
Tag temp = new Tag();
|
||||||
temp.setOrgi(super.getOrgi(request));
|
temp.setOrgi(super.getOrgi(request));
|
||||||
@ -122,7 +124,7 @@ public class AgentQualityController extends Handler {
|
|||||||
tagTempList.add(temp);
|
tagTempList.add(temp);
|
||||||
}
|
}
|
||||||
if (tagTempList.size() > 0) {
|
if (tagTempList.size() > 0) {
|
||||||
tagRes.save(tagTempList);
|
tagRes.saveAll(tagTempList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,11 @@ import com.chatopera.cc.persistence.repository.AttachmentRepository;
|
|||||||
import com.chatopera.cc.persistence.repository.KbsTypeRepository;
|
import com.chatopera.cc.persistence.repository.KbsTypeRepository;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
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;
|
||||||
@ -47,132 +48,134 @@ import java.util.Date;
|
|||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping({"/apps/kbs"})
|
@RequestMapping({"/apps/kbs"})
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class KbsController extends Handler {
|
public class KbsController extends Handler {
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private KbsTypeRepository kbsTypeRes;
|
private final KbsTypeRepository kbsTypeRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private KbsTopicRepository kbsTopicRes;
|
private final KbsTopicRepository kbsTopicRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private AttachmentRepository attachementRes;
|
private final AttachmentRepository attachementRes;
|
||||||
|
|
||||||
@Value("${web.upload-path}")
|
@Value("${web.upload-path}")
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
@RequestMapping({"/index"})
|
@RequestMapping({"/index"})
|
||||||
@Menu(type = "apps", subtype = "kbs")
|
@Menu(type = "apps", subtype = "kbs")
|
||||||
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
public ModelAndView index() {
|
||||||
return request(super.createAppsTempletResponse("/apps/business/kbs/index"));
|
return request(super.createAppsTempletResponse("/apps/business/kbs/index"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping({"/list"})
|
@RequestMapping({"/list"})
|
||||||
@Menu(type = "apps", subtype = "kbs")
|
@Menu(type = "apps", subtype = "kbs")
|
||||||
public ModelAndView list(ModelMap map, HttpServletRequest request) {
|
public ModelAndView list(ModelMap map, HttpServletRequest request) {
|
||||||
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request)));
|
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request)));
|
||||||
return request(super.createAppsTempletResponse("/apps/business/kbs/list"));
|
return request(super.createAppsTempletResponse("/apps/business/kbs/list"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping({"/list/type"})
|
@RequestMapping({"/list/type"})
|
||||||
@Menu(type = "apps", subtype = "kbs")
|
@Menu(type = "apps", subtype = "kbs")
|
||||||
public ModelAndView listtype(ModelMap map, HttpServletRequest request, @Valid String typeid) {
|
public ModelAndView listtype(ModelMap map, HttpServletRequest request, @Valid String typeid) {
|
||||||
if (!StringUtils.isBlank(typeid) && !typeid.equals("0")) {
|
if (!StringUtils.isBlank(typeid) && !typeid.equals("0")) {
|
||||||
map.addAttribute("kbsType", kbsTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
|
map.addAttribute("kbsType", kbsTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/kbs/typelist"));
|
return request(super.createRequestPageTempletResponse("/apps/business/kbs/typelist"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping({"/addtype"})
|
@RequestMapping({"/addtype"})
|
||||||
@Menu(type = "apps", subtype = "kbs")
|
@Menu(type = "apps", subtype = "kbs")
|
||||||
public ModelAndView addtype(ModelMap map, HttpServletRequest request) {
|
public ModelAndView addtype(ModelMap map, HttpServletRequest request) {
|
||||||
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request)));
|
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request)));
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/kbs/addtype"));
|
return request(super.createRequestPageTempletResponse("/apps/business/kbs/addtype"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/type/save")
|
@RequestMapping("/type/save")
|
||||||
@Menu(type = "apps", subtype = "kbs")
|
@Menu(type = "apps", subtype = "kbs")
|
||||||
public ModelAndView typesave(HttpServletRequest request, @Valid KbsType kbsType) {
|
public ModelAndView typesave(HttpServletRequest request, @Valid KbsType kbsType) {
|
||||||
int count = kbsTypeRes.countByOrgiAndNameAndParentid(super.getOrgi(request), kbsType.getName(), kbsType.getParentid());
|
int count = kbsTypeRes.countByOrgiAndNameAndParentid(super.getOrgi(request), kbsType.getName(), kbsType.getParentid());
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
kbsType.setOrgi(super.getOrgi(request));
|
kbsType.setOrgi(super.getOrgi(request));
|
||||||
kbsType.setCreater(super.getUser(request).getId());
|
kbsType.setCreater(super.getUser(request).getId());
|
||||||
kbsType.setCreatetime(new Date());
|
kbsType.setCreatetime(new Date());
|
||||||
kbsTypeRes.save(kbsType);
|
kbsTypeRes.save(kbsType);
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/apps/kbs/list.html"));
|
return request(super.createRequestPageTempletResponse("redirect:/apps/kbs/list.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping({"/add"})
|
@RequestMapping({"/add"})
|
||||||
@Menu(type = "apps", subtype = "kbs")
|
@Menu(type = "apps", subtype = "kbs")
|
||||||
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String typeid) {
|
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String typeid) {
|
||||||
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request)));
|
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request)));
|
||||||
map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.KBS.toString()));
|
map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.KBS.toString()));
|
||||||
if (!StringUtils.isBlank(typeid) && !typeid.equals("0")) {
|
if (!StringUtils.isBlank(typeid) && !typeid.equals("0")) {
|
||||||
map.addAttribute("kbsType", kbsTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
|
map.addAttribute("kbsType", kbsTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/kbs/add"));
|
return request(super.createRequestPageTempletResponse("/apps/business/kbs/add"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
@Menu(type = "topic", subtype = "save")
|
@Menu(type = "topic", subtype = "save")
|
||||||
public ModelAndView save(HttpServletRequest request,
|
public ModelAndView save(HttpServletRequest request,
|
||||||
final @Valid KbsTopic topic,
|
final @Valid KbsTopic topic,
|
||||||
@RequestParam(value = "files", required = false) MultipartFile[] files) throws IOException {
|
@RequestParam(value = "files", required = false) MultipartFile[] files) throws IOException {
|
||||||
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/apps/kbs/index.html"));
|
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/apps/kbs/index.html"));
|
||||||
topic.setOrgi(super.getOrgi(request));
|
topic.setOrgi(super.getOrgi(request));
|
||||||
topic.setCreater(super.getUser(request).getId());
|
topic.setCreater(super.getUser(request).getId());
|
||||||
topic.setUsername(super.getUser(request).getUsername());
|
topic.setUsername(super.getUser(request).getUsername());
|
||||||
|
|
||||||
processAttachmentFile(files, topic, request, topic.getId(), topic.getId());
|
processAttachmentFile(files, topic, request, topic.getId(), topic.getId());
|
||||||
|
|
||||||
KbsType workOrderType = kbsTypeRes.findByIdAndOrgi(topic.getTptype(), super.getOrgi(request));
|
KbsType workOrderType = kbsTypeRes.findByIdAndOrgi(topic.getTptype(), super.getOrgi(request));
|
||||||
// 知识处理流程,如果知识分类需要审批,则触发知识流程
|
// 知识处理流程,如果知识分类需要审批,则触发知识流程
|
||||||
topic.setApproval(!workOrderType.isApproval());
|
topic.setApproval(!workOrderType.isApproval());
|
||||||
kbsTopicRes.save(topic);
|
kbsTopicRes.save(topic);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void processAttachmentFile(MultipartFile[] files, KbsTopic topic, HttpServletRequest request, String dataid, String modelid) throws IOException {
|
private void processAttachmentFile(MultipartFile[] files, KbsTopic topic, HttpServletRequest request, String dataid, String modelid) throws IOException {
|
||||||
if (files != null && files.length > 0) {
|
if (files != null && files.length > 0) {
|
||||||
topic.setAttachment(""); //序列化 附件文件,方便显示,避免多一次查询 附件的操作
|
topic.setAttachment(""); //序列化 附件文件,方便显示,避免多一次查询 附件的操作
|
||||||
//保存附件
|
//保存附件
|
||||||
for (MultipartFile file : files) {
|
for (MultipartFile file : files) {
|
||||||
if (file.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制
|
if (file.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制
|
||||||
String fileid = MainUtils.md5(file.getBytes()); //使用 文件的 MD5作为 ID,避免重复上传大文件
|
String fileid = MainUtils.md5(file.getBytes()); //使用 文件的 MD5作为 ID,避免重复上传大文件
|
||||||
if (!StringUtils.isBlank(fileid)) {
|
if (!StringUtils.isBlank(fileid)) {
|
||||||
AttachmentFile attachmentFile = new AttachmentFile();
|
AttachmentFile attachmentFile = new AttachmentFile();
|
||||||
attachmentFile.setCreater(super.getUser(request).getId());
|
attachmentFile.setCreater(super.getUser(request).getId());
|
||||||
attachmentFile.setOrgi(super.getOrgi(request));
|
attachmentFile.setOrgi(super.getOrgi(request));
|
||||||
attachmentFile.setDataid(dataid);
|
attachmentFile.setDataid(dataid);
|
||||||
attachmentFile.setModelid(modelid);
|
attachmentFile.setModelid(modelid);
|
||||||
attachmentFile.setModel(MainContext.ModelType.WORKORDERS.toString());
|
attachmentFile.setModel(MainContext.ModelType.WORKORDERS.toString());
|
||||||
attachmentFile.setFilelength((int) file.getSize());
|
attachmentFile.setFilelength((int) file.getSize());
|
||||||
if (file.getContentType() != null && file.getContentType().length() > 255) {
|
if (file.getContentType() != null && file.getContentType().length() > 255) {
|
||||||
attachmentFile.setFiletype(file.getContentType().substring(0, 255));
|
attachmentFile.setFiletype(file.getContentType().substring(0, 255));
|
||||||
} else {
|
} else {
|
||||||
attachmentFile.setFiletype(file.getContentType());
|
attachmentFile.setFiletype(file.getContentType());
|
||||||
}
|
}
|
||||||
if (file.getOriginalFilename() != null && file.getOriginalFilename().length() > 255) {
|
if (file.getOriginalFilename() != null && file.getOriginalFilename().length() > 255) {
|
||||||
attachmentFile.setTitle(file.getOriginalFilename().substring(0, 255));
|
attachmentFile.setTitle(file.getOriginalFilename().substring(0, 255));
|
||||||
} else {
|
} else {
|
||||||
attachmentFile.setTitle(file.getOriginalFilename());
|
attachmentFile.setTitle(file.getOriginalFilename());
|
||||||
}
|
}
|
||||||
if (!StringUtils.isBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) {
|
String filetype = attachmentFile.getFiletype();
|
||||||
attachmentFile.setImage(true);
|
if (!StringUtils.isBlank(filetype) && filetype.contains("image")) {
|
||||||
}
|
attachmentFile.setImage(true);
|
||||||
attachmentFile.setFileid(fileid);
|
}
|
||||||
attachementRes.save(attachmentFile);
|
attachmentFile.setFileid(fileid);
|
||||||
FileUtils.writeByteArrayToFile(new File(path, "app/kbs/" + fileid), file.getBytes());
|
attachementRes.save(attachmentFile);
|
||||||
}
|
FileUtils.writeByteArrayToFile(new File(path, "app/kbs/" + fileid), file.getBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,46 +1,48 @@
|
|||||||
/*
|
/*
|
||||||
* 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.impl;
|
package com.chatopera.cc.persistence.impl;
|
||||||
|
|
||||||
import com.chatopera.cc.model.Tag;
|
import com.chatopera.cc.model.Tag;
|
||||||
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
|
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.lang.NonNull;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
@Service("servicedata")
|
|
||||||
public class ServiceDataExchangeImpl implements DataExchangeInterface {
|
@Service("servicedata")
|
||||||
@Autowired
|
@RequiredArgsConstructor
|
||||||
private TagRepository tagRes ;
|
public class ServiceDataExchangeImpl implements DataExchangeInterface {
|
||||||
|
@NonNull
|
||||||
public String getDataByIdAndOrgi(String id, String orgi){
|
private final TagRepository tagRes;
|
||||||
Tag tag = tagRes.findByOrgiAndId(orgi, id) ;
|
|
||||||
return tag!=null ? tag.getTag() : id;
|
public String getDataByIdAndOrgi(String id, String orgi) {
|
||||||
}
|
Tag tag = tagRes.findByOrgiAndId(orgi, id);
|
||||||
|
return tag != null ? tag.getTag() : id;
|
||||||
@Override
|
}
|
||||||
public List<Serializable> getListDataByIdAndOrgi(String id , String creater, String orgi) {
|
|
||||||
return null ;
|
@Override
|
||||||
}
|
public List<Serializable> getListDataByIdAndOrgi(String id, String creater, String orgi) {
|
||||||
|
return null;
|
||||||
public void process(Object data , String orgi) {
|
}
|
||||||
|
|
||||||
}
|
public void process(Object data, String orgi) {
|
||||||
}
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
package com.chatopera.cc.persistence.impl;
|
package com.chatopera.cc.persistence.impl;
|
||||||
|
|
||||||
import com.chatopera.cc.model.Tag;
|
import com.chatopera.cc.model.Tag;
|
||||||
import com.chatopera.cc.model.User;
|
|
||||||
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
|
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import com.chatopera.cc.persistence.repository.UserRepository;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service("tagdata")
|
@Service("tagdata")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class TagDataExchangeImpl implements DataExchangeInterface {
|
public class TagDataExchangeImpl implements DataExchangeInterface {
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
public String getDataByIdAndOrgi(String id, String orgi) {
|
public String getDataByIdAndOrgi(String id, String orgi) {
|
||||||
Tag tag = tagRes.findByOrgiAndId(orgi, id);
|
Tag tag = tagRes.findByOrgiAndId(orgi, id);
|
||||||
|
@ -1,43 +1,42 @@
|
|||||||
/*
|
/*
|
||||||
* 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.Tag;
|
import com.chatopera.cc.model.Tag;
|
||||||
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 org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface TagRepository extends JpaRepository<Tag, String>
|
public interface TagRepository extends JpaRepository<Tag, String> {
|
||||||
{
|
|
||||||
|
Tag findByOrgiAndTag(String orgi, String tag);
|
||||||
Tag findByOrgiAndTag(String orgi, String tag);
|
|
||||||
|
Tag findByOrgiAndId(String orgi, String id);
|
||||||
Tag findByOrgiAndId(String orgi, String id);
|
|
||||||
|
@Query(value = "select t from Tag t where (:tagtype is null or t.tagtype = :tagtype) " +
|
||||||
@Query(value = "select t from Tag t where (:tagtype is null or t.tagtype = :tagtype) " +
|
"and t.orgi = :orgi")
|
||||||
"and t.orgi = :orgi")
|
Page<Tag> findByOrgiAndTagtype(@Param("orgi") String orgi, @Param("tagtype") String tagtype, Pageable paramPageable);
|
||||||
Page<Tag> findByOrgiAndTagtype(@Param("orgi") String orgi, @Param("tagtype") String tagtype, Pageable paramPageable);
|
|
||||||
|
List<Tag> findByOrgi(String orgi);
|
||||||
List<Tag> findByOrgi(String orgi);
|
|
||||||
|
List<Tag> findByOrgiAndTagtype(String orgi, String tagtype);
|
||||||
List<Tag> findByOrgiAndTagtype(String orgi, String tagtype);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user