Commit 367267a8 by lanmw

deleteTag

parent e2de8df7
package com.keymobile.tagmanager.api; package com.keymobile.tagmanager.api;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
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.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.keymobile.tagmanager.model.Page; import com.keymobile.tagmanager.model.Page;
import com.keymobile.tagmanager.model.Tag; import com.keymobile.tagmanager.model.Tag;
import com.keymobile.tagmanager.service.TagService; import com.keymobile.tagmanager.service.TagService;
import com.keymobile.tagmanager.util.Constants;
import com.keymobile.tagmanager.util.JsonTreeHelper.JsonNode; import com.keymobile.tagmanager.util.JsonTreeHelper.JsonNode;
import com.keymobile.tagmanager.util.UserInfoUtils; import com.keymobile.tagmanager.util.UserInfoUtils;
...@@ -32,36 +31,49 @@ public class TagCtrl { ...@@ -32,36 +31,49 @@ public class TagCtrl {
@RequestBody Tag tag) throws Exception { @RequestBody Tag tag) throws Exception {
String userName = UserInfoUtils.getUserName(); String userName = UserInfoUtils.getUserName();
tag.setCreator(userName); tag.setCreator(userName);
return tagService.addOrUpdateTag(parentId, tag); return tagService.addOrUpdateTag(parentId, tag, userName);
} }
@ApiOperation(value = "删除标签", notes = "删除标签")
@PostMapping(value = "/deleteTag")
public void deleteTag(@RequestParam(value = "tagId") String tagId) throws Exception {
String userName = UserInfoUtils.getUserName();
tagService.deleteTag(tagId, userName);
}
@ApiOperation(value = "存在节点", notes = "存在节点")
@GetMapping(value = "/hasChild")
public boolean hasChild(@RequestParam(value = "tagId") String tagId) throws Exception {
String userName = UserInfoUtils.getUserName();
return tagService.hasChild(tagId, userName);
}
// @PreAuthorize("principal.authorities.?[authority.startsWith('ROLE_tagmanager_admin')].size() > 0") // @PreAuthorize("principal.authorities.?[authority.startsWith('ROLE_tagmanager_admin')].size() > 0")
@ApiOperation(value = "查询系统标签树", notes = "查询系统标签树") @ApiOperation(value = "查询系统标签树", notes = "查询系统标签树")
@PostMapping(value = "/querySystemTagAsTree") @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 Exception {
String userName = UserInfoUtils.getUserName(); return tagService.querySystemTagAsTree(parentId);
return tagService.queryTagAsTreeByTagType(Constants.TAG_SYSTEM_TYPE, parentId, userName);
} }
@ApiOperation(value = "查询个人标签树", notes = "查询个人标签树") @ApiOperation(value = "查询个人标签树", notes = "查询个人标签树")
@PostMapping(value = "/queryPersonalTagAsTree") @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 Exception {
String userName = UserInfoUtils.getUserName(); String userName = UserInfoUtils.getUserName();
return tagService.queryTagAsTreeByTagType(Constants.TAG_PERSONAL_TYPE, parentId, userName); return tagService.queryPersonalTagAsTree(parentId, userName);
} }
@ApiOperation(value = "搜索系統标签", notes = "搜索系統标签") @ApiOperation(value = "搜索系統标签", notes = "搜索系統标签")
@PostMapping(value = "/searchSystemTagByPage") @GetMapping(value = "/searchSystemTagByPage")
public Page searchSystemTagByPage(@RequestParam(required = false, value = "keyword") String keyword, public Page searchSystemTagByPage(@RequestParam(required = false, value = "keyword") String keyword,
@RequestParam(required = false, value = "domain") Integer domain, @RequestParam(required = false, value = "domain") Integer domain,
@RequestParam("pageNo") Integer pageNo, @RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) throws Exception { @RequestParam("pageSize") Integer pageSize) throws Exception {
String userName = UserInfoUtils.getUserName(); return tagService.searchSystemTagByPage(keyword, domain, new Page(pageSize, pageNo));
return tagService.searchSystemTagByPage(userName, keyword, domain, new Page(pageSize, pageNo));
} }
@ApiOperation(value = "搜索个人标签", notes = "搜索个人标签") @ApiOperation(value = "搜索个人标签", notes = "搜索个人标签")
@PostMapping(value = "/searchPersonalTagByPage") @GetMapping(value = "/searchPersonalTagByPage")
public Page searchPersonalTagByPage(@RequestParam(required = false, value = "keyword") String keyword, public Page searchPersonalTagByPage(@RequestParam(required = false, value = "keyword") String keyword,
@RequestParam(required = false , value = "domain") Integer domain, @RequestParam(required = false , value = "domain") Integer domain,
@RequestParam("pageNo") Integer pageNo, @RequestParam("pageNo") Integer pageNo,
......
...@@ -59,6 +59,20 @@ public class MongoOperationsUtil { ...@@ -59,6 +59,20 @@ public class MongoOperationsUtil {
return q; return q;
} }
public static Query createQueryWithSpecifiedField(Map<String, Object> condition, Page page, List<Order> orderList) {
Document dbObject = new Document();
condition.forEach((k, v) -> {
dbObject.put(k, v);
});
Query q = new BasicQuery(dbObject);
q.skip(page.getOffset());
q.limit(page.getPageSize());
if (orderList != null && !orderList.isEmpty()) {
q.with(Sort.by(orderList));
}
return q;
}
public static Query createQueryWithSpecifiedField(List<String> specifields) { public static Query createQueryWithSpecifiedField(List<String> specifields) {
Map<String, Object> condition = new HashMap<>(); Map<String, Object> condition = new HashMap<>();
return createQueryWithSpecifiedField(condition, specifields); return createQueryWithSpecifiedField(condition, specifields);
......
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