|
@@ -16,10 +16,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
@@ -37,7 +34,7 @@ import static com.yc.ship.framework.common.pojo.CommonResult.success;
|
|
|
*/
|
|
*/
|
|
|
@Tag(name = "用户 APP - 广告")
|
|
@Tag(name = "用户 APP - 广告")
|
|
|
@RestController
|
|
@RestController
|
|
|
-@RequestMapping("/app/applet/advert")
|
|
|
|
|
|
|
+@RequestMapping("/applet/advert")
|
|
|
@Validated
|
|
@Validated
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class AppAdvertController {
|
|
public class AppAdvertController {
|
|
@@ -48,56 +45,15 @@ public class AppAdvertController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private AdvertService advertService;
|
|
private AdvertService advertService;
|
|
|
|
|
|
|
|
- @Resource
|
|
|
|
|
- private AdvertLogService advertLogService;
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/adsenseList")
|
|
|
|
|
- public CommonResult<List<AppAdsenseRespVO>> catalogueList(@RequestBody @Valid AppAdvertReqVO reqVO) {
|
|
|
|
|
- List<AdsenseDO> adsenseList = adsenseService.getAdsenseList(reqVO);
|
|
|
|
|
- List<AppAdsenseRespVO> respVOS = BeanUtils.toBean(adsenseList, AppAdsenseRespVO.class);
|
|
|
|
|
|
|
+ // 根据广告位编码获取广告列表
|
|
|
|
|
+ @GetMapping("/advertListByCode")
|
|
|
|
|
+ @Operation(summary = "根据广告位编码获取广告列表")
|
|
|
|
|
+ public CommonResult<List<AppAdvertRespVO>> advertListByCode(@RequestParam("adsenseCode") String adsenseCode) {
|
|
|
|
|
+ AdsenseDO adsenseDO = adsenseService.getAdsenseByCode(adsenseCode);
|
|
|
|
|
+ Long adsenseId = adsenseDO.getId();
|
|
|
|
|
+ List<AdvertDO> advertList = advertService.getCanUseAdvertList(adsenseId);
|
|
|
|
|
+ List<AppAdvertRespVO> respVOS = BeanUtils.toBean(advertList, AppAdvertRespVO.class);
|
|
|
return success(respVOS);
|
|
return success(respVOS);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @PostMapping("/adsense")
|
|
|
|
|
- public CommonResult<AppAdsenseRespVO> catalogue(@RequestBody @Valid AppAdvertReqVO reqVO) {
|
|
|
|
|
- AdsenseDO adsenseDO = adsenseService.getAdsenseByCode(reqVO.getAdsenseCode());
|
|
|
|
|
- AppAdsenseRespVO respVO = BeanUtils.toBean(adsenseDO, AppAdsenseRespVO.class);
|
|
|
|
|
- return success(respVO);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/advertList")
|
|
|
|
|
- public CommonResult<List<AppAdvertRespVO>> contentList(@RequestBody @Valid AppAdvertReqVO reqVO) {
|
|
|
|
|
- List<AppAdvertRespVO> respVOS = new ArrayList<>(3);
|
|
|
|
|
- if (reqVO.getAdsenseId() == null) {
|
|
|
|
|
- AdsenseDO adsenseDO = adsenseService.getAdsenseByCode(reqVO.getAdsenseCode());
|
|
|
|
|
- if (adsenseDO != null) {
|
|
|
|
|
- reqVO.setAdsenseId(adsenseDO.getId());
|
|
|
|
|
- } else {
|
|
|
|
|
- return success(respVOS);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- List<AdvertDO> advertList = advertService.getAdvertList(reqVO.getAdsenseId());
|
|
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
- advertList = advertList.stream()
|
|
|
|
|
- .filter(advert -> advert.getIsDisplay() == 1 && (advert.getValidType() == 0 || (advert.getValidType() == 1 && (now.isAfter(advert.getStaDate()) && now.isBefore(advert.getEndDate())))))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
- respVOS = BeanUtils.toBean(advertList, AppAdvertRespVO.class);
|
|
|
|
|
- return success(respVOS);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/advert")
|
|
|
|
|
- public CommonResult<AppAdvertRespVO> content(@RequestBody @Valid AppAdvertReqVO reqVO) {
|
|
|
|
|
- AdvertDO advertDO = advertService.getAdvert(reqVO.getAdvertId());
|
|
|
|
|
- AppAdvertRespVO respVO = BeanUtils.toBean(advertDO, AppAdvertRespVO.class);
|
|
|
|
|
- return success(respVO);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/recordAdvertLog")
|
|
|
|
|
- @Operation(summary = "记录广告操作日志")
|
|
|
|
|
- public CommonResult<Long> content(@RequestBody @Valid AppAdvertLogReqVO reqVO) {
|
|
|
|
|
- AdvertLogSaveReqVO createReqVO = BeanUtils.toBean(reqVO, AdvertLogSaveReqVO.class);
|
|
|
|
|
- Long logId = advertLogService.createAdvertLog(createReqVO);
|
|
|
|
|
- return success(logId);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|