程式碼拉取完成,頁面將自動刷新
package com.baiyulong.crm.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.baiyulong.crm.base.Query;
import com.baiyulong.crm.base.R;
import com.baiyulong.crm.base.RoleEnum;
import com.baiyulong.crm.bean.BirthdayManager;
import com.baiyulong.crm.bean.Manager;
import com.baiyulong.crm.service.BirthdayManagerService;
import com.baiyulong.crm.service.ManagerService;
import com.baiyulong.crm.utils.CommonUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
/**
* <p>
* 前端控制器
* </p>
*
* @author byl
* @since 2020-02-26
*/
@Controller
@RequestMapping("/birthdayManager")
public class BirthdayManagerController {
@Resource
private ManagerService managerService;
@Resource
private BirthdayManagerService birthdayManagerService;
/**
* 获取客户联系人生日列表
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.POST)
@ResponseBody
public R<Page<BirthdayManager>> getCustomerContanctList(HttpServletRequest request, Query query, String name) {
//判断用户是否登录
Manager manager = managerService.checkLogin(request);
Page page = CommonUtil.getPage(query);
EntityWrapper<BirthdayManager> wrapper = new EntityWrapper<BirthdayManager>();
if(!StringUtils.isEmpty(name)) {
wrapper.like("contanct_name", name);
}
ArrayList<String> sort = new ArrayList<String>();
sort.add("birthday");
wrapper.orderDesc(sort);
if(manager.getRoleId() != RoleEnum.Admin.getRoleId()) {
wrapper.eq("user_id", manager.getManagerId());
}
return R.data(birthdayManagerService.selectPage(page, wrapper));
}
/**
* 删除客户联系人生日
* @return
* @return
*/
@RequestMapping(value="/remove",method=RequestMethod.POST)
@ResponseBody
public R removeCustomer (HttpServletRequest request, long id) {
//判断用户是否登录
managerService.checkLogin(request);
return R.status(birthdayManagerService.deleteById(id));
}
/**
* 批量删除客户联系人
* @return
* @return
*/
@RequestMapping(value="/batchremove",method=RequestMethod.POST)
@ResponseBody
public R batchremove (HttpServletRequest request, String ids) {
//判断用户是否登录
managerService.checkLogin(request);
List<Long> listId = Arrays.asList(CommonUtil.toLongArray(ids));
if(listId != null && listId.size() > 0) {
for (Long id : listId) {
birthdayManagerService.deleteById(id);
}
}
return R.status(true);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。