广告模块修改

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); public int logicalDel(@Param("array") List<Long> adIds);
int countByAreaId(@Param("areaId") Long areaId, @Param("adId") Long adId); 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 AND deleted = 0
</select> </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 id="insertAd" parameterType="Ad" useGeneratedKeys="true" keyProperty="adId">
insert into bst_ad insert into bst_ad
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

View File

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

View File

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

View File

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