| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.dto.BannerDto; |
| | | import com.sandu.ximon.admin.param.BannerParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.service.BannerService; |
| | | import com.sandu.ximon.admin.service.ClientService; |
| | | import com.sandu.ximon.dao.domain.Banner; |
| | | import com.sandu.ximon.dao.domain.Client; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | public class BannerController { |
| | | |
| | | private final BannerService contentBannerService; |
| | | private final ClientService clientService; |
| | | |
| | | @PostMapping("/addbanner") |
| | | public ResponseVO<Object> addBanner(@Validated @RequestBody BannerParam bannerParam) { |
| | | boolean result = contentBannerService.addBanner(bannerParam); |
| | | Client client = clientService.getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getId, bannerParam.getBinding_author())); |
| | | |
| | | |
| | | boolean result = contentBannerService.addBanner(bannerParam, client); |
| | | if (result) { |
| | | return ResponseUtil.success("添加成功"); |
| | | } else { |
| | |
| | | |
| | | @PostMapping("/{bannerId}") |
| | | public ResponseVO<Object> updateBanner(@PathVariable Long bannerId, @Validated @RequestBody BannerParam bannerParam) { |
| | | boolean result = contentBannerService.updateBanner(bannerId,bannerParam); |
| | | boolean result = contentBannerService.updateBanner(bannerId, bannerParam); |
| | | if (result) { |
| | | return ResponseUtil.success("更新成功"); |
| | | } else { |
| | |
| | | |
| | | @GetMapping |
| | | public ResponseVO<Object> listMainBanner() { |
| | | List<Banner> list = contentBannerService.listBanner(); |
| | | return ResponseUtil.success(list); |
| | | if (SecurityUtils.getClientId() != null) { |
| | | List<Banner> list = contentBannerService.listBanner(); |
| | | return ResponseUtil.success(list); |
| | | } else { |
| | | return ResponseUtil.success(contentBannerService.list()); |
| | | } |
| | | |
| | | } |
| | | |
| | | @PostMapping("/delete/{bannerId}") |