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("删除失败");
|
}
|
}
|