前端广告展示

This commit is contained in:
SjS 2025-04-25 11:20:03 +08:00
parent 4e96d3c16e
commit 1236c24184
8 changed files with 47 additions and 41 deletions

View File

@ -59,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.picture != null and query.picture != ''"> and bad.picture = #{query.picture}</if>
<if test="query.url != null and query.url != ''"> and bad.url like concat('%',#{query.url},'%') </if>
<if test="query.deleted != null "> and bad.deleted = #{query.deleted}</if>
<if test="query.auditStatus != null "> and bad.audit_status = #{query.auditStatus}</if>
<if test="query.urlType != null and query.urlType != ''"> and bad.url_type = #{query.urlType}</if>
${@com.ruoyi.framework.util.DataScopeUtil@dataScope(
null,
@ -98,13 +99,6 @@ 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

@ -8,11 +8,8 @@ import java.util.List;
public interface AdConverter {
AdQuery toAdQueryByCreate(Ad ad);
AdQuery toAdAdminVO();
AdQuery toAdStoreVO();
Ad toPoByCreate(Ad ad);
Ad toPoByUpdate(Ad ad);
}

View File

@ -12,28 +12,6 @@ import org.springframework.stereotype.Service;
@Service
public class AdConverterImpl implements AdConverter {
@Override
public AdQuery toAdQueryByCreate(Ad ad) {
AdQuery query = new AdQuery();
query.setAreaId(ad.getAreaId());
query.setBelong(ad.getBelong());
return query;
}
@Override
public AdQuery toAdAdminVO() {
AdQuery query = new AdQuery();
query.setBelong(AdBlong.ADMIN.getCode());
return query;
}
@Override
public AdQuery toAdStoreVO() {
AdQuery query = new AdQuery();
query.setUserId(SecurityUtils.getUserId());
query.setBelong(AdBlong.STORE.getCode());
return query;
}
@Override
public Ad toPoByCreate(Ad data) {
@ -51,4 +29,21 @@ public class AdConverterImpl implements AdConverter {
return po;
}
@Override
public Ad toPoByUpdate(Ad data) {
if (data == null) {
return null;
}
Ad po = new Ad();
// 基础信息
po.setAdId(data.getAdId());
po.setAreaId(data.getAreaId());
po.setType(data.getType());
po.setPicture(data.getPicture());
po.setBelong(data.getBelong());
po.setUrl(data.getUrl());
po.setUrlType(data.getUrlType());
return po;
}
}

View File

@ -156,14 +156,17 @@ public class AdServiceImpl implements AdService
@Override
public List<AdVO> toAppVOList(AdQuery adQuery) {
List<AdVO> list = new ArrayList<>();
UserVO user = userService.selectUserById(adQuery.getUserId());
// 查询所属运营区的广告
List<AdVO> areaAdVOList = adMapper.selectAdByAreaId(user.getAreaId());
UserVO user = userService.selectUserById(adQuery.getUserId());
adQuery.setAreaId(user.getAreaId());
List<AdVO> areaAdVOList = adMapper.selectAdList(adQuery);
if (areaAdVOList != null) {
list.addAll(areaAdVOList);
}
// 查询管理员发布的广告
List<AdVO> adminAdVOList = adMapper.selectAdList(adConverter.toAdAdminVO());
AdQuery query = new AdQuery();
query.setBelong(AdBlong.ADMIN.getCode());
List<AdVO> adminAdVOList = adMapper.selectAdList(query);
if (adminAdVOList != null) {
list.addAll(adminAdVOList);
}

View File

@ -4,9 +4,13 @@ import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.interfaces.LogBizParam;
import com.ruoyi.common.core.validate.ValidGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 协议对象 bst_agreement
*
@ -26,10 +30,12 @@ public class Agreement extends BaseEntity implements LogBizParam
@Excel(name = "运营区ID")
@ApiModelProperty("运营区ID")
@NotNull(message = "运营区ID不能为空",groups = {ValidGroup.Create.class})
private Long areaId;
@Excel(name = "标题")
@ApiModelProperty("标题")
@NotBlank(message = "标题不能为空",groups = {ValidGroup.Create.class})
private String title;
@Excel(name = "简介")
@ -38,12 +44,19 @@ public class Agreement extends BaseEntity implements LogBizParam
@Excel(name = "内容详情")
@ApiModelProperty("内容详情")
@NotBlank(message = "内容详情不能为空",groups = {ValidGroup.Create.class})
private String content;
@Excel(name = "协议类型:0-公告 1-免责协议 2-安全协议")
@ApiModelProperty("协议类型:0-公告 1-免责协议 2-安全协议")
@Excel(name = "协议类型:0-公告 1-租赁协议 ")
@ApiModelProperty("协议类型:0-公告 1-租赁协议 ")
@NotBlank(message = "协议类型不能为空",groups = {ValidGroup.Create.class})
private String agreementType;
@Excel(name = "内容类型:1-模板 2-正文")
@ApiModelProperty("内容类型:1-模板 2-正文")
private String contentType;
@Excel(name = "展示时间")
@ApiModelProperty("展示时间")
private Integer duration;

View File

@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bag.title,
bag.brief,
bag.content,
bag.content_type,
bag.agreement_type,
bag.duration,
bag.create_time,
@ -86,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="brief != null">brief,</if>
<if test="content != null">content,</if>
<if test="agreementType != null">agreement_type,</if>
<if test="contentType != null">content_type,</if>
<if test="duration != null">duration,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
@ -97,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="brief != null">#{brief},</if>
<if test="content != null">#{content},</if>
<if test="agreementType != null">#{agreementType},</if>
<if test="contentType != null">#{contentType},</if>
<if test="duration != null">#{duration},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
@ -256,6 +259,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.brief != null">brief = #{data.brief},</if>
<if test="data.content != null">content = #{data.content},</if>
<if test="data.agreementType != null">agreement_type = #{data.agreementType},</if>
<if test="data.contentType != null">content_type = #{data.contentType},</if>
<if test="data.duration != null">duration = #{data.duration},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if>
<if test="data.updateTime != null">update_time = #{data.updateTime},</if>

View File

@ -27,6 +27,7 @@ public class AppAdController extends BaseController {
public AjaxResult getAd(AdQuery query) {
query.setUserId(getUserId());
query.setAuditStatus(AdVerifyStatus.PASSED.getCode());
query.setDeleted(false);
return success(adService.toAppVOList(query));
}

View File

@ -66,7 +66,6 @@ public class AdController extends BaseController
startPage();
startOrderBy();
query.setScope(true);
query.setUserId(getUserId());
query.setDeleted(false);
return getDataTable(adService.selectAdList(query));
}