//package com.yizhi.application.vote.controller;
//
//
//import java.util.Date;
//import java.util.List;
//
//import com.yizhi.application.domain.Vote;
//import com.yizhi.application.feign.PointRedisFeignClients;
//import com.yizhi.application.feign.VoteClient;
//import com.yizhi.application.point.constant.MQqueuesEnum;
//import com.yizhi.application.point.constant.PointEventEnum;
//import com.yizhi.application.util.constant.ReturnCode;
//import com.yizhi.application.vo.PointParamVO;
//import com.yizhi.application.vo.VoteRemindVO;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.amqp.core.AmqpTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import com.yizhi.application.context.ContextHolder;
//import com.yizhi.application.context.RequestContext;
//import com.yizhi.application.feign.StudentVoteClient;
//import com.yizhi.application.util.domain.Response;
//import com.yizhi.application.vo.PageStudentVoteVO;
//
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//
///**
// * <p>
// * 学员端
// * </p>
// *
// * @author lilingye
// * @since 2018-3-20
// */
//@RestController
//@Api(tags = "投票-学员端接口")
//@RequestMapping("/api")
//public class StudentVoteController {
//	private static final Logger LOGGER = LoggerFactory.getLogger(StudentVoteController.class);
//
//	@Autowired
//	private StudentVoteClient stuClient;
//	@Autowired
//    private VoteClient voteClient;
//	@Autowired
//    private PointRedisFeignClients pointRedisFeignClients;
//	@Autowired
//    private AmqpTemplate amqpTemplate;
//
//	/**
//	 * 学员端-我的投票列表
//	 */
//	@ApiOperation(value = "我的投票列表", notes = "我的投票列表", response =PageStudentVoteVO.class )
//	@RequestMapping(value="/account/list",method = RequestMethod.GET)
//	public Response<PageStudentVoteVO> listVote(
//			@ApiParam(name = "type", value = "状态，0 进行中，1已完成") @RequestParam(name="type",defaultValue="3") Integer type,
//			@ApiParam(name = "voteName", value = "投票名称", required = false) @RequestParam(name="voteName",defaultValue="") String voteName,
//            @ApiParam(name = "pageNo", value = "要跳转的页数", required = false) @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
//            @ApiParam(name = "pageSize", value = "每页条数，默认：10", required = false) @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize
//	){
//
//
//		PageStudentVoteVO pageStudentVoteVO = stuClient.listVote( type, voteName, pageNo, pageSize);
//		return Response.ok(pageStudentVoteVO);
//	}
//
//    /**
//     * 投票动作
//     * @author lilingye
//     * @date 2018-6-27
//     * @param optionIds 投票选项id list
//     * @return
//     */
//    @PostMapping(value="/vote")
//    public Response<String> voteToOption(@ApiParam(name = "optionIds", value = "投票选项的选项id[12,13]") @RequestBody List<Long> optionIds ){
//
//	    RequestContext requestContext = ContextHolder.get();
//	    Vote vote = voteClient.voteToOption(optionIds);
//	    if (vote!=null){
//
//            PointParamVO pointParamVO = new PointParamVO();
//            // 事件名称
//            pointParamVO.setEventName(PointEventEnum.POINTVOTE.getKey());
//            // 事件类型
//            pointParamVO.setActivityType("考试通过积分发放");
//            // 学习活动来源
//            pointParamVO.setActivitySource("考试");
//            // 学习活动名称
//            pointParamVO.setActivityName(vote.getVoteName());
//            // 发放条件
//            pointParamVO.setReleaseCondition("范围发放");
//            pointParamVO.setReleaseRules("按照范围取积分");
//            // 积分创建时间
//            pointParamVO.setCreatePointTime(new Date());
//            // 积分来源ID，（业务ID主键）
//            pointParamVO.setSourceId(vote.getId());
//            // 积分数量，  正数 加积分，  负数减积分
//            pointParamVO.setOperatingPoint(vote.getPoint());
//            // 学员ID
//            pointParamVO.setAccountId(requestContext.getAccountId());
//            // 学员名称
//            pointParamVO.setAccountName(requestContext.getAccountName());
//            // 企业ID
//            pointParamVO.setCompanyId(requestContext.getCompanyId());
//            // 站点ID
//            pointParamVO.setSiteId(requestContext.getSiteId());
//            // 组织ID
//            pointParamVO.setOrgId(requestContext.getOrgId());
//            // 调用积分接口添加积分
//            String sitePointId = pointRedisFeignClients.addPointRedis(pointParamVO);
//            String sitePointId1 = pointRedisFeignClients.addPointRedis(pointParamVO);
//            // 发送积分获取消息
//            amqpTemplate.convertAndSend(MQqueuesEnum.VOTE.getKey(),sitePointId);
//            amqpTemplate.convertAndSend(MQqueuesEnum.EXPERIENCEVOTE.getKey(),sitePointId1);
//            return Response.ok(ReturnCode.SUCCESS);
//        }else {
//	        return Response.fail(ReturnCode.SERVICE_UNAVAILABLE.getCode(),ReturnCode.SERVICE_UNAVAILABLE.getMsg());
//        }
//    }
//
//}
//
