wzy
2021-01-19 cc74efb36fd1f1de56b3acb2ba59d4b416eaed4f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.matrix.system.hive.action;
 
import com.matrix.core.pojo.AjaxResult;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.hive.bean.SysVipLabel;
import com.matrix.system.hive.dao.SysVipLabelDao;
import com.matrix.system.hive.plugin.util.CollectionUtils;
import jodd.util.CollectionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.util.Date;
import java.util.List;
 
/**
 * @author wzy
 * @date 2020-12-17
 **/
@Controller
@RequestMapping(value = "/admin/label")
public class SysVipLabelController extends BaseController{
 
    @Autowired
    private SysVipLabelDao sysVipLabelDao;
 
    @RequestMapping(value = "/add")
    @ResponseBody
    public AjaxResult add(SysVipLabel sysVipLabel) {
        SysUsers sysUsers = getMe();
 
        List<SysVipLabel> sysVipLabels = sysVipLabelDao.selectByModel(sysVipLabel);
        if (CollectionUtils.isNotEmpty(sysVipLabels)) {
            return AjaxResult.buildFailInstance("已存在该标签");
        }
 
        sysVipLabel.setCreateBy(sysUsers.getSuName());
        sysVipLabel.setCreateTime(new Date());
 
        int i = sysVipLabelDao.insert(sysVipLabel);
        if (i > 0) {
            AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("添加成功");
            ajaxResult.putInMap("label", sysVipLabel);
            return ajaxResult;
        }
        return AjaxResult.buildFailInstance("添加失败");
    }
 
    @RequestMapping(value = "/del")
    @ResponseBody
    public AjaxResult del(Long id) {
        int i = sysVipLabelDao.deleteById(id);
        if (i > 0) {
            return AjaxResult.buildSuccessInstance("删除成功");
        }
        return AjaxResult.buildFailInstance("删除失败");
    }
}