VoteController.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package com.uas.ps.vote.controller;
  2. import com.uas.ps.core.page.PageParams;
  3. import com.uas.ps.vote.model.Vote;
  4. import com.uas.ps.vote.service.VoteService;
  5. import com.uas.ps.vote.support.ResultMap;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.web.bind.annotation.*;
  8. import java.io.UnsupportedEncodingException;
  9. import java.net.URLDecoder;
  10. /**
  11. * @Author: huj
  12. * @Date: Created in 14:14 2018/10/26.
  13. */
  14. @RestController
  15. @RequestMapping("/vote")
  16. public class VoteController {
  17. @Autowired
  18. VoteService voteService;
  19. /**
  20. * 获取单个企业
  21. * @param enUU
  22. * @return
  23. */
  24. @RequestMapping("/one")
  25. public ResultMap getEnterprise(Long enUU) {
  26. return voteService.getEnterprise(enUU);
  27. }
  28. /**
  29. * 获取企业列表
  30. * @param params
  31. * @param type
  32. * @param keyword
  33. * @return
  34. */
  35. @RequestMapping("/all")
  36. public ResultMap getEnterprises(PageParams pageParams, Vote.Type type, String keyword) {
  37. return voteService.getEnterprises(pageParams, type, keyword);
  38. }
  39. /**
  40. * 企业报名
  41. * @param enUU
  42. * @param type
  43. * @param userUU
  44. * @param enDes
  45. * @param enName
  46. * @return
  47. */
  48. @RequestMapping(value = "/apply", method = RequestMethod.POST)
  49. public ResultMap apply(Long enUU, Vote.Type type, Long userUU, String enDes, String enName, String userName, String pic)
  50. throws UnsupportedEncodingException {
  51. enDes = URLDecoder.decode(enDes, "UTF-8");
  52. enName = URLDecoder.decode(enName, "UTF-8");
  53. userName = URLDecoder.decode(userName, "UTF-8");
  54. pic = URLDecoder.decode(pic, "UTF-8");
  55. return voteService.apply(enUU, type, userUU, enDes, enName, userName, pic);
  56. }
  57. /**
  58. * 用户投票
  59. * @param userUU
  60. * @param type
  61. * @param enUU
  62. * @return
  63. */
  64. @RequestMapping(value = "/vote", method = RequestMethod.POST)
  65. public ResultMap vote(Long userUU,Long enUU, String userName) throws UnsupportedEncodingException {
  66. userName = URLDecoder.decode(userName, "UTF-8");
  67. return voteService.vote(userUU, enUU, userName);
  68. }
  69. /**
  70. * 更新主营产品
  71. * @param enUU
  72. * @param des
  73. * @return
  74. * @throws UnsupportedEncodingException
  75. */
  76. @RequestMapping(value = "/des", method = RequestMethod.POST)
  77. public ResultMap des(Long enUU, String des) throws UnsupportedEncodingException {
  78. des = URLDecoder.decode(des, "UTF-8");
  79. return voteService.des(enUU, des);
  80. }
  81. }