Commit b89a6ee4 by lanmw

update

parent 367267a8
package com.keymobile.tagmanager.api;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -6,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.keymobile.tagmanager.exception.TagNotExistException;
import com.keymobile.tagmanager.model.Page;
import com.keymobile.tagmanager.model.Tag;
import com.keymobile.tagmanager.service.TagService;
......@@ -52,13 +55,13 @@ public class TagCtrl {
// @PreAuthorize("principal.authorities.?[authority.startsWith('ROLE_tagmanager_admin')].size() > 0")
@ApiOperation(value = "查询系统标签树", notes = "查询系统标签树")
@GetMapping(value = "/querySystemTagAsTree")
public JsonNode[] querySystemTagAsTree(@RequestParam(value = "parentId", required = false) String parentId) throws Exception {
public JsonNode[] querySystemTagAsTree(@RequestParam(value = "parentId", required = false) String parentId) throws TagNotExistException {
return tagService.querySystemTagAsTree(parentId);
}
@ApiOperation(value = "查询个人标签树", notes = "查询个人标签树")
@GetMapping(value = "/queryPersonalTagAsTree")
public JsonNode[] queryPersonalTagAsTree(@RequestParam(value = "parentId", required = false) String parentId) throws Exception {
public JsonNode[] queryPersonalTagAsTree(@RequestParam(value = "parentId", required = false) String parentId) throws TagNotExistException {
String userName = UserInfoUtils.getUserName();
return tagService.queryPersonalTagAsTree(parentId, userName);
}
......@@ -68,7 +71,7 @@ public class TagCtrl {
public Page searchSystemTagByPage(@RequestParam(required = false, value = "keyword") String keyword,
@RequestParam(required = false, value = "domain") Integer domain,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) throws Exception {
@RequestParam("pageSize") Integer pageSize) {
return tagService.searchSystemTagByPage(keyword, domain, new Page(pageSize, pageNo));
}
......@@ -77,9 +80,16 @@ public class TagCtrl {
public Page searchPersonalTagByPage(@RequestParam(required = false, value = "keyword") String keyword,
@RequestParam(required = false , value = "domain") Integer domain,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) throws Exception {
@RequestParam("pageSize") Integer pageSize) {
String userName = UserInfoUtils.getUserName();
return tagService.searchPersonalTagByPage(userName, keyword, domain, new Page(pageSize, pageNo));
}
@ApiOperation(value = "分享标签", notes = "分享标签")
@PostMapping(value = "/shareTags")
public void shareTags(@RequestBody List<String> tagIds) throws Exception {
tagService.shareTags(tagIds);
}
}
......@@ -29,6 +29,7 @@ public class Tag implements Serializable{
private String creator;
private String isOpen = Constants.TAG_CLOSE_STATUS; //0 不公开, 1, 公开
private Integer domain;
private boolean dimension = false;//是否维度标签
public Tag() {}
......@@ -150,5 +151,13 @@ public class Tag implements Serializable{
this.domain = domain;
}
public boolean isDimension() {
return dimension;
}
public void setDimension(boolean dimension) {
this.dimension = dimension;
}
}
......@@ -75,7 +75,7 @@ public class TagService {
Tag t = mongoOperations.findOne(Query.query(Criteria.where("path").is(tag.getPath())
.and("creator").is(userName)), Tag.class);
if (t != null && !t.getId().equals(tag.getId()))
throw new TagDuplicateException("tag [" + tag.getName() + "] is already exist in target!");
throw new TagDuplicateException("tag [" + tag.getName() + "] is already exist in target!, userName is [" + userName + "]");
}
......@@ -223,4 +223,12 @@ public class TagService {
return false;
}
public void shareTags(List<String> tagIds) {
Iterable<Tag> tags = tagRepository.findAllById(tagIds);
tags.forEach(t -> {
t.setIsOpen(Constants.TAG_OPEN_STATUS);
});
tagRepository.saveAll(tags);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment