广告更新
This commit is contained in:
parent
c5032f64b6
commit
a7f7aaefc7
|
@ -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.deleted == null "> and bad.deleted = false</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(
|
||||
|
|
|
@ -68,7 +68,6 @@ public interface AdService
|
|||
AdVO selectOne(AdQuery adQuery);
|
||||
|
||||
|
||||
List<AdVO> toAppVOList(AdQuery adQuery);
|
||||
|
||||
public int logicalDel(List<Long> adIds);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public class AdConverterImpl implements AdConverter {
|
|||
|
||||
po.setUrl(data.getUrl());
|
||||
po.setUrlType(data.getUrlType());
|
||||
po.setAuditStatus(data.getAuditStatus());
|
||||
return po;
|
||||
}
|
||||
|
||||
|
@ -48,6 +49,7 @@ public class AdConverterImpl implements AdConverter {
|
|||
po.setPicture(data.getPicture());
|
||||
po.setUrl(data.getUrl());
|
||||
po.setUrlType(data.getUrlType());
|
||||
po.setAuditStatus(data.getAuditStatus());
|
||||
return po;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ public class AdServiceImpl implements AdService {
|
|||
if (ad.getBelong().equals(AdBlong.STORE.getCode())) {
|
||||
AreaVO area = areaService.selectAreaById(ad.getAreaId());
|
||||
ad.setStoreId(area.getUserId());
|
||||
|
||||
// 条件查询广告
|
||||
AdQuery query = new AdQuery();
|
||||
query.setAreaId(ad.getAreaId());
|
||||
|
@ -108,7 +109,7 @@ public class AdServiceImpl implements AdService {
|
|||
}
|
||||
}
|
||||
AreaVO area = areaService.selectAreaById(ad.getAreaId());
|
||||
if (area.getUserId() != null) {
|
||||
if (area != null && area.getUserId() != null) {
|
||||
ad.setStoreId(area.getUserId());
|
||||
}
|
||||
ad.setUpdateTime(DateUtils.getNowDate());
|
||||
|
@ -143,26 +144,6 @@ public class AdServiceImpl implements AdService {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AdVO> toAppVOList(AdQuery adQuery) {
|
||||
List<AdVO> list = new ArrayList<>();
|
||||
// 查询所属运营区的广告
|
||||
UserVO user = userService.selectUserById(adQuery.getUserId());
|
||||
adQuery.setAreaId(user.getAreaId());
|
||||
List<AdVO> areaAdVOList = adMapper.selectAdList(adQuery);
|
||||
if (areaAdVOList != null) {
|
||||
list.addAll(areaAdVOList);
|
||||
}
|
||||
// 查询管理员发布的广告
|
||||
AdQuery query = new AdQuery();
|
||||
query.setBelong(AdBlong.ADMIN.getCode());
|
||||
List<AdVO> adminAdVOList = adMapper.selectAdList(query);
|
||||
if (adminAdVOList != null) {
|
||||
list.addAll(adminAdVOList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int logicalDel(List<Long> adIds) {
|
||||
return adMapper.logicalDel(adIds);
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package com.ruoyi.web.app;
|
||||
|
||||
import com.ruoyi.bst.ad.domain.AdQuery;
|
||||
import com.ruoyi.bst.ad.domain.AdVO;
|
||||
import com.ruoyi.bst.ad.domain.enums.AdBlong;
|
||||
import com.ruoyi.bst.ad.domain.enums.AdVerifyStatus;
|
||||
import com.ruoyi.common.core.domain.vo.UserVO;
|
||||
import com.ruoyi.system.user.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -14,6 +18,9 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
|||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/ad")
|
||||
public class AppAdController extends BaseController {
|
||||
|
@ -21,14 +28,37 @@ public class AppAdController extends BaseController {
|
|||
@Autowired
|
||||
private AdService adService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@ApiOperation("获取广告")
|
||||
@GetMapping
|
||||
@Anonymous
|
||||
public AjaxResult getAd(AdQuery query) {
|
||||
query.setUserId(getUserId());
|
||||
query.setAuditStatus(AdVerifyStatus.PASSED.getCode());
|
||||
query.setDeleted(false);
|
||||
return success(adService.toAppVOList(query));
|
||||
|
||||
List<AdVO> list = new ArrayList<>();
|
||||
|
||||
// 查询所属运营区的广告
|
||||
UserVO user = userService.selectUserById(getUserId());
|
||||
if (user.getAreaId() != null) {
|
||||
query.setAreaId(user.getAreaId());
|
||||
query.setBelong(AdBlong.STORE.getCode());
|
||||
List<AdVO> areaAdVOList = adService.selectAdList(query);
|
||||
if (areaAdVOList != null) {
|
||||
list.addAll(areaAdVOList);
|
||||
}
|
||||
}
|
||||
|
||||
// 查询管理员发布的广告
|
||||
query.setAreaId(null);
|
||||
query.setBelong(AdBlong.ADMIN.getCode());
|
||||
List<AdVO> adminAdVOList = adService.selectAdList(query);
|
||||
if (adminAdVOList != null) {
|
||||
list.addAll(adminAdVOList);
|
||||
}
|
||||
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -99,6 +99,11 @@ public class AdController extends BaseController
|
|||
@PostMapping
|
||||
public AjaxResult add(@Validated(ValidGroup.Create.class) @RequestBody Ad ad)
|
||||
{
|
||||
if (isSysAdmin()) {
|
||||
ad.setAuditStatus("2");
|
||||
} else {
|
||||
ad.setAuditStatus("1");
|
||||
}
|
||||
ad = adConverter.toPoByCreate(ad);
|
||||
return toAjax(adService.insertAd(ad));
|
||||
}
|
||||
|
@ -115,6 +120,11 @@ public class AdController extends BaseController
|
|||
if (!adValidator.canEdit(ad.getAdId())){
|
||||
return AjaxResult.error("您没有权限修改id为" + ad.getAdId() + "的广告信息");
|
||||
}
|
||||
if (isSysAdmin()) {
|
||||
ad.setAuditStatus("2");
|
||||
} else {
|
||||
ad.setAuditStatus("1");
|
||||
}
|
||||
adConverter.toPoByUpdate(ad);
|
||||
return toAjax(adService.updateAd(ad));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user