| @@ -0,0 +1,81 @@ | |||
| package com.iformall.controller.yqzj; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.controller.base.YqzjBaseController; | |||
| import com.iformall.domain.po.TtPoiTakeRate; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.yqzj.YqzjGuangGaoWei; | |||
| import com.iformall.domain.po.yqzj.YqzjHotNews; | |||
| import com.iformall.domain.po.yqzj.YqzjLunBoTu; | |||
| import com.iformall.domain.po.yqzj.YqzjNews; | |||
| import com.iformall.domain.po.yqzj.YqzjPageNews; | |||
| import com.iformall.domain.po.yqzj.YqzjVideo; | |||
| import com.iformall.enums.EnumCpsPlanContentType; | |||
| import com.iformall.enums.EnumCpsPlanStatus; | |||
| import com.iformall.enums.EnumCpsPlanType; | |||
| import com.iformall.enums.yqzj.EnumYqzjGuangGaoWeiType; | |||
| import com.iformall.enums.yqzj.EnumYqzjHotNewsType; | |||
| import com.iformall.enums.yqzj.EnumYqzjLunboType; | |||
| import com.iformall.enums.yqzj.EnumYqzjNewsType; | |||
| import com.iformall.enums.yqzj.EnumYqzjPageNewsType; | |||
| import com.iformall.service.TtCouponGoodsService; | |||
| import com.iformall.service.YqzjService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * @author | |||
| */ | |||
| @RestController | |||
| @RequestMapping("news") | |||
| public class YqzjNewsController extends YqzjBaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @ApiOperation("首页轮播列表") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute YqzjNews record, Integer pageNum, Integer pageSize) { | |||
| final PageInfo<YqzjNews> page = this.yqzjService.listNewsAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("更新轮播") | |||
| @PostMapping("save") | |||
| public ResultData saveNews(@RequestBody YqzjNews record) { | |||
| this.yqzjService.saveOrUpdateNews(record); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("删除轮播") | |||
| @PostMapping("del") | |||
| public ResultData deleteNews(@RequestBody YqzjLunBoTu record) { | |||
| if (null == record.getId()) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| yqzjService.deleteNews(record.getId()); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,51 @@ | |||
| package com.iformall.domain.po.yqzj; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| @TableName(value = "yqzj_news") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class YqzjNews extends TenantEntity { | |||
| private static final long serialVersionUID = 7896943199531322661L; | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumYqzjNewsType 类型",name="type") | |||
| private Integer type; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumYqzjNewsType 类型",name="subType") | |||
| private Integer subType; | |||
| @io.swagger.annotations.ApiModelProperty(value="标签",name="tag") | |||
| private String tag; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="title") | |||
| private String title; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="subTitle") | |||
| private String subTitle; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="detail") | |||
| private String detail; | |||
| @io.swagger.annotations.ApiModelProperty(value="封面图",name="image") | |||
| private String image; | |||
| @io.swagger.annotations.ApiModelProperty(value="视频地址",name="video") | |||
| private String video; | |||
| @io.swagger.annotations.ApiModelProperty(value="发布时间",name="sendDate") | |||
| private Date sendDate; | |||
| @TableField(exist = false) | |||
| private Date sendDateBegin; | |||
| @TableField(exist = false) | |||
| private Date sendDateEnd; | |||
| @io.swagger.annotations.ApiModelProperty(value="状态 EnumYqzjNewsStatus",name="status") | |||
| private Integer status; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| package com.iformall.enums.yqzj; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.exception.MallinkException; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumYqzjNewsStatus { | |||
| UN_SEND(1, "未发布"), | |||
| SEND(2, "已发布") | |||
| ; | |||
| public static EnumYqzjNewsStatus getEnum(Integer code) { | |||
| for (EnumYqzjNewsStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| public static List<Integer> getAllCodes(){ | |||
| List<Integer> codes = new ArrayList<>(); | |||
| for (EnumYqzjNewsStatus value : values()) { | |||
| codes.add(value.getCode()); | |||
| } | |||
| return codes; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumYqzjNewsStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -11,9 +11,11 @@ import java.util.List; | |||
| */ | |||
| public enum EnumYqzjNewsType { | |||
| CAR(1, "汽车资讯"), | |||
| HOT(2, "热点新闻"), | |||
| YUNYUZHOU(3, "元宇宙资讯") | |||
| HOT(1, "热点新闻",null), | |||
| CAR(2, "汽车资讯",null), | |||
| YUNYUZHOU(3, "元宇宙资讯",null), | |||
| YUNYUZHOU_ZIXUN(31,"元宇宙-资讯",3), | |||
| YUNYUZHOU_SHENDU(32,"元宇宙-深度",3) | |||
| ; | |||
| public static EnumYqzjNewsType getEnum(Integer code) { | |||
| @@ -35,10 +37,12 @@ public enum EnumYqzjNewsType { | |||
| private Integer code; | |||
| private String message; | |||
| private Integer parentCode; | |||
| EnumYqzjNewsType(Integer code, String message) { | |||
| EnumYqzjNewsType(Integer code, String message, Integer parentCode) { | |||
| this.code = code; | |||
| this.message = message; | |||
| this.parentCode = parentCode; | |||
| } | |||
| public Integer getCode() { | |||
| @@ -48,4 +52,9 @@ public enum EnumYqzjNewsType { | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| public Integer getParentCode() { | |||
| return parentCode; | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| package com.iformall.mapper; | |||
| import java.util.*; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxTopic; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.yqzj.YqzjLunBoTu; | |||
| import com.iformall.domain.po.yqzj.YqzjNews; | |||
| import com.iformall.domain.vo.TtCouponVo; | |||
| import com.iformall.domain.vo.WxCouponCVo; | |||
| import com.iformall.domain.vo.WxCouponStatisVo; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| public interface YqzjNewsMapper extends CommonMapper<YqzjNews, Long> { | |||
| List<YqzjNews> findList(YqzjNews lunbotu); | |||
| } | |||
| @@ -16,6 +16,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.yqzj.YqzjGuangGaoWei; | |||
| import com.iformall.domain.po.yqzj.YqzjHotNews; | |||
| import com.iformall.domain.po.yqzj.YqzjLunBoTu; | |||
| import com.iformall.domain.po.yqzj.YqzjNews; | |||
| import com.iformall.domain.po.yqzj.YqzjPageNews; | |||
| import com.iformall.domain.po.yqzj.YqzjVideo; | |||
| import com.iformall.domain.vo.TtCouponVo; | |||
| @@ -49,4 +50,7 @@ public interface YqzjService { | |||
| void deleteVideo(Long id); | |||
| PageInfo<YqzjNews> listNewsAsPage(YqzjNews record, Integer pageIndex, Integer pageSize); | |||
| void saveOrUpdateNews(YqzjNews record); | |||
| void deleteNews(Long id); | |||
| } | |||
| @@ -6,6 +6,7 @@ import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.yqzj.YqzjGuangGaoWei; | |||
| import com.iformall.domain.po.yqzj.YqzjHotNews; | |||
| import com.iformall.domain.po.yqzj.YqzjLunBoTu; | |||
| import com.iformall.domain.po.yqzj.YqzjNews; | |||
| import com.iformall.domain.po.yqzj.YqzjPageNews; | |||
| import com.iformall.domain.po.yqzj.YqzjVideo; | |||
| import com.iformall.mapper.*; | |||
| @@ -37,6 +38,9 @@ public class YqzjServiceImpl implements YqzjService { | |||
| @Autowired | |||
| YqzjVideoMapper yqzjVideoMapper; | |||
| @Autowired | |||
| YqzjNewsMapper yqzjNewsMapper; | |||
| @Override | |||
| public PageInfo<YqzjLunBoTu> listLunBoTuAsPage(YqzjLunBoTu record, Integer pageNum, Integer pageSize) { | |||
| @@ -130,5 +134,29 @@ public class YqzjServiceImpl implements YqzjService { | |||
| yqzjVideoMapper.deleteById(id); | |||
| } | |||
| @Override | |||
| public PageInfo<YqzjNews> listNewsAsPage(YqzjNews record, Integer pageNum, Integer pageSize) { | |||
| return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> yqzjNewsMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public void saveOrUpdateNews(YqzjNews record) { | |||
| if (null == record.getId()) { | |||
| IdWorker idworker = IdWorker.get(); | |||
| record.setId(idworker.nextId()); | |||
| record.setCreateDate(new Date()); | |||
| record.setUpdateDate(new Date()); | |||
| yqzjNewsMapper.insert(record); | |||
| }else { | |||
| record.setUpdateDate(new Date()); | |||
| yqzjNewsMapper.updateById(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteNews(Long id) { | |||
| yqzjNewsMapper.deleteById(id); | |||
| } | |||
| } | |||
| @@ -0,0 +1,82 @@ | |||
| <?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.iformall.mapper.YqzjNewsMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.yqzj.YqzjNews"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="sub_type" jdbcType="INTEGER" property="subType"/> | |||
| <result column="tag" jdbcType="VARCHAR" property="tag"/> | |||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||
| <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/> | |||
| <result column="detail" jdbcType="VARCHAR" property="detail"/> | |||
| <result column="image" jdbcType="VARCHAR" property="image"/> | |||
| <result column="video" jdbcType="VARCHAR" property="video"/> | |||
| <result column="send_date" jdbcType="TIMESTAMP" property="sendDate"/> | |||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`type`,`sub_type`,`tag`,`title`,`sub_title`,`detail`,`image`,`video`,`send_date`,`status`,,`create_date`,`update_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != type "> | |||
| and `type` = #{type} | |||
| </if> | |||
| <if test=" null != subType "> | |||
| and `sub_type` = #{subType} | |||
| </if> | |||
| <if test=" null != tag "> | |||
| and `tag` = #{tag} | |||
| </if> | |||
| <if test=" null != title "> | |||
| and `title` like concat('%', #{title},'%') | |||
| </if> | |||
| <if test=" null != sendDateBegin "> | |||
| and `send_date` >= #{sendDateBegin} | |||
| </if> | |||
| <if test=" null != sendDateEnd "> | |||
| and `send_date` <= #{sendDateEnd} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.yqzj.YqzjNews" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from yqzj_news | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| </mapper> | |||