新增MpAd模块
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package com.gxwebsoft.cms.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.cms.service.MpAdService;
|
||||
import com.gxwebsoft.cms.entity.MpAd;
|
||||
import com.gxwebsoft.cms.param.MpAdParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序广告位控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-23 01:53:01
|
||||
*/
|
||||
@Api(tags = "小程序广告位管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/cms/mp-ad")
|
||||
public class MpAdController extends BaseController {
|
||||
@Resource
|
||||
private MpAdService mpAdService;
|
||||
|
||||
@ApiOperation("分页查询小程序广告位")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<MpAd>> page(MpAdParam param) {
|
||||
// 使用关联查询
|
||||
return success(mpAdService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部小程序广告位")
|
||||
@GetMapping()
|
||||
public ApiResult<List<MpAd>> list(MpAdParam param) {
|
||||
// 使用关联查询
|
||||
return success(mpAdService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:mpAd:list')")
|
||||
@ApiOperation("根据id查询小程序广告位")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<MpAd> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(mpAdService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加小程序广告位")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody MpAd mpAd) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
mpAd.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (mpAdService.save(mpAd)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改小程序广告位")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody MpAd mpAd) {
|
||||
if (mpAdService.updateById(mpAd)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除小程序广告位")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (mpAdService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加小程序广告位")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<MpAd> list) {
|
||||
if (mpAdService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改小程序广告位")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<MpAd> batchParam) {
|
||||
if (batchParam.update(mpAdService, "ad_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除小程序广告位")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (mpAdService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.gxwebsoft.cms.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 小程序广告位
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-23 01:53:01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "MpAd对象", description = "小程序广告位")
|
||||
@TableName("cms_mp_ad")
|
||||
public class MpAd implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
@TableId(value = "ad_id", type = IdType.AUTO)
|
||||
private Integer adId;
|
||||
|
||||
@ApiModelProperty(value = "页面ID")
|
||||
private Integer pageId;
|
||||
|
||||
@ApiModelProperty(value = "广告类型")
|
||||
private String adType;
|
||||
|
||||
@ApiModelProperty(value = "广告位名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "宽")
|
||||
private String width;
|
||||
|
||||
@ApiModelProperty(value = "高")
|
||||
private String height;
|
||||
|
||||
@ApiModelProperty(value = "广告图片")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "路由/链接地址")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.cms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.cms.entity.MpAd;
|
||||
import com.gxwebsoft.cms.param.MpAdParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序广告位Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-23 01:53:01
|
||||
*/
|
||||
public interface MpAdMapper extends BaseMapper<MpAd> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<MpAd>
|
||||
*/
|
||||
List<MpAd> selectPageRel(@Param("page") IPage<MpAd> page,
|
||||
@Param("param") MpAdParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<MpAd> selectListRel(@Param("param") MpAdParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.cms.mapper.MpAdMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM cms_mp_ad a
|
||||
<where>
|
||||
<if test="param.adId != null">
|
||||
AND a.ad_id = #{param.adId}
|
||||
</if>
|
||||
<if test="param.pageId != null">
|
||||
AND a.page_id = #{param.pageId}
|
||||
</if>
|
||||
<if test="param.adType != null">
|
||||
AND a.ad_type LIKE CONCAT('%', #{param.adType}, '%')
|
||||
</if>
|
||||
<if test="param.name != null">
|
||||
AND a.name LIKE CONCAT('%', #{param.name}, '%')
|
||||
</if>
|
||||
<if test="param.width != null">
|
||||
AND a.width LIKE CONCAT('%', #{param.width}, '%')
|
||||
</if>
|
||||
<if test="param.height != null">
|
||||
AND a.height LIKE CONCAT('%', #{param.height}, '%')
|
||||
</if>
|
||||
<if test="param.images != null">
|
||||
AND a.images LIKE CONCAT('%', #{param.images}, '%')
|
||||
</if>
|
||||
<if test="param.path != null">
|
||||
AND a.path LIKE CONCAT('%', #{param.path}, '%')
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.cms.entity.MpAd">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.cms.entity.MpAd">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.gxwebsoft.cms.param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 小程序广告位查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-23 01:53:01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "MpAdParam对象", description = "小程序广告位查询参数")
|
||||
public class MpAdParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer adId;
|
||||
|
||||
@ApiModelProperty(value = "页面ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer pageId;
|
||||
|
||||
@ApiModelProperty(value = "广告类型")
|
||||
private String adType;
|
||||
|
||||
@ApiModelProperty(value = "广告位名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "宽")
|
||||
private String width;
|
||||
|
||||
@ApiModelProperty(value = "高")
|
||||
private String height;
|
||||
|
||||
@ApiModelProperty(value = "广告图片")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "路由/链接地址")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.cms.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.cms.entity.MpAd;
|
||||
import com.gxwebsoft.cms.param.MpAdParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序广告位Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-23 01:53:01
|
||||
*/
|
||||
public interface MpAdService extends IService<MpAd> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<MpAd>
|
||||
*/
|
||||
PageResult<MpAd> pageRel(MpAdParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<MpAd>
|
||||
*/
|
||||
List<MpAd> listRel(MpAdParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param adId ID
|
||||
* @return MpAd
|
||||
*/
|
||||
MpAd getByIdRel(Integer adId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.cms.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.cms.mapper.MpAdMapper;
|
||||
import com.gxwebsoft.cms.service.MpAdService;
|
||||
import com.gxwebsoft.cms.entity.MpAd;
|
||||
import com.gxwebsoft.cms.param.MpAdParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序广告位Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-23 01:53:01
|
||||
*/
|
||||
@Service
|
||||
public class MpAdServiceImpl extends ServiceImpl<MpAdMapper, MpAd> implements MpAdService {
|
||||
|
||||
@Override
|
||||
public PageResult<MpAd> pageRel(MpAdParam param) {
|
||||
PageParam<MpAd, MpAdParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<MpAd> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MpAd> listRel(MpAdParam param) {
|
||||
List<MpAd> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<MpAd, MpAdParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MpAd getByIdRel(Integer adId) {
|
||||
MpAdParam param = new MpAdParam();
|
||||
param.setAdId(adId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -68,8 +68,9 @@ public class CmsGenerator {
|
||||
// "cms_domain",
|
||||
// "cms_mp_menu"
|
||||
// "cms_mp_pages",
|
||||
"cms_mp"
|
||||
// "cms_mp"
|
||||
// "cms_mp_field"
|
||||
"cms_mp_ad"
|
||||
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
|
||||
Reference in New Issue
Block a user