Commit c4e4a6b2 authored by liaoanyuan's avatar liaoanyuan

管理端广告增加删除功能,查询添加type和status筛选字段

parent fc8df5c1
......@@ -44,7 +44,7 @@ public interface BannerMapper extends BaseMapper<Banner> {
* 统计广告条数
* @return 广告条数
*/
int count();
int count(Map<String,Object> map);
/**
* 通过广告id查询广告信息
......
......@@ -84,6 +84,10 @@
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
<if test="status != null">and status =#{status}</if>
<if test="type != null">and type =#{type}</if>
</where>
order by create_time desc
limit #{pageNo},#{pageSize}
</select>
......@@ -92,6 +96,10 @@
select count(1)
from
<include refid="table"/>
<where>
<if test="status != null">and status =#{status}</if>
<if test="type != null">and type =#{type}</if>
</where>
</select>
<select id="getById" resultMap="advertisingMap">
......
......@@ -23,6 +23,18 @@ public class AdvertisingQueryVo implements Serializable {
@ApiModelProperty(value = "关键词", name = "keyword")
private String keyword;
/**
* 广告类型: 1:顶部广告 2:底部广告
*/
@ApiModelProperty(value = "广告类型: 1:顶部广告 2:底部广告",name = "type")
private Integer type;
/**
* 投放状态 0:暂停中 1:投放中
*/
@ApiModelProperty(value = "投放状态 0:暂停中 1:投放中",name = "status")
private Integer status;
/**
* 开始时间
*/
......
......@@ -58,4 +58,10 @@ public interface BannerService {
R<List<Banner>> getTopBanners(Integer type);
/**
* 工具广告id删除广告
* @param id 广告id
* @return true 成功 false 失败
*/
R<Boolean> delBanner(Integer id);
}
......@@ -103,12 +103,14 @@ public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> impleme
HashMap<String, Object> map = new HashMap<>(4);
map.put("pageNo", (pageNo - 1)*pageSize);
map.put("pageSize", pageSize);
map.put("status",null==advertisingQueryVo.getStatus()?null:advertisingQueryVo.getStatus());
map.put("type",null==advertisingQueryVo.getType()?null:advertisingQueryVo.getType());
//查询数据;
List<BannerDto> list = bannerMapper.getList(map);
PageInfo<BannerDto> pageInfo = new PageInfo<>();
pageInfo.setTotal(bannerMapper.count());
pageInfo.setTotal(bannerMapper.count(map));
pageInfo.setPageNum(pageNo);
pageInfo.setPageSize(pageSize);
pageInfo.setList(list);
......@@ -141,4 +143,18 @@ public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> impleme
}
return R.ok(bannerMapper.getTopBanners(type));
}
@Override
public R<Boolean> delBanner(Integer id) {
log.info("BannerServiceImpl[]delBanner[]input.param.id:" + id);
if (null==id) {
return R.error("参数为空");
}
int i = bannerMapper.delById(id);
if (i==0) {
return R.ok(1,false);
}
return R.ok(0,true);
}
}
......@@ -42,7 +42,7 @@ public class BannerController {
@ApiOperation(value = "广告查询", notes = "广告查询", httpMethod = "POST")
@ApiImplicitParam(name = "advertisingQueryVo", value = "分页数据", dataType = "AdvertisingQueryVo")
@PostMapping("/getList")
public R<PageInfo<BannerDto>> add(@RequestBody AdvertisingQueryVo advertisingQueryVo) {
public R<PageInfo<BannerDto>> getList(@RequestBody AdvertisingQueryVo advertisingQueryVo) {
log.info("BannerController[].add[].input.param:advertisingQueryVo:" + advertisingQueryVo);
return bannerService.getList(advertisingQueryVo);
}
......@@ -89,4 +89,14 @@ public class BannerController {
return bannerService.getTopBanners(type);
}
@ApiOperation(value = "删除广告", notes = "删除广告", httpMethod = "GET")
@ApiImplicitParam(name = "id", value = "广告id", dataType = "int", required = true)
@GetMapping("/delBanner")
public R<Boolean> delBanner(Integer id) {
log.info("BannerController[]delBanner[]input.param.id:" + id);
if (null == id) {
return R.error("入参不能为空!");
}
return bannerService.delBanner(id);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment