package com.pj.biz; import java.util.List; import cn.hutool.core.util.StrUtil; import com.pj.project.tb_venues.TbVenues; import com.pj.project.tb_venues.TbVenuesService; import org.aspectj.weaver.loadtime.Aj; 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_venues -- 场所管理 * * @author qzyReal */ @RestController @RequestMapping("/TbVenues/") public class TbVenuesController { /** * 底层 Service 对象 */ @Autowired TbVenuesService tbVenuesService; /** * 增 */ @RequestMapping("add") @SaCheckPermission(TbVenues.PERMISSION_CODE_ADD) public AjaxJson add(TbVenues t) { tbVenuesService.add(t); return AjaxJson.getSuccessData(t); } /** * 删 */ @RequestMapping("delete") @SaCheckPermission(TbVenues.PERMISSION_CODE_DEL) public AjaxJson delete(Long id) { tbVenuesService.delete(id); return AjaxJson.getSuccess(); } /** * 改 */ @RequestMapping("update") @SaCheckPermission(TbVenues.PERMISSION_CODE_EDIT) public AjaxJson update(TbVenues t) { tbVenuesService.update(t); return AjaxJson.getSuccess(); } /** * 查 - 根据id */ @RequestMapping("getById") public AjaxJson getById(Long id) { TbVenues t = tbVenuesService.getById(id); return AjaxJson.getSuccessData(t); } /** * 查集合 - 根据条件(参数为空时代表忽略指定条件) */ @RequestMapping("getList") public AjaxJson getList() { SoMap so = SoMap.getRequestSoMap(); List list = tbVenuesService.getList(so.startPage()); return AjaxJson.getPageData(so.getDataCount(), list); } /** * 查集合 (整个表数据转化为tree结构返回) */ @RequestMapping("getTree") public AjaxJson getTree() { // 获取记录 SoMap so = SoMap.getRequestSoMap(); String deptId = StpUserUtil.getDeptId(); if (!StrUtil.equals(String.valueOf(StpUserUtil.ADMIN_DEPT_ID), deptId)) { so.put("deptId", deptId); } List list = tbVenuesService.getList(so); // 转为tree结构,并返回 List listMap = SoMap.getSoMapByList(list); List listTree = SoMap.listToTree(listMap, "id", "pId", "children"); return AjaxJson.getPageData((long) listMap.size(), listTree); } @GetMapping(value = "getInnerList") public AjaxJson getInnerList() { SoMap so = SoMap.getRequestSoMap(); List list = tbVenuesService.getInnerList(so); return AjaxJson.getSuccessData(list); } @PostMapping(value = "release") public AjaxJson pass(Long id) { return tbVenuesService.release(id); } }