From 2620b87fd24feaa0b60cd8b529cd44c3a7557c30 Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Mon, 25 Jan 2021 15:59:45 +0800
Subject: [PATCH] 1、修改树形分类可以选择自己为自己的父级的bug
---
zq-erp/src/main/java/com/matrix/system/hive/action/SysVipLabelController.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/action/SysVipLabelController.java b/zq-erp/src/main/java/com/matrix/system/hive/action/SysVipLabelController.java
index a93ef26..cbb8ac3 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/action/SysVipLabelController.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/action/SysVipLabelController.java
@@ -1,7 +1,10 @@
package com.matrix.system.hive.action;
import com.matrix.core.pojo.AjaxResult;
+import com.matrix.core.pojo.PaginationVO;
+import com.matrix.core.tools.WebUtil;
import com.matrix.system.common.bean.SysUsers;
+import com.matrix.system.constance.Dictionary;
import com.matrix.system.hive.bean.SysVipLabel;
import com.matrix.system.hive.dao.SysVipLabelDao;
import com.matrix.system.hive.plugin.util.CollectionUtils;
@@ -14,6 +17,7 @@
import java.util.Date;
import java.util.List;
+import java.util.Random;
/**
* @author wzy
@@ -26,11 +30,22 @@
@Autowired
private SysVipLabelDao sysVipLabelDao;
+
+ @RequestMapping(value = "/showList")
+ @ResponseBody
+ private AjaxResult showList(SysVipLabel sysVipLabel, PaginationVO pageVo) {
+ SysUsers user = getMe();
+ sysVipLabel.setCompanyId(user.getCompanyId());
+ return AjaxResult.buildSuccessInstance(sysVipLabelDao.selectInPage(sysVipLabel, pageVo), sysVipLabelDao.selectTotal(sysVipLabel));
+ }
+
@RequestMapping(value = "/add")
@ResponseBody
public AjaxResult add(SysVipLabel sysVipLabel) {
SysUsers sysUsers = getMe();
+ sysVipLabel.setIsAll(1);
+ sysVipLabel.setCompanyId(sysUsers.getCompanyId());
List<SysVipLabel> sysVipLabels = sysVipLabelDao.selectByModel(sysVipLabel);
if (CollectionUtils.isNotEmpty(sysVipLabels)) {
return AjaxResult.buildFailInstance("已存在该标签");
@@ -38,8 +53,37 @@
sysVipLabel.setCreateBy(sysUsers.getSuName());
sysVipLabel.setCreateTime(new Date());
+ sysVipLabel.setColor(Dictionary.COLORS[new Random().nextInt(6)]);
int i = sysVipLabelDao.insert(sysVipLabel);
+ if (i > 0) {
+ AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("添加成功");
+ ajaxResult.putInMap("label", sysVipLabel);
+ return ajaxResult;
+ }
+ return AjaxResult.buildFailInstance("添加失败");
+ }
+
+ @RequestMapping(value = "/modify")
+ @ResponseBody
+ public AjaxResult modify(SysVipLabel sysVipLabel) {
+ SysUsers sysUsers = getMe();
+
+ SysVipLabel hasExist = sysVipLabelDao.selectById(sysVipLabel.getId());
+ if (!sysVipLabel.getLabel().equals(hasExist.getLabel())) {
+ SysVipLabel query = new SysVipLabel();
+ query.setIsAll(1);
+ query.setCompanyId(sysUsers.getCompanyId());
+ query.setLabel(sysVipLabel.getLabel());
+ List<SysVipLabel> sysVipLabels = sysVipLabelDao.selectByModel(sysVipLabel);
+ if (CollectionUtils.isNotEmpty(sysVipLabels)) {
+ return AjaxResult.buildFailInstance("已存在该标签");
+ }
+ }
+
+ sysVipLabel.setColor(Dictionary.COLORS[new Random().nextInt(6)]);
+
+ int i = sysVipLabelDao.update(sysVipLabel);
if (i > 0) {
AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("添加成功");
ajaxResult.putInMap("label", sysVipLabel);
@@ -57,4 +101,13 @@
}
return AjaxResult.buildFailInstance("删除失败");
}
+
+ @RequestMapping(value = "/edit")
+ public String edit(Long id) {
+ if (id != null) {
+ SysVipLabel sysVipLabel = sysVipLabelDao.selectById(id);
+ WebUtil.getRequest().setAttribute("obj", sysVipLabel);
+ }
+ return "admin/hive/operate/label-form";
+ }
}
--
Gitblit v1.9.1