ResourceChoiceController.java 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. package cn.ubitech.ttc.controller;
  2. import cn.ubitech.ttc.entity.ResourceChoiceMore;
  3. import cn.ubitech.ttc.model.ResourceChoice.ResourceChoiceModel;
  4. import cn.ubitech.ttc.model.common.Constant;
  5. import cn.ubitech.ttc.model.common.ResultModel;
  6. import cn.ubitech.ttc.service.impl.resourceChoice.ResouceChoiceServiceImpl;
  7. import io.swagger.annotations.Api;
  8. import io.swagger.annotations.ApiImplicitParam;
  9. import io.swagger.annotations.ApiImplicitParams;
  10. import io.swagger.annotations.ApiOperation;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.*;
  13. import java.util.List;
  14. /**
  15. * code is far away from bug with the animal protecting
  16. * ┏┓   ┏┓
  17. * ┏┛┻━━━┛┻┓
  18. * ┃       ┃
  19. * ┃   ━   ┃
  20. * ┃ ┳┛ ┗┳ ┃
  21. * ┃       ┃
  22. * ┃   ┻   ┃
  23. * ┃       ┃
  24. * ┗━┓   ┏━┛
  25. *   ┃   ┃神兽保佑
  26. *   ┃   ┃代码无BUG!
  27. *   ┃   ┗━━━┓
  28. *   ┃       ┣┓
  29. *   ┃       ┏┛
  30. *   ┗┓┓┏━┳┓┏┛
  31. *    ┃┫┫ ┃┫┫
  32. *    ┗┻┛ ┗┻┛
  33. *
  34. * @author chen.guodong
  35. * @version 5.2
  36. * @Date: Create in 2018/12/03
  37. * @Modifyed By:
  38. * @Description:
  39. */
  40. @RestController
  41. @RequestMapping("/resource")
  42. @Api(description = "资源功能相关接口")
  43. public class ResourceChoiceController {
  44. @Autowired
  45. private ResouceChoiceServiceImpl resouceChoiceService;
  46. /**
  47. * 资源选择列表
  48. * @param node
  49. * @param restype
  50. * @return
  51. */
  52. @RequestMapping(value = "/choice/list/{node}/{restype}", method = RequestMethod.GET)
  53. @ApiOperation(value = "资源选择列表", notes = "资源选择列表接口")
  54. @ApiImplicitParams({
  55. @ApiImplicitParam(name = "node", paramType = "path", dataType = "String", value = "当前登录节点"),
  56. @ApiImplicitParam(name = "restype", paramType = "path", dataType = "Integer", value = "资源库类型")
  57. })
  58. public ResultModel getResourceChoiceList(@PathVariable String node, @PathVariable Integer restype) {
  59. ResultModel resultModel = new ResultModel();
  60. try {
  61. List<ResourceChoiceModel> resourceChoiceList = resouceChoiceService.getResourceChoiceList(node, restype);
  62. resultModel.setData(resourceChoiceList);
  63. } catch (Exception e) {
  64. resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351);
  65. resultModel.setData(e.toString());
  66. }
  67. return resultModel;
  68. }
  69. /**
  70. * 资源排序列表
  71. * @param node
  72. * @param restype
  73. * @return
  74. */
  75. @RequestMapping(value = "/sort/list/{node}/{restype}", method = RequestMethod.GET)
  76. @ApiOperation(value = "资源排序列表", notes = "资源排序列表接口")
  77. @ApiImplicitParams({
  78. @ApiImplicitParam(name = "node", paramType = "path", dataType = "String", value = "当前登录节点"),
  79. @ApiImplicitParam(name = "restype", paramType = "path", dataType = "Integer", value = "资源库类型")
  80. })
  81. public ResultModel getResourceSortList(@PathVariable String node, @PathVariable Integer restype) {
  82. ResultModel resultModel = new ResultModel();
  83. try {
  84. List<ResourceChoiceModel> resourceSortList = resouceChoiceService.getResourceSortList(node, restype);
  85. resultModel.setData(resourceSortList);
  86. } catch (Exception e) {
  87. resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351);
  88. resultModel.setData(e.toString());
  89. }
  90. return resultModel;
  91. }
  92. /**
  93. * 资源置顶功能
  94. * @param resourceId
  95. * @param userId
  96. * @return
  97. */
  98. @RequestMapping(value = "/top/{resourceId}/{userId}/{node}", method = RequestMethod.GET)
  99. @ApiOperation(value = "资源置顶功能", notes = "资源置顶功能")
  100. @ApiImplicitParams({
  101. @ApiImplicitParam(name = "resourceId", paramType = "path", dataType = "long", value = "资源id"),
  102. @ApiImplicitParam(name = "userId", paramType = "path", dataType = "long", value = "当前用户id"),
  103. @ApiImplicitParam(name = "node", paramType = "path", dataType = "long", value = "当前节点")
  104. })
  105. public ResultModel topResourceDetail(@PathVariable long resourceId, @PathVariable long userId, @PathVariable long node) {
  106. System.err.println("置顶update...");
  107. ResultModel resultModel = new ResultModel();
  108. try {
  109. boolean isTopResourceFlag = resouceChoiceService.topResourceDetail(resourceId, userId, node);
  110. resultModel.setData(isTopResourceFlag);
  111. } catch (Exception e) {
  112. resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351);
  113. resultModel.setData(e.toString());
  114. }
  115. return resultModel;
  116. }
  117. /**
  118. * 取消资源置顶功能
  119. * @param resourceId
  120. * @return
  121. */
  122. @RequestMapping(value = "/top/cancle/{resourceId}/{userId}",method = RequestMethod.GET)
  123. @ApiOperation(value = "取消资源置顶功能", notes = "取消资源置顶功能")
  124. @ApiImplicitParams({
  125. @ApiImplicitParam(name = "resourceId",paramType = "path",dataType = "long", value = "资源id"),
  126. @ApiImplicitParam(name = "userId",paramType = "path",dataType = "long", value = "用户id")
  127. })
  128. public ResultModel topSearchCancle(@PathVariable long resourceId, @PathVariable long userId) {
  129. ResultModel resultModel = new ResultModel();
  130. try {
  131. boolean cancelFlag = resouceChoiceService.topSearchCancle(resourceId, userId);
  132. resultModel.setData(cancelFlag);
  133. } catch (Exception e) {//异常
  134. resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351);
  135. resultModel.setMessage(e.toString());
  136. e.printStackTrace();
  137. }
  138. return resultModel;
  139. }
  140. /**
  141. * 选择资源默认排序
  142. * @param restype
  143. * @return
  144. */
  145. @RequestMapping(value = "/default/sort/get/{restype}", method = RequestMethod.GET)
  146. @ApiOperation(value = "选择资源默认排序", notes = "选择资源默认排序")
  147. @ApiImplicitParams({
  148. @ApiImplicitParam(name = "restype", paramType = "path", dataType = "String", value = "资源类型")
  149. })
  150. public ResultModel getDefaultSort(@PathVariable String restype) {
  151. ResultModel resultModel = new ResultModel();
  152. try {
  153. String sort = resouceChoiceService.getDefaultSort(restype);
  154. resultModel.setData(sort);
  155. } catch (Exception e) {
  156. resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351);
  157. resultModel.setData(e.toString());
  158. }
  159. return resultModel;
  160. }
  161. /**
  162. * 智能排序或筛选功能
  163. * @param userId
  164. * @param node
  165. * @param isSortFlag true:排序 false:筛选
  166. * @return
  167. */
  168. @RequestMapping(value = "/intelligence/list/{userId}/{node}/{isSortFlag}", method = RequestMethod.GET)
  169. @ApiOperation(value = "智能排序或筛选功能", notes = "智能排序或筛选功能")
  170. @ApiImplicitParams({
  171. @ApiImplicitParam(name = "userId", paramType = "path", dataType = "long", value = "当前用户id"),
  172. @ApiImplicitParam(name = "node", paramType = "path", dataType = "long", value = "当前节点"),
  173. @ApiImplicitParam(name = "isSortFlag", paramType = "path", dataType = "Boolean", value = "排序筛选标志")
  174. })
  175. public ResultModel intelligenceSortOrChoice(@PathVariable long userId, @PathVariable long node, @PathVariable boolean isSortFlag) {
  176. ResultModel resultModel = new ResultModel();
  177. try {
  178. String sort = resouceChoiceService.intelligenceSortOrChoice(userId, node, isSortFlag);
  179. resultModel.setData(sort);
  180. } catch (Exception e) {
  181. resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351);
  182. resultModel.setData(e.toString());
  183. }
  184. return resultModel;
  185. }
  186. @GetMapping(value = "/choice/more/list/{nodeId}/{restype}")
  187. @ApiOperation(value = "更多资源选择列表", notes = "更多资源选择列表")
  188. @ApiImplicitParams({
  189. @ApiImplicitParam(name = "nodeId", paramType = "path", dataType = "String", value = "节点id"),
  190. @ApiImplicitParam(name = "restype", paramType = "path", dataType = "Integer", value = "资源库类型")
  191. })
  192. public ResultModel moreChoice(@PathVariable String nodeId, @PathVariable Integer restype) {
  193. ResultModel resultModel = new ResultModel();
  194. try {
  195. resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3350);
  196. resultModel.setData(resouceChoiceService.getResourceChoiceMoreList(nodeId, restype));
  197. } catch (Exception e) {
  198. resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351);
  199. resultModel.setData(e.toString());
  200. }
  201. return resultModel;
  202. }
  203. @GetMapping(value = "/choice/foster/list/{nodeId}/{restype}")
  204. @ApiOperation(value = "培育库筛选条件列表")
  205. @ApiImplicitParams({
  206. @ApiImplicitParam(name = "nodeId", paramType = "path", dataType = "String", value = "节点id"),
  207. @ApiImplicitParam(name = "restype", paramType = "path", dataType = "Integer", value = "培育库标识")
  208. })
  209. public ResultModel choiceFosterList(@PathVariable String nodeId, @PathVariable Integer restype) {
  210. ResultModel resultModel = new ResultModel();
  211. try {
  212. resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3350);
  213. resultModel.setData(resouceChoiceService.choiceFosterList(nodeId, restype));
  214. } catch (Exception e) {
  215. resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351);
  216. resultModel.setData(e.toString());
  217. }
  218. return resultModel;
  219. }
  220. }