package cn.ubitech.ttc.controller; import cn.ubitech.ttc.entity.ResourceChoiceMore; import cn.ubitech.ttc.model.ResourceChoice.ResourceChoiceModel; import cn.ubitech.ttc.model.common.Constant; import cn.ubitech.ttc.model.common.ResultModel; import cn.ubitech.ttc.service.impl.resourceChoice.ResouceChoiceServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; /** * code is far away from bug with the animal protecting * ┏┓   ┏┓ * ┏┛┻━━━┛┻┓ * ┃       ┃ * ┃   ━   ┃ * ┃ ┳┛ ┗┳ ┃ * ┃       ┃ * ┃   ┻   ┃ * ┃       ┃ * ┗━┓   ┏━┛ *   ┃   ┃神兽保佑 *   ┃   ┃代码无BUG! *   ┃   ┗━━━┓ *   ┃       ┣┓ *   ┃       ┏┛ *   ┗┓┓┏━┳┓┏┛ *    ┃┫┫ ┃┫┫ *    ┗┻┛ ┗┻┛ * * @author chen.guodong * @version 5.2 * @Date: Create in 2018/12/03 * @Modifyed By: * @Description: */ @RestController @RequestMapping("/resource") @Api(description = "资源功能相关接口") public class ResourceChoiceController { @Autowired private ResouceChoiceServiceImpl resouceChoiceService; /** * 资源选择列表 * @param node * @param restype * @return */ @RequestMapping(value = "/choice/list/{node}/{restype}", method = RequestMethod.GET) @ApiOperation(value = "资源选择列表", notes = "资源选择列表接口") @ApiImplicitParams({ @ApiImplicitParam(name = "node", paramType = "path", dataType = "String", value = "当前登录节点"), @ApiImplicitParam(name = "restype", paramType = "path", dataType = "Integer", value = "资源库类型") }) public ResultModel getResourceChoiceList(@PathVariable String node, @PathVariable Integer restype) { ResultModel resultModel = new ResultModel(); try { List resourceChoiceList = resouceChoiceService.getResourceChoiceList(node, restype); resultModel.setData(resourceChoiceList); } catch (Exception e) { resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351); resultModel.setData(e.toString()); } return resultModel; } /** * 资源排序列表 * @param node * @param restype * @return */ @RequestMapping(value = "/sort/list/{node}/{restype}", method = RequestMethod.GET) @ApiOperation(value = "资源排序列表", notes = "资源排序列表接口") @ApiImplicitParams({ @ApiImplicitParam(name = "node", paramType = "path", dataType = "String", value = "当前登录节点"), @ApiImplicitParam(name = "restype", paramType = "path", dataType = "Integer", value = "资源库类型") }) public ResultModel getResourceSortList(@PathVariable String node, @PathVariable Integer restype) { ResultModel resultModel = new ResultModel(); try { List resourceSortList = resouceChoiceService.getResourceSortList(node, restype); resultModel.setData(resourceSortList); } catch (Exception e) { resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351); resultModel.setData(e.toString()); } return resultModel; } /** * 资源置顶功能 * @param resourceId * @param userId * @return */ @RequestMapping(value = "/top/{resourceId}/{userId}/{node}", method = RequestMethod.GET) @ApiOperation(value = "资源置顶功能", notes = "资源置顶功能") @ApiImplicitParams({ @ApiImplicitParam(name = "resourceId", paramType = "path", dataType = "long", value = "资源id"), @ApiImplicitParam(name = "userId", paramType = "path", dataType = "long", value = "当前用户id"), @ApiImplicitParam(name = "node", paramType = "path", dataType = "long", value = "当前节点") }) public ResultModel topResourceDetail(@PathVariable long resourceId, @PathVariable long userId, @PathVariable long node) { System.err.println("置顶update..."); ResultModel resultModel = new ResultModel(); try { boolean isTopResourceFlag = resouceChoiceService.topResourceDetail(resourceId, userId, node); resultModel.setData(isTopResourceFlag); } catch (Exception e) { resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351); resultModel.setData(e.toString()); } return resultModel; } /** * 取消资源置顶功能 * @param resourceId * @return */ @RequestMapping(value = "/top/cancle/{resourceId}/{userId}",method = RequestMethod.GET) @ApiOperation(value = "取消资源置顶功能", notes = "取消资源置顶功能") @ApiImplicitParams({ @ApiImplicitParam(name = "resourceId",paramType = "path",dataType = "long", value = "资源id"), @ApiImplicitParam(name = "userId",paramType = "path",dataType = "long", value = "用户id") }) public ResultModel topSearchCancle(@PathVariable long resourceId, @PathVariable long userId) { ResultModel resultModel = new ResultModel(); try { boolean cancelFlag = resouceChoiceService.topSearchCancle(resourceId, userId); resultModel.setData(cancelFlag); } catch (Exception e) {//异常 resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351); resultModel.setMessage(e.toString()); e.printStackTrace(); } return resultModel; } /** * 选择资源默认排序 * @param restype * @return */ @RequestMapping(value = "/default/sort/get/{restype}", method = RequestMethod.GET) @ApiOperation(value = "选择资源默认排序", notes = "选择资源默认排序") @ApiImplicitParams({ @ApiImplicitParam(name = "restype", paramType = "path", dataType = "String", value = "资源类型") }) public ResultModel getDefaultSort(@PathVariable String restype) { ResultModel resultModel = new ResultModel(); try { String sort = resouceChoiceService.getDefaultSort(restype); resultModel.setData(sort); } catch (Exception e) { resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351); resultModel.setData(e.toString()); } return resultModel; } /** * 智能排序或筛选功能 * @param userId * @param node * @param isSortFlag true:排序 false:筛选 * @return */ @RequestMapping(value = "/intelligence/list/{userId}/{node}/{isSortFlag}", method = RequestMethod.GET) @ApiOperation(value = "智能排序或筛选功能", notes = "智能排序或筛选功能") @ApiImplicitParams({ @ApiImplicitParam(name = "userId", paramType = "path", dataType = "long", value = "当前用户id"), @ApiImplicitParam(name = "node", paramType = "path", dataType = "long", value = "当前节点"), @ApiImplicitParam(name = "isSortFlag", paramType = "path", dataType = "Boolean", value = "排序筛选标志") }) public ResultModel intelligenceSortOrChoice(@PathVariable long userId, @PathVariable long node, @PathVariable boolean isSortFlag) { ResultModel resultModel = new ResultModel(); try { String sort = resouceChoiceService.intelligenceSortOrChoice(userId, node, isSortFlag); resultModel.setData(sort); } catch (Exception e) { resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351); resultModel.setData(e.toString()); } return resultModel; } @GetMapping(value = "/choice/more/list/{nodeId}/{restype}") @ApiOperation(value = "更多资源选择列表", notes = "更多资源选择列表") @ApiImplicitParams({ @ApiImplicitParam(name = "nodeId", paramType = "path", dataType = "String", value = "节点id"), @ApiImplicitParam(name = "restype", paramType = "path", dataType = "Integer", value = "资源库类型") }) public ResultModel moreChoice(@PathVariable String nodeId, @PathVariable Integer restype) { ResultModel resultModel = new ResultModel(); try { resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3350); resultModel.setData(resouceChoiceService.getResourceChoiceMoreList(nodeId, restype)); } catch (Exception e) { resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351); resultModel.setData(e.toString()); } return resultModel; } @GetMapping(value = "/choice/foster/list/{nodeId}/{restype}") @ApiOperation(value = "培育库筛选条件列表") @ApiImplicitParams({ @ApiImplicitParam(name = "nodeId", paramType = "path", dataType = "String", value = "节点id"), @ApiImplicitParam(name = "restype", paramType = "path", dataType = "Integer", value = "培育库标识") }) public ResultModel choiceFosterList(@PathVariable String nodeId, @PathVariable Integer restype) { ResultModel resultModel = new ResultModel(); try { resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3350); resultModel.setData(resouceChoiceService.choiceFosterList(nodeId, restype)); } catch (Exception e) { resultModel.setCode(Constant.INTERFACE_STATUS_CODE_3351); resultModel.setData(e.toString()); } return resultModel; } }