TbLocationController.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package com.ruoyi.asset.controller;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import com.ruoyi.common.core.domain.TreeSelect;
  5. import io.swagger.v3.oas.annotations.Parameter;
  6. import org.springframework.http.MediaType;
  7. import org.springframework.security.access.prepost.PreAuthorize;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.PutMapping;
  12. import org.springframework.web.bind.annotation.DeleteMapping;
  13. import org.springframework.web.bind.annotation.PathVariable;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import com.ruoyi.common.annotation.Log;
  18. import com.ruoyi.common.core.controller.BaseController;
  19. import com.ruoyi.common.core.domain.AjaxResult;
  20. import com.ruoyi.common.enums.BusinessType;
  21. import com.ruoyi.asset.domain.TbLocation;
  22. import com.ruoyi.asset.service.ITbLocationService;
  23. import com.ruoyi.common.utils.poi.ExcelUtil;
  24. import com.ruoyi.common.core.page.TableDataInfo;
  25. /**
  26. * 所属位置Controller
  27. *
  28. * @author 原动力
  29. * @date 2023-05-15
  30. */
  31. @RestController
  32. @RequestMapping("/asset/location")
  33. public class TbLocationController extends BaseController
  34. {
  35. @Autowired
  36. private ITbLocationService tbLocationService;
  37. /**
  38. * 查询所属位置列表
  39. */
  40. @PreAuthorize("@ss.hasPermi('asset:location:list')")
  41. @GetMapping("/list")
  42. public TableDataInfo list(TbLocation tbLocation)
  43. {
  44. startPage();
  45. List<TbLocation> list = tbLocationService.selectTbLocationList(tbLocation);
  46. return getDataTable(list);
  47. }
  48. @PreAuthorize("@ss.hasPermi('asset:location:list')")
  49. @PostMapping("/tree")
  50. public TableDataInfo tree(@RequestBody(required = false) TbLocation tbLocation) {
  51. startPage();
  52. List<TbLocation> tbLocations = tbLocationService.selectTree(tbLocation);
  53. return getDataTable(tbLocations);
  54. }
  55. @PreAuthorize("@ss.hasPermi('asset:location:list')")
  56. @GetMapping("/treeSelect")
  57. public AjaxResult treeSelect(@Parameter(name = "id") Long id) {
  58. List<TreeSelect> tbLocations = tbLocationService.selectTreeSelect(id);
  59. return success(tbLocations);
  60. }
  61. /**
  62. * 导出所属位置列表
  63. */
  64. @PreAuthorize("@ss.hasPermi('asset:location:export')")
  65. @Log(title = "所属位置", businessType = BusinessType.EXPORT)
  66. @PostMapping("/export")
  67. public void export(HttpServletResponse response, TbLocation tbLocation)
  68. {
  69. List<TbLocation> list = tbLocationService.selectTbLocationList(tbLocation);
  70. ExcelUtil<TbLocation> util = new ExcelUtil<TbLocation>(TbLocation.class);
  71. util.exportExcel(response, list, "所属位置数据");
  72. }
  73. /**
  74. * 获取所属位置详细信息
  75. */
  76. @PreAuthorize("@ss.hasPermi('asset:location:query')")
  77. @GetMapping(value = "/{id}")
  78. public AjaxResult getInfo(@PathVariable("id") Long id)
  79. {
  80. return success(tbLocationService.selectTbLocationById(id));
  81. }
  82. /**
  83. * 新增所属位置
  84. */
  85. @PreAuthorize("@ss.hasPermi('asset:location:add')")
  86. @Log(title = "所属位置", businessType = BusinessType.INSERT)
  87. @PostMapping
  88. public AjaxResult add(@RequestBody TbLocation tbLocation)
  89. {
  90. return toAjax(tbLocationService.insertTbLocation(tbLocation));
  91. }
  92. /**
  93. * 修改所属位置
  94. */
  95. @PreAuthorize("@ss.hasPermi('asset:location:edit')")
  96. @Log(title = "所属位置", businessType = BusinessType.UPDATE)
  97. @PutMapping
  98. public AjaxResult edit(@RequestBody TbLocation tbLocation)
  99. {
  100. return toAjax(tbLocationService.updateTbLocation(tbLocation));
  101. }
  102. /**
  103. * 删除所属位置
  104. */
  105. @PreAuthorize("@ss.hasPermi('asset:location:remove')")
  106. @Log(title = "所属位置", businessType = BusinessType.DELETE)
  107. @DeleteMapping("/{ids}")
  108. public AjaxResult remove(@PathVariable Long[] ids)
  109. {
  110. return toAjax(tbLocationService.deleteTbLocationByIds(ids));
  111. }
  112. /**
  113. * 查看位置二维码
  114. */
  115. @GetMapping(value = "/code/{number}", produces = MediaType.IMAGE_PNG_VALUE)
  116. public byte[] selectQrCode(@PathVariable("number") String locationNumber) {
  117. return tbLocationService.selectQrCodeByLocationNumber(locationNumber);
  118. }
  119. }