package com.dsh.other.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.dsh.other.entity.Banner;
|
import com.dsh.other.entity.CreateHistoryDto;
|
import com.dsh.other.entity.GetHistoryDto;
|
import com.dsh.other.model.BannerVo;
|
import com.dsh.other.service.IBannerService;
|
import com.dsh.other.util.ResultUtil;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @author zhibing.pu
|
* @date 2023/7/11 17:48
|
*/
|
@RestController
|
@RequestMapping("")
|
public class BannerController {
|
|
@Autowired
|
private IBannerService bannerService;
|
|
|
|
|
@ResponseBody
|
@PostMapping("/base/banner/queryBannerList")
|
@ApiOperation(value = "获取banner数据", tags = {"APP-加入玩湃"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "位置(1=首页,2=首页底部,3=线上课得积分,4=看视频得奖励,5=常见问题)", name = "position", dataType = "int", required = true),
|
})
|
public ResultUtil<List<BannerVo>> queryBannerList(Integer position){
|
try {
|
List<Banner> list = bannerService.list(new QueryWrapper<Banner>().eq("position", position).eq("state", 1).orderByAsc("sort"));
|
List<BannerVo> list1 = new ArrayList<>();
|
for (Banner banner : list) {
|
BannerVo bannerVo = new BannerVo();
|
BeanUtils.copyProperties(banner, bannerVo);
|
list1.add(bannerVo);
|
}
|
return ResultUtil.success(list1);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/class/hisotory")
|
public void createHistory(@RequestBody CreateHistoryDto createHistoryDto){
|
createHistoryDto.setDate(new Date());
|
|
bannerService.createHistory(createHistoryDto);
|
|
|
}
|
|
@ResponseBody
|
@PostMapping("/class/gethisotory")
|
public List<GetHistoryDto> getHistory(@RequestBody Integer studentId){
|
|
return bannerService.gethistory(studentId);
|
|
|
}
|
}
|