package com.pj.biz; import java.util.List; import cn.hutool.core.util.StrUtil; import com.pj.project.tb_person_black.TbPersonBlack; import com.pj.project.tb_person_black.TbPersonBlackService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import com.pj.utils.sg.*; import com.pj.utils.so.*; import com.pj.project4sp.SP; import com.pj.current.satoken.StpUserUtil; import cn.dev33.satoken.annotation.SaCheckPermission; /** * Controller: tb_person_black -- 人员黑名单 * * @author qzyReal */ @RestController @RequestMapping("/TbPersonBlack/") public class TbPersonBlackController { /** * 底层 Service 对象 */ @Autowired TbPersonBlackService tbPersonBlackService; /** * 增 */ @RequestMapping("add") @SaCheckPermission(TbPersonBlack.PERMISSION_CODE_ADD) @Transactional(rollbackFor = Exception.class) public AjaxJson add(TbPersonBlack t) { tbPersonBlackService.add(t); return AjaxJson.getSuccessData(t); } /** * 删 */ @RequestMapping("delete") @SaCheckPermission(TbPersonBlack.PERMISSION_CODE_DEL) public AjaxJson delete(Long id) { tbPersonBlackService.delete(id); return AjaxJson.getSuccess(); } /** * 删 - 根据id列表 */ @RequestMapping("deleteByIds") @SaCheckPermission(TbPersonBlack.PERMISSION_CODE_DEL) public AjaxJson deleteByIds() { List ids = SoMap.getRequestSoMap().getListByComma("ids", long.class); int line = SP.publicMapper.deleteByIds(TbPersonBlack.TABLE_NAME, ids); return AjaxJson.getByLine(line); } /** * 改 */ @RequestMapping("update") @SaCheckPermission(TbPersonBlack.PERMISSION_CODE_EDIT) public AjaxJson update(TbPersonBlack t) { tbPersonBlackService.update(t); return AjaxJson.getSuccess(); } /** * 查 - 根据id */ @RequestMapping("getById") public AjaxJson getById(Long id) { TbPersonBlack t = tbPersonBlackService.getById(id); return AjaxJson.getSuccessData(t); } /** * 查集合 - 根据条件(参数为空时代表忽略指定条件) */ @RequestMapping("getList") public AjaxJson getList() { SoMap so = SoMap.getRequestSoMap(); String deptId = StpUserUtil.getDeptId(); if (!StrUtil.equals(String.valueOf(StpUserUtil.ADMIN_DEPT_ID), deptId)) { so.put("deptId", deptId); } List list = tbPersonBlackService.getList(so.startPage()); return AjaxJson.getPageData(so.getDataCount(), list); } }