ZjxlPartnerController.java 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package cn.stylefeng.guns.zjxl.cnotroller;
  2. import cn.stylefeng.guns.zjxl.model.ZjxlPartner;
  3. import cn.stylefeng.guns.zjxl.service.ZjxlPartnerService;
  4. import cn.stylefeng.guns.zjxlUtil.BaseController;
  5. import cn.stylefeng.guns.zjxlUtil.PageUtil;
  6. import io.swagger.annotations.Api;
  7. import io.swagger.annotations.ApiOperation;
  8. import io.swagger.annotations.ApiParam;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RequestMethod;
  12. import org.springframework.web.bind.annotation.RequestParam;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import java.util.List;
  15. /***
  16. * @ClassName: ZjxlPartnerController
  17. * @Description: 公司官网-合作伙伴
  18. * @Auther: shi kejing
  19. * @Date: 2020/11/3 14:56
  20. */
  21. @RestController
  22. @Api(description = "公司官网-合作伙伴")
  23. @RequestMapping(value = "/zjxl/partner")
  24. public class ZjxlPartnerController extends BaseController {
  25. @Autowired
  26. private ZjxlPartnerService partnerService;
  27. @RequestMapping(value = "/findPartenrById", method = RequestMethod.GET)
  28. @ApiOperation("查询合作伙伴")
  29. public String findPartenrById(
  30. @ApiParam(name = "id", value = "partnerId", required = false) @RequestParam(value = "id", required = false)String id,
  31. @ApiParam(name = "name", value = "partnername", required = false) @RequestParam(value = "name", required = false)String name,
  32. @ApiParam(name = "pageNo", value = "第几页", defaultValue = "1") @RequestParam(value = "pageNo", required = false) Integer pageNo,
  33. @ApiParam(name = "pageSize", value = "分页大小", defaultValue = "10") @RequestParam(value = "pageSize", required = false) Integer pageSize){
  34. try {
  35. List<ZjxlPartner> partnerList = partnerService.findPartenrById(id,name,pageNo-1,pageSize);
  36. return write(200,"查询成功", "data", PageUtil.getPage(partnerList,pageNo,pageSize,partnerService.allCount()));
  37. }catch (Exception e){
  38. e.printStackTrace();
  39. return write(-1,"查询失败");
  40. }
  41. }
  42. @RequestMapping(value = "/addPartenr", method = RequestMethod.POST)
  43. @ApiOperation(value = "添加合作伙伴")
  44. public String addPartenr(@ApiParam(name = "partnerName", value = "合作伙伴名称", required = false) @RequestParam(value = "partnerName", required = false)String partnerName,
  45. @ApiParam(name = "partnerImg", value = "合作伙伴图片", required = false) @RequestParam(value = "partnerImg", required = false)String partnerImg,
  46. @ApiParam(name = "partnerSort", value = "排序", required = false) @RequestParam(value = "partnerSort", required = false)Integer partnerSort,
  47. @ApiParam(name = "partnerIsLine", value = "是否上线", required = false, defaultValue = "0") @RequestParam(value = "partnerIsLine", required = false)Integer partnerIsLine){
  48. try {
  49. ZjxlPartner partner = new ZjxlPartner();
  50. partner.setPartnerName(partnerName);
  51. partner.setPartnerImg(partnerImg);
  52. partner.setPartnerSort(partnerSort);
  53. partner.setPartnerIsLine(partnerIsLine);
  54. return write(200,"添加成功","data",partnerService.addPartenr(partner));
  55. }catch (Exception e){
  56. e.printStackTrace();
  57. return write(-1,"添加失败");
  58. }
  59. }
  60. @RequestMapping(value = "/updatePartner", method = RequestMethod.POST)
  61. @ApiOperation(value = "合作伙伴修改上线")
  62. public String updatePartner(String id, Integer isLine){
  63. try {
  64. return write(200,"修改上线成功","data",partnerService.updatePartner(id,isLine));
  65. }catch (Exception e){
  66. e.printStackTrace();
  67. return write(-1,"修改上线失败");
  68. }
  69. }
  70. @RequestMapping(value = "/deletePartner", method = RequestMethod.POST)
  71. @ApiOperation(value = "删除合作伙伴")
  72. public String deletePartner(String id){
  73. try {
  74. return write(200,"删除成功","data",partnerService.deletePartner(id));
  75. }catch (Exception e){
  76. e.printStackTrace();
  77. return write(-1,"删除失败");
  78. }
  79. }
  80. }