| | |
| | | package com.dsh.competition.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.competition.entity.Competition; |
| | | import com.dsh.competition.entity.UserCompetition; |
| | | import com.dsh.competition.feignclient.model.PurchaseRecordVo; |
| | | import com.dsh.competition.model.CompetitionInfo; |
| | | import com.dsh.competition.model.CompetitionListVo; |
| | | import com.dsh.competition.service.CompetitionService; |
| | | import com.dsh.competition.service.UserCompetitionService; |
| | | import com.dsh.competition.util.ResultUtil; |
| | | import com.dsh.competition.util.TokenUtil; |
| | | 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 org.springframework.web.bind.annotation.RestController; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2023-06-26 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/competition") |
| | | @RequestMapping("") |
| | | public class CompetitionController { |
| | | |
| | | |
| | | @Autowired |
| | | private CompetitionService cttService; |
| | | |
| | | @Autowired |
| | | private UserCompetitionService ucttService; |
| | | |
| | | private final SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm"); |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | |
| | | |
| | | |
| | | @PostMapping("/base/competition/getCompetitionsDetails") |
| | | public List<PurchaseRecordVo> getStuSourseList(@RequestParam("startTime") Date startTime, @RequestParam("endTime") Date endTime, @RequestParam("appUserId") Integer appUserId){ |
| | | |
| | | List<PurchaseRecordVo> recordVos = new ArrayList<>(); |
| | | |
| | | List<Competition> list = cttService.list(new QueryWrapper<Competition>() |
| | | .eq("payType",3 ) |
| | | .eq("auditStatus",2)); |
| | | List<Integer> comIds = list.stream().map(Competition::getId).collect(Collectors.toList()); |
| | | List<UserCompetition> userCompetitions = ucttService.queryUsersCompetetions(startTime,endTime,appUserId,comIds); |
| | | if (userCompetitions.size() > 0){ |
| | | userCompetitions.forEach(coms ->{ |
| | | PurchaseRecordVo recordVo = new PurchaseRecordVo(); |
| | | recordVo.setPurchaseType("报名赛事"); |
| | | recordVo.setPurchaseTime(dateFormat.format(coms.getInsertTime())); |
| | | Competition competition = cttService.getById(coms.getCompetitionId()); |
| | | recordVo.setPurchaseAmount("-"+competition.getPrice()); |
| | | recordVos.add(recordVo); |
| | | }); |
| | | } |
| | | return recordVos; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/competition/queryCompetitionList") |
| | | @ApiOperation(value = "获取赛事列表", tags = {"APP-赛事活动列表"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "城市code", name = "cityCode", dataType = "string", required = false), |
| | | @ApiImplicitParam(value = "搜索内容", name = "content", dataType = "string", required = false), |
| | | @ApiImplicitParam(value = "报名条件(1=全部用户,2=仅限年度会员参与,3=仅限学员参与)", name = "registerCondition", dataType = "int", required = false), |
| | | @ApiImplicitParam(value = "排序(1=正序,2=倒序)", name = "heat", dataType = "int", required = false), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<CompetitionListVo>> queryCompetitionList(String cityCode, String content, Integer registerCondition, Integer heat){ |
| | | try { |
| | | List<CompetitionListVo> competitionListVos = cttService.queryCompetitionList(cityCode, content, registerCondition, heat); |
| | | return ResultUtil.success(competitionListVos); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public ResultUtil<CompetitionInfo> queryCompetitionInfo(Integer id){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return null; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | } |
| | | |