package com.ruoyi.asset.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.core.domain.TreeSelect; import io.swagger.v3.oas.annotations.Parameter; import org.springframework.http.MediaType; import org.springframework.security.access.prepost.PreAuthorize; 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.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.asset.domain.TbLocation; import com.ruoyi.asset.service.ITbLocationService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * 所属位置Controller * * @author 原动力 * @date 2023-05-15 */ @RestController @RequestMapping("/asset/location") public class TbLocationController extends BaseController { @Autowired private ITbLocationService tbLocationService; /** * 查询所属位置列表 */ @PreAuthorize("@ss.hasPermi('asset:location:list')") @GetMapping("/list") public TableDataInfo list(TbLocation tbLocation) { startPage(); List list = tbLocationService.selectTbLocationList(tbLocation); return getDataTable(list); } @PreAuthorize("@ss.hasPermi('asset:location:list')") @PostMapping("/tree") public TableDataInfo tree(@RequestBody(required = false) TbLocation tbLocation) { startPage(); List tbLocations = tbLocationService.selectTree(tbLocation); return getDataTable(tbLocations); } @PreAuthorize("@ss.hasPermi('asset:location:list')") @GetMapping("/treeSelect") public AjaxResult treeSelect(@Parameter(name = "id") Long id) { List tbLocations = tbLocationService.selectTreeSelect(id); return success(tbLocations); } /** * 导出所属位置列表 */ @PreAuthorize("@ss.hasPermi('asset:location:export')") @Log(title = "所属位置", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TbLocation tbLocation) { List list = tbLocationService.selectTbLocationList(tbLocation); ExcelUtil util = new ExcelUtil(TbLocation.class); util.exportExcel(response, list, "所属位置数据"); } /** * 获取所属位置详细信息 */ @PreAuthorize("@ss.hasPermi('asset:location:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(tbLocationService.selectTbLocationById(id)); } /** * 新增所属位置 */ @PreAuthorize("@ss.hasPermi('asset:location:add')") @Log(title = "所属位置", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TbLocation tbLocation) { return toAjax(tbLocationService.insertTbLocation(tbLocation)); } /** * 修改所属位置 */ @PreAuthorize("@ss.hasPermi('asset:location:edit')") @Log(title = "所属位置", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TbLocation tbLocation) { return toAjax(tbLocationService.updateTbLocation(tbLocation)); } /** * 删除所属位置 */ @PreAuthorize("@ss.hasPermi('asset:location:remove')") @Log(title = "所属位置", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(tbLocationService.deleteTbLocationByIds(ids)); } /** * 查看位置二维码 */ @GetMapping(value = "/code/{number}", produces = MediaType.IMAGE_PNG_VALUE) public byte[] selectQrCode(@PathVariable("number") String locationNumber) { return tbLocationService.selectQrCodeByLocationNumber(locationNumber); } }