package com.uas.ps.vote.controller; import com.uas.ps.core.page.PageParams; import com.uas.ps.vote.model.Vote; import com.uas.ps.vote.service.VoteService; import com.uas.ps.vote.support.ResultMap; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; /** * @Author: huj * @Date: Created in 14:14 2018/10/26. */ @RestController @RequestMapping("/vote") public class VoteController { @Autowired VoteService voteService; /** * 获取单个企业 * @param enUU * @return */ @RequestMapping("/one") public ResultMap getEnterprise(Long enUU) { return voteService.getEnterprise(enUU); } /** * 获取企业列表 * @param params * @param type * @param keyword * @return */ @RequestMapping("/all") public ResultMap getEnterprises(PageParams pageParams, Vote.Type type, String keyword) { return voteService.getEnterprises(pageParams, type, keyword); } /** * 企业报名 * @param enUU * @param type * @param userUU * @param enDes * @param enName * @return */ @RequestMapping(value = "/apply", method = RequestMethod.POST) public ResultMap apply(Long enUU, Vote.Type type, Long userUU, String enDes, String enName, String userName, String pic) throws UnsupportedEncodingException { enDes = URLDecoder.decode(enDes, "UTF-8"); enName = URLDecoder.decode(enName, "UTF-8"); userName = URLDecoder.decode(userName, "UTF-8"); pic = URLDecoder.decode(pic, "UTF-8"); return voteService.apply(enUU, type, userUU, enDes, enName, userName, pic); } /** * 用户投票 * @param userUU * @param type * @param enUU * @return */ @RequestMapping(value = "/vote", method = RequestMethod.POST) public ResultMap vote(Long userUU,Long enUU, String userName) throws UnsupportedEncodingException { userName = URLDecoder.decode(userName, "UTF-8"); return voteService.vote(userUU, enUU, userName); } /** * 更新主营产品 * @param enUU * @param des * @return * @throws UnsupportedEncodingException */ @RequestMapping(value = "/des", method = RequestMethod.POST) public ResultMap des(Long enUU, String des) throws UnsupportedEncodingException { des = URLDecoder.decode(des, "UTF-8"); return voteService.des(enUU, des); } }