|
@@ -7,8 +7,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -39,13 +41,13 @@ public class TagInfoController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping(value = "/list")
|
|
|
- public Result<IPage<TagInfo>> queryPageList(TagInfo tagInfo,
|
|
|
- @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
- @RequestParam(name="pageSize", defaultValue="100") Integer pageSize,
|
|
|
+ public Result<IPage<TagInfo>> queryPageList(TagInfo tagInfo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="100") Integer pageSize,
|
|
|
HttpServletRequest req) {
|
|
|
Result<IPage<TagInfo>> result = new Result<>();
|
|
|
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
QueryWrapper<TagInfo> queryWrapper = QueryGenerator.initQueryWrapper(tagInfo, req.getParameterMap());
|
|
|
Page<TagInfo> page = new Page<>(pageNo, pageSize);
|
|
|
+ queryWrapper.eq("del_flag",0);
|
|
|
IPage<TagInfo> pageList = tagInfoService.page(page, queryWrapper);
|
|
|
result.setSuccess(true);
|
|
|
result.setResult(pageList);
|
|
@@ -61,8 +63,12 @@ public class TagInfoController {
|
|
|
public Result<TagInfo> add(@RequestBody TagInfo tagInfo) {
|
|
|
Result<TagInfo> result = new Result<>();
|
|
|
try {
|
|
|
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
tagInfo.setDelFlag(0);
|
|
|
- tagInfo.setStatus(1);
|
|
|
+ if(null == tagInfo.getStatus()){
|
|
|
+ tagInfo.setStatus(1);
|
|
|
+ }
|
|
|
+ tagInfo.setUserId(user.getId());
|
|
|
int level = 1;
|
|
|
Long parentId = tagInfo.getParentId();
|
|
|
if(null!=parentId){
|
|
@@ -72,12 +78,20 @@ public class TagInfoController {
|
|
|
return result;
|
|
|
}
|
|
|
String tagCode = parentTag.getTagCode()+tagInfo.getTagCode();
|
|
|
- level = parentTag.getLevel()+1;
|
|
|
TagInfo getTag = tagInfoService.getByTagCode(tagCode);
|
|
|
if(null!=getTag){
|
|
|
result.error500("标签编码已存在");
|
|
|
return result;
|
|
|
}
|
|
|
+ tagInfo.setTagCategoryId(parentTag.getTagCategoryId());
|
|
|
+ if(parentTag.getLevel() == 1){
|
|
|
+ tagInfo.setFirstTagId(parentTag.getId());
|
|
|
+ }
|
|
|
+ if(parentTag.getLevel() == 2){
|
|
|
+ tagInfo.setSecendTagId(parentTag.getId());
|
|
|
+ tagInfo.setFirstTagId(parentTag.getParentId());
|
|
|
+ }
|
|
|
+ level = parentTag.getLevel()+1;
|
|
|
tagInfo.setTagCode(tagCode);
|
|
|
}
|
|
|
tagInfo.setLevel(level);
|