广告模块修改

This commit is contained in:
SjS 2025-04-14 17:02:34 +08:00
parent 53a27fae8a
commit 1d9870ac6f
5 changed files with 22 additions and 18 deletions

View File

@ -78,4 +78,6 @@ public interface AdMapper
public int logicalDel(@Param("array") List<Long> adIds);
int countByAreaId(@Param("areaId") Long areaId, @Param("adId") Long adId);
List<AdVO> selectAdByAreaId(@Param("areaId") Long areaId);
}

View File

@ -93,6 +93,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND deleted = 0
</select>
<select id="selectAdByAreaId" resultType="com.ruoyi.bst.ad.domain.AdVO">
<include refid="selectAdVo"/>
<where>
bad.area_id = #{areaId}
</where>
</select>
<insert id="insertAd" parameterType="Ad" useGeneratedKeys="true" keyProperty="adId">
insert into bst_ad
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -64,7 +64,7 @@ public interface AdService
AdVO selectOne(AdQuery adQuery);
List<AdVO> toAppVOList();
List<AdVO> toAppVOList(AdQuery adQuery);
public int logicalDel(List<Long> adIds);
}

View File

@ -146,24 +146,18 @@ public class AdServiceImpl implements AdService
@Override
public List<AdVO> toAppVOList() {
public List<AdVO> toAppVOList(AdQuery adQuery) {
List<AdVO> list = new ArrayList<>();
OrderQuery orderQuery = new OrderQuery();
orderQuery.setUserId(SecurityUtils.getUserId());
OrderVO orderVO = orderService.selectOne(orderQuery);
// 如果有订单,查询对应商户的广告
if (orderVO != null) {
AdQuery adStoreVO = adConverter.toAdStoreVO();
adStoreVO.setStoreId(orderVO.getAreaUserId());
AdVO vo = adMapper.selectOne(adStoreVO);
if (vo != null) {
list.add(vo);
}
UserVO user = userService.selectUserById(adQuery.getUserId());
// 查询所属运营区的广告
List<AdVO> areaAdVOList = adMapper.selectAdByAreaId(user.getAreaId());
if (areaAdVOList != null) {
list.addAll(areaAdVOList);
}
// 查询管理员发布的广告
List<AdVO> adminVOList = adMapper.selectAdList(adConverter.toAdAdminVO());
if (adminVOList != null) {
list.addAll(adminVOList);
List<AdVO> adminAdVOList = adMapper.selectAdList(adConverter.toAdAdminVO());
if (adminAdVOList != null) {
list.addAll(adminAdVOList);
}
return list;
}

View File

@ -22,8 +22,9 @@ public class AppAdController extends BaseController {
@ApiOperation("获取广告")
@GetMapping
@Anonymous
public AjaxResult getAd() {
return success(adService.toAppVOList());
public AjaxResult getAd(AdQuery query) {
query.setUserId(getUserId());
return success(adService.toAppVOList(query));
}
}