package com.xunmei.system.controller; import com.xunmei.common.core.exception.ServiceException; import com.xunmei.system.api.domain.SysArea; import com.xunmei.system.api.domain.SysOrg; import com.xunmei.system.mapper.SysOrgMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.xunmei.common.log.annotation.Log; import com.xunmei.common.log.enums.BusinessType; import com.xunmei.common.security.annotation.RequiresPermissions; import com.xunmei.system.service.ISysAreaService; import com.xunmei.common.core.web.controller.BaseController; import com.xunmei.common.core.web.domain.AjaxResult; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import com.xunmei.common.core.web.page.TableDataInfo; /** * 【请填写功能名称】Controller * * @author xunmei * @date 2023-08-14 */ @Api(tags = {"SysArea"}) @RestController @RequestMapping("/area") public class SysAreaController extends BaseController { @Autowired private ISysAreaService sysAreaService; @Autowired private SysOrgMapper sysOrgMapper; /** * 查询【请填写功能名称】列表 */ @ApiOperation(value = "查询SysArea列表") @RequiresPermissions("system:area:list") @GetMapping("/list") public TableDataInfo list(SysArea sysArea) { return sysAreaService.selectPage(sysArea); } /** * 获取【请填写功能名称】详细信息 */ @ApiOperation(value = "获取SysArea详细信息") @RequiresPermissions("system:area:query") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(sysAreaService.selectSysAreaById(id)); } /** * 获取【请填写功能名称】详细信息 */ @ApiOperation(value = "根据机构获取区域") @GetMapping("/getAreaByOrg/{orgId}") public AjaxResult getAreaByOrg(@PathVariable("orgId") Long orgId) { /* SysOrg sysOrg = sysOrgMapper.selectSysOrgById(orgId); if (null==sysOrg.getType()){ return error("该机构没有机构类型,请维护!"); }*/ return success(sysAreaService.getAreaByOrg(orgId)); } /** * 新增【请填写功能名称】 */ @ApiOperation(value = "新增SysArea") @RequiresPermissions("system:area:add") @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody SysArea sysArea) { return toAjax(sysAreaService.insertSysArea(sysArea)); } /** * 修改【请填写功能名称】 */ @ApiOperation(value = "修改SysArea") @RequiresPermissions("system:area:edit") @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody SysArea sysArea) { return toAjax(sysAreaService.updateSysArea(sysArea)); } /** * 删除【请填写功能名称】 */ @ApiOperation(value = "删除SysArea") @RequiresPermissions("system:area:remove") @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(sysAreaService.deleteSysAreaByIds(ids)); } /** *按机构类型获取所有区域 */ @ApiOperation(value = "按机构类型获取所有区域") // @RequiresPermissions("system:area:list @GetMapping("/orgType/{orgType}") public AjaxResult listByOrgType(@PathVariable Integer orgType) { SysArea condition = new SysArea(); condition.setOrgType(orgType.toString()); condition.setPageNum(1L); condition.setPageSize(9999L); TableDataInfo table= sysAreaService.selectPage(condition); return success(table.getRows()); } }