NoticeSupplyController.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. package com.dgtly.notice.controller;
  2. import java.util.List;
  3. import com.dgtly.common.annotation.DataScope;
  4. import com.dgtly.common.utils.StringUtils;
  5. import com.dgtly.common.utils.file.FileUploadUtils;
  6. import org.apache.shiro.authz.annotation.RequiresPermissions;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.ui.ModelMap;
  10. import org.springframework.web.bind.annotation.GetMapping;
  11. import org.springframework.web.bind.annotation.PathVariable;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.ResponseBody;
  15. import com.dgtly.common.annotation.Log;
  16. import com.dgtly.common.enums.BusinessType;
  17. import com.dgtly.notice.domain.NoticeSupply;
  18. import com.dgtly.notice.service.INoticeSupplyService;
  19. import com.dgtly.common.core.controller.BaseController;
  20. import com.dgtly.common.core.domain.AjaxResult;
  21. import com.dgtly.common.utils.poi.ExcelUtil;
  22. import com.dgtly.common.core.page.TableDataInfo;
  23. import org.springframework.web.multipart.MultipartFile;
  24. /**
  25. * 【请填写功能名称】Controller
  26. *
  27. * @author dgtly
  28. * @date 2020-02-13
  29. */
  30. @Controller
  31. @RequestMapping("/notice/supply")
  32. public class NoticeSupplyController extends BaseController
  33. {
  34. private String prefix = "notice/supply";
  35. @Autowired
  36. private INoticeSupplyService noticeSupplyService;
  37. @RequiresPermissions("notice:supply:view")
  38. @GetMapping()
  39. public String supply()
  40. {
  41. return prefix + "/supply";
  42. }
  43. /**
  44. * 供应信息列表
  45. */
  46. @RequiresPermissions("notice:supply:list")
  47. @PostMapping("/list")
  48. @ResponseBody
  49. public TableDataInfo list(NoticeSupply noticeSupply)
  50. {
  51. startPage();
  52. List<NoticeSupply> list = noticeSupplyService.selectNoticeSupplyList(noticeSupply);
  53. return getDataTable(list);
  54. }
  55. /**
  56. * 导出【请填写功能名称】列表
  57. */
  58. @RequiresPermissions("notice:supply:export")
  59. @PostMapping("/export")
  60. @ResponseBody
  61. public AjaxResult export(NoticeSupply noticeSupply)
  62. {
  63. List<NoticeSupply> list = noticeSupplyService.selectNoticeSupplyList(noticeSupply);
  64. ExcelUtil<NoticeSupply> util = new ExcelUtil<NoticeSupply>(NoticeSupply.class);
  65. return util.exportExcel(list, "supply");
  66. }
  67. /**
  68. * 新增【请填写功能名称】
  69. */
  70. @GetMapping("/add")
  71. public String add()
  72. {
  73. return prefix + "/add";
  74. }
  75. /**
  76. * 新增保存【请填写功能名称】
  77. */
  78. @RequiresPermissions("notice:supply:add")
  79. @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
  80. @PostMapping("/add")
  81. @ResponseBody
  82. public AjaxResult addSave(NoticeSupply noticeSupply, MultipartFile file)
  83. {
  84. if(StringUtils.isNotEmpty(noticeSupply.getPicture())){
  85. //获取base64文件后缀
  86. String houzhui = noticeSupply.getPicture().split(";")[0].split("\\/")[1];
  87. //获取base64值
  88. String base64 = noticeSupply.getPicture().substring( noticeSupply.getPicture().indexOf(",") + 1);
  89. //base64转文件 并返回展示url
  90. String fileUrl = FileUploadUtils.base64ToFile(base64,FileUploadUtils.getDefaultBaseDir()+"/content",System.currentTimeMillis()+"."+houzhui);
  91. noticeSupply.setPicture(fileUrl);
  92. }
  93. return toAjax(noticeSupplyService.insertNoticeSupply(noticeSupply));
  94. }
  95. /**
  96. * 修改【请填写功能名称】
  97. */
  98. @GetMapping("/edit/{id}")
  99. public String edit(@PathVariable("id") Long id, ModelMap mmap)
  100. {
  101. NoticeSupply noticeSupply = noticeSupplyService.selectNoticeSupplyById(id);
  102. mmap.put("noticeSupply", noticeSupply);
  103. return prefix + "/edit";
  104. }
  105. /**
  106. * 查看供应详情
  107. */
  108. @GetMapping("/details/{id}")
  109. public String details(@PathVariable("id") Long id, ModelMap mmap)
  110. {
  111. NoticeSupply noticeSupply = noticeSupplyService.selectNoticeSupplyById(id);
  112. mmap.put("noticeSupply", noticeSupply);
  113. return prefix + "/details";
  114. }
  115. /**
  116. * 查看供应详情
  117. */
  118. @GetMapping("/editstatus/{id}")
  119. public String editstatus(@PathVariable("id") Long id, ModelMap mmap)
  120. {
  121. NoticeSupply noticeSupply = noticeSupplyService.selectNoticeSupplyById(id);
  122. mmap.put("noticeSupply", noticeSupply);
  123. return prefix + "/editstatus";
  124. }
  125. /**
  126. * 修改保存【请填写功能名称】
  127. */
  128. @RequiresPermissions("notice:supply:edit")
  129. @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
  130. @PostMapping("/edit")
  131. @ResponseBody
  132. public AjaxResult editSave(NoticeSupply noticeSupply)
  133. {
  134. if(StringUtils.isNotEmpty(noticeSupply.getPicture())){
  135. //获取base64文件后缀
  136. String houzhui = noticeSupply.getPicture().split(";")[0].split("\\/")[1];
  137. //获取base64值
  138. String base64 = noticeSupply.getPicture().substring( noticeSupply.getPicture().indexOf(",") + 1);
  139. //base64转文件 并返回展示url
  140. String fileUrl = FileUploadUtils.base64ToFile(base64,FileUploadUtils.getDefaultBaseDir()+"/content",System.currentTimeMillis()+"."+houzhui);
  141. noticeSupply.setPicture(fileUrl);
  142. }
  143. return toAjax(noticeSupplyService.updateNoticeSupply(noticeSupply));
  144. }
  145. /**
  146. * 删除【请填写功能名称】
  147. */
  148. @RequiresPermissions("notice:supply:remove")
  149. @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
  150. @PostMapping( "/remove")
  151. @ResponseBody
  152. public AjaxResult remove(String ids)
  153. {
  154. return toAjax(noticeSupplyService.deleteNoticeSupplyByIds(ids));
  155. }
  156. }