2025-04-01 18:02:44 +08:00
|
|
|
package com.ruoyi.web.bst;
|
|
|
|
|
|
|
|
import com.ruoyi.bst.ad.domain.Ad;
|
|
|
|
import com.ruoyi.bst.ad.domain.AdQuery;
|
|
|
|
import com.ruoyi.bst.ad.domain.AdVO;
|
2025-04-21 18:19:00 +08:00
|
|
|
import com.ruoyi.bst.ad.domain.AdVerifyDTO;
|
2025-04-08 16:31:58 +08:00
|
|
|
import com.ruoyi.bst.ad.enums.AdBlong;
|
2025-04-22 11:50:16 +08:00
|
|
|
import com.ruoyi.bst.ad.enums.AdVerifyStatus;
|
2025-04-07 20:36:04 +08:00
|
|
|
import com.ruoyi.bst.ad.service.AdConverter;
|
2025-04-01 18:02:44 +08:00
|
|
|
import com.ruoyi.bst.ad.service.AdService;
|
2025-04-07 20:36:04 +08:00
|
|
|
import com.ruoyi.bst.ad.service.AdValidator;
|
2025-04-09 20:36:35 +08:00
|
|
|
import com.ruoyi.bst.area.service.AreaService;
|
2025-04-21 18:19:00 +08:00
|
|
|
import com.ruoyi.bst.fault.domain.Fault;
|
|
|
|
import com.ruoyi.bst.fault.domain.FaultVerifyDTO;
|
2025-04-01 18:02:44 +08:00
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
2025-04-22 11:50:16 +08:00
|
|
|
import com.ruoyi.common.core.validate.ValidGroup;
|
2025-04-01 18:02:44 +08:00
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
2025-04-07 20:36:04 +08:00
|
|
|
import com.ruoyi.common.enums.UserType;
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
import com.ruoyi.common.utils.ServiceUtil;
|
2025-04-01 18:02:44 +08:00
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
2025-04-07 20:36:04 +08:00
|
|
|
import com.ruoyi.system.user.service.UserService;
|
|
|
|
import com.ruoyi.system.user.service.UserValidator;
|
2025-04-21 18:19:00 +08:00
|
|
|
import io.swagger.annotations.ApiOperation;
|
2025-04-07 20:36:04 +08:00
|
|
|
import org.checkerframework.checker.units.qual.A;
|
2025-04-01 18:02:44 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
2025-04-21 18:19:00 +08:00
|
|
|
import org.springframework.validation.annotation.Validated;
|
2025-04-01 18:02:44 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 广告Controller
|
|
|
|
*
|
|
|
|
* @author ruoyi
|
|
|
|
* @date 2025-04-01
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/bst/ad")
|
|
|
|
public class AdController extends BaseController
|
|
|
|
{
|
|
|
|
@Autowired
|
|
|
|
private AdService adService;
|
2025-04-07 20:36:04 +08:00
|
|
|
@Autowired
|
|
|
|
private AdConverter adConverter;
|
|
|
|
@Autowired
|
|
|
|
private AdValidator adValidator;
|
2025-04-09 20:36:35 +08:00
|
|
|
@Autowired
|
|
|
|
private AreaService areaService;
|
2025-04-01 18:02:44 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询广告列表
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:ad:list')")
|
|
|
|
@GetMapping("/list")
|
|
|
|
public TableDataInfo list(AdQuery query)
|
|
|
|
{
|
|
|
|
startPage();
|
|
|
|
startOrderBy();
|
2025-04-15 09:13:38 +08:00
|
|
|
query.setScope(true);
|
2025-04-22 11:50:16 +08:00
|
|
|
query.setUserId(getUserId());
|
|
|
|
query.setDeleted(false);
|
2025-04-09 20:36:35 +08:00
|
|
|
return getDataTable(adService.selectAdList(query));
|
2025-04-01 18:02:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导出广告列表
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:ad:export')")
|
|
|
|
@Log(title = "广告", businessType = BusinessType.EXPORT)
|
|
|
|
@PostMapping("/export")
|
|
|
|
public void export(HttpServletResponse response, AdQuery query)
|
|
|
|
{
|
|
|
|
List<AdVO> list = adService.selectAdList(query);
|
|
|
|
ExcelUtil<AdVO> util = new ExcelUtil<AdVO>(AdVO.class);
|
|
|
|
util.exportExcel(response, list, "广告数据");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取广告详细信息
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:ad:query')")
|
|
|
|
@GetMapping(value = "/{adId}")
|
|
|
|
public AjaxResult getInfo(@PathVariable("adId") Long adId)
|
|
|
|
{
|
|
|
|
return success(adService.selectAdByAdId(adId));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增广告
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:ad:add')")
|
|
|
|
@Log(title = "广告", businessType = BusinessType.INSERT)
|
|
|
|
@PostMapping
|
2025-04-22 11:50:16 +08:00
|
|
|
public AjaxResult add(@Validated(ValidGroup.Create.class) @RequestBody Ad ad)
|
2025-04-01 18:02:44 +08:00
|
|
|
{
|
2025-04-22 11:50:16 +08:00
|
|
|
ad = adConverter.toPoByCreate(ad);
|
2025-04-01 18:02:44 +08:00
|
|
|
return toAjax(adService.insertAd(ad));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改广告
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:ad:edit')")
|
|
|
|
@Log(title = "广告", businessType = BusinessType.UPDATE)
|
|
|
|
@PutMapping
|
2025-04-22 11:50:16 +08:00
|
|
|
public AjaxResult edit(@Validated(ValidGroup.Update.class)@RequestBody Ad ad)
|
2025-04-01 18:02:44 +08:00
|
|
|
{
|
2025-04-07 20:36:04 +08:00
|
|
|
if (!adValidator.canEdit(ad.getAdId())){
|
|
|
|
return AjaxResult.error("您没有权限修改id为" + ad.getAdId() + "的广告信息");
|
|
|
|
}
|
2025-04-01 18:02:44 +08:00
|
|
|
return toAjax(adService.updateAd(ad));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除广告
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:ad:remove')")
|
|
|
|
@Log(title = "广告", businessType = BusinessType.DELETE)
|
|
|
|
@DeleteMapping("/{adIds}")
|
2025-04-07 20:36:04 +08:00
|
|
|
public AjaxResult remove(@PathVariable List<Long> adIds)
|
2025-04-01 18:02:44 +08:00
|
|
|
{
|
2025-04-07 20:36:04 +08:00
|
|
|
if (!adValidator.canDeleteAll(adIds)) {
|
|
|
|
return AjaxResult.error("您没有权限删除ID为" + adIds + "的广告信息");
|
|
|
|
}
|
2025-04-09 20:36:35 +08:00
|
|
|
return toAjax(adService.logicalDel(adIds));
|
2025-04-01 18:02:44 +08:00
|
|
|
}
|
2025-04-21 18:19:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 后台处理或者驳回添加广告申请
|
|
|
|
* @param dto
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:ad:edit')")
|
|
|
|
@Log(title = "广告", businessType = BusinessType.UPDATE)
|
|
|
|
@ApiOperation("后台处理或者驳回添加广告申请")
|
|
|
|
@PutMapping("/handle")
|
|
|
|
public AjaxResult handle(@RequestBody @Validated AdVerifyDTO dto) {
|
|
|
|
if (!isSysAdmin()){
|
|
|
|
return AjaxResult.error("您没有权限处理id为" + dto.getId() + "的广告添加申请");
|
|
|
|
}
|
|
|
|
return toAjax(adService.verify(dto));
|
|
|
|
}
|
|
|
|
|
2025-04-01 18:02:44 +08:00
|
|
|
}
|