| @@ -0,0 +1,24 @@ | |||
| DROP TABLE IF EXISTS `mall_sale_type` ; | |||
| CREATE TABLE `mall_sale_type` ( | |||
| `id` bigint(64) NOT NULL, | |||
| `name` varchar(32) DEFAULT NULL COMMENT '销售类型', | |||
| `type` tinyint(2) DEFAULT NULL COMMENT '资源类型1:标准版 2:速享版 3.营销版', | |||
| `period` tinyint(2) DEFAULT NULL COMMENT '有效期(单位月)', | |||
| `menus` json DEFAULT NULL COMMENT '菜单列表', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE `id_UNIQUE` USING BTREE (`id`) comment '' | |||
| ) ENGINE=`InnoDB` ROW_FORMAT=DYNAMIC COMMENT='系统销售表' CHECKSUM=0 DELAY_KEY_WRITE=0; | |||
| INSERT INTO `mall_sale_type` | |||
| (`id`,`name`, `type`, `period`, `menus`) | |||
| VALUES | |||
| (1, '标准版', 3, 12, | |||
| '[1,2,3,4,5,6,7,8,9,101,102,103,104,105,106,107,201,202,203,204,205,211,212,221,222,251,301,302,303,304,401,402,403,404,405,406,407,408,409,410,411,501,502,503,504,505,506,507,508,511,512,513,521,522,523,531,532,533,601,602,603,604,605,606,607,608,609,610,611,621,622,623,624,625,626,641,642,643,644,645,651,661,662,671,672,673,674,681,682,683,684,685,691,692,693,694,701,702,711,712,713,901,902,951,961]' | |||
| ), | |||
| (2, '速享版', 1, 1, | |||
| '[2,4,5,6,201,202,205,409,410,411,501,502,503,504,505,506,507,508,511,512,513,521,522,523,531,532,533,601,602,603,604,605,606,607,608,609,610,611,621,622,623,624,625,626,641,642,643,644,645,651,661,662,671,672,673,674,681,682,683,684,685,691,692,693,694,701,702,711,712,713,901,902]' | |||
| ), | |||
| (3, '营销版', 2, 12, | |||
| '[1,2,4,5,6,101,103,104,105,106,201,202,205,409,410,411,501,502,503,504,505,506,507,508,511,512,513,521,522,523,531,532,533,601,602,603,604,605,606,607,608,609,610,611,621,622,623,624,625,626,641,642,643,644,645,651,661,662,671,672,673,674,681,682,683,684,685,691,692,693,694,701,702,711,712,713,901,902]' | |||
| ) | |||
| ; | |||
| @@ -0,0 +1,90 @@ | |||
| package com.iformall.domain.po; | |||
| import lombok.Data; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.util.List; | |||
| @Data | |||
| @Table(name = "mall_sale_type") | |||
| public class MallSaleType implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| @io.swagger.annotations.ApiModelProperty(value="销售类型名",name="name") | |||
| private String name; | |||
| @io.swagger.annotations.ApiModelProperty(value="资源类型1:速享版 2:速享标准版 3.标准版",name="type") | |||
| private Integer type; | |||
| @io.swagger.annotations.ApiModelProperty(value="有效期(单位月))",name="period") | |||
| private Integer period; | |||
| @io.swagger.annotations.ApiModelProperty(value="菜单列表",name="menus") | |||
| private String menus; | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||
| ,Period_ASC("`period` ASC"),Period_DESC("`period` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| this.value = value; | |||
| } | |||
| public String getValue() { | |||
| return value; | |||
| } | |||
| public void setCol(String value) { | |||
| this.value = value; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(MallSaleType.Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| } | |||
| for (int k = 0; k < fields.length; k++) { | |||
| if (fields[k] == null) { | |||
| return; | |||
| } | |||
| } | |||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||
| for (int k = 1; k < fields.length; k++) { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| return; | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| List<Field> fList = new java.util.ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(Field.valueOf(cols[k])); | |||
| } | |||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||
| } else { | |||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.MallSaleType; | |||
| import java.util.List; | |||
| public interface MallSaleTypeMapper extends CommonMapper<MallSaleType, String> { | |||
| List<MallSaleType> findList(MallSaleType mallSaleType); | |||
| } | |||
| @@ -0,0 +1,51 @@ | |||
| package com.iformall.service.sys; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.MallPermission; | |||
| import com.iformall.domain.po.MallSaleType; | |||
| import java.util.List; | |||
| public interface MallSaleTypeService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<MallSaleType> listAsPage(MallSaleType record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @return | |||
| */ | |||
| List<MallSaleType> getList(MallSaleType record); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| MallSaleType getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(MallSaleType record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| } | |||
| @@ -0,0 +1,54 @@ | |||
| package com.iformall.service.sys.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.MallSaleType; | |||
| import com.iformall.mapper.MallSaleTypeMapper; | |||
| import com.iformall.service.sys.MallSaleTypeService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.List; | |||
| @Service | |||
| public class MallSaleTypeServiceImpl implements MallSaleTypeService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| MallSaleTypeMapper mallSaleTypeMapper; | |||
| @Override | |||
| public PageInfo<MallSaleType> listAsPage(MallSaleType record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> mallSaleTypeMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public List<MallSaleType> getList(MallSaleType record) { | |||
| return mallSaleTypeMapper.findList(record); | |||
| } | |||
| @Override | |||
| public MallSaleType getById(Long id) { | |||
| return mallSaleTypeMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(MallSaleType record) { | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| mallSaleTypeMapper.insertSelective(record); | |||
| } else { | |||
| mallSaleTypeMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| mallSaleTypeMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -0,0 +1,51 @@ | |||
| <?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.MallSaleTypeMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.MallSaleType"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||
| <result column="type" jdbcType="TINYINT" property="type"/> | |||
| <result column="period" jdbcType="TINYINT" property="period"/> | |||
| <result column="menus" jdbcType="VARCHAR" property="menus"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`name`,`type`,`period`,`menus` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != name "> | |||
| and `name` = #{name} | |||
| </if> | |||
| <if test=" null != parentId "> | |||
| and `type` = #{type} | |||
| </if> | |||
| <if test=" null != period "> | |||
| and `period` = #{period} | |||
| </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.MallSaleType" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from mall_sale_type | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| </mapper> | |||