AttachController.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package org.springblade.modules.resource.controller;
  18. import com.baomidou.mybatisplus.core.metadata.IPage;
  19. import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
  20. import io.swagger.annotations.Api;
  21. import io.swagger.annotations.ApiOperation;
  22. import io.swagger.annotations.ApiParam;
  23. import lombok.AllArgsConstructor;
  24. import org.springblade.core.boot.ctrl.BladeController;
  25. import org.springblade.core.launch.constant.AppConstant;
  26. import org.springblade.core.mp.support.Condition;
  27. import org.springblade.core.mp.support.Query;
  28. import org.springblade.core.tenant.annotation.NonDS;
  29. import org.springblade.core.tool.api.R;
  30. import org.springblade.core.tool.utils.Func;
  31. import org.springblade.modules.resource.entity.Attach;
  32. import org.springblade.modules.resource.service.IAttachService;
  33. import org.springblade.modules.resource.vo.AttachVO;
  34. import org.springframework.web.bind.annotation.*;
  35. import javax.validation.Valid;
  36. /**
  37. * 附件表 控制器
  38. *
  39. * @author Chill
  40. */
  41. @NonDS
  42. @RestController
  43. @AllArgsConstructor
  44. @RequestMapping(AppConstant.APPLICATION_RESOURCE_NAME + "/attach")
  45. @Api(value = "附件表", tags = "附件表接口")
  46. public class AttachController extends BladeController {
  47. private final IAttachService attachService;
  48. /**
  49. * 详情
  50. */
  51. @GetMapping("/detail")
  52. @ApiOperationSupport(order = 1)
  53. @ApiOperation(value = "详情", notes = "传入attach")
  54. public R<Attach> detail(Attach attach) {
  55. Attach detail = attachService.getOne(Condition.getQueryWrapper(attach));
  56. return R.data(detail);
  57. }
  58. /**
  59. * 分页 附件表
  60. */
  61. @GetMapping("/list")
  62. @ApiOperationSupport(order = 2)
  63. @ApiOperation(value = "分页", notes = "传入attach")
  64. public R<IPage<Attach>> list(Attach attach, Query query) {
  65. IPage<Attach> pages = attachService.page(Condition.getPage(query), Condition.getQueryWrapper(attach));
  66. return R.data(pages);
  67. }
  68. /**
  69. * 自定义分页 附件表
  70. */
  71. @GetMapping("/page")
  72. @ApiOperationSupport(order = 3)
  73. @ApiOperation(value = "分页", notes = "传入attach")
  74. public R<IPage<AttachVO>> page(AttachVO attach, Query query) {
  75. IPage<AttachVO> pages = attachService.selectAttachPage(Condition.getPage(query), attach);
  76. return R.data(pages);
  77. }
  78. /**
  79. * 新增 附件表
  80. */
  81. @PostMapping("/save")
  82. @ApiOperationSupport(order = 4)
  83. @ApiOperation(value = "新增", notes = "传入attach")
  84. public R save(@Valid @RequestBody Attach attach) {
  85. return R.status(attachService.save(attach));
  86. }
  87. /**
  88. * 修改 附件表
  89. */
  90. @PostMapping("/update")
  91. @ApiOperationSupport(order = 5)
  92. @ApiOperation(value = "修改", notes = "传入attach")
  93. public R update(@Valid @RequestBody Attach attach) {
  94. return R.status(attachService.updateById(attach));
  95. }
  96. /**
  97. * 新增或修改 附件表
  98. */
  99. @PostMapping("/submit")
  100. @ApiOperationSupport(order = 6)
  101. @ApiOperation(value = "新增或修改", notes = "传入attach")
  102. public R submit(@Valid @RequestBody Attach attach) {
  103. return R.status(attachService.saveOrUpdate(attach));
  104. }
  105. /**
  106. * 删除 附件表
  107. */
  108. @PostMapping("/remove")
  109. @ApiOperationSupport(order = 7)
  110. @ApiOperation(value = "逻辑删除", notes = "传入ids")
  111. public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
  112. return R.status(attachService.deleteLogic(Func.toLongList(ids)));
  113. }
  114. }