| @@ -0,0 +1,78 @@ | |||||
| package com.simple.controller; | |||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.common.Result; | |||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxLevelConfig; | |||||
| import com.simple.service.WxLevelConfigService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| @RestController | |||||
| @RequestMapping("wxLevelConfig") | |||||
| @Api(description="等级权益相关接口") | |||||
| public class WxLevelConfigController extends BaseController | |||||
| { | |||||
| @Autowired | |||||
| private WxLevelConfigService wxLevelConfigService; | |||||
| private Logger logger = Logger.getLogger(WxLevelConfigController.class); | |||||
| @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 WxLevelConfig wxLevelConfig,Integer pageNum, Integer pageSize) { | |||||
| if (null == wxLevelConfig) wxLevelConfig = new WxLevelConfig(); | |||||
| final PageInfo<WxLevelConfig> page = wxLevelConfigService.listAsPage(wxLevelConfig, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| public ResultData add(@RequestBody WxLevelConfig wxLevelConfig) { | |||||
| //Assert.notNull(wxLevelConfig.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxLevelConfig.setTenantId(getTenantId()); | |||||
| wxLevelConfigService.saveOrUpdate(wxLevelConfig); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| public ResultData update(@RequestBody WxLevelConfig wxLevelConfig) { | |||||
| wxLevelConfigService.saveOrUpdate(wxLevelConfig); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||||
| public ResultData delete(Long id) { | |||||
| wxLevelConfigService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||||
| public ResultData findById(Long id) { | |||||
| return new ResultData(Result.SUCCESS,"查询成功",wxLevelConfigService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -11,12 +11,15 @@ import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxScoreRules; | import com.simple.domain.po.WxScoreRules; | ||||
| import com.simple.service.WxScoreRulesService; | import com.simple.service.WxScoreRulesService; | ||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| @RestController | @RestController | ||||
| @RequestMapping("wxScoreRules") | @RequestMapping("wxScoreRules") | ||||
| @Api(description="成长值规则相关接口") | |||||
| public class WxScoreRulesController extends BaseController | public class WxScoreRulesController extends BaseController | ||||
| { | { | ||||
| @Autowired | @Autowired | ||||
| @@ -40,7 +43,8 @@ public class WxScoreRulesController extends BaseController | |||||
| public ResultData add(@RequestBody WxScoreRules wxScoreRules) { | public ResultData add(@RequestBody WxScoreRules wxScoreRules) { | ||||
| //Assert.notNull(wxScoreRules.getName(), "角色名不能为空"); | //Assert.notNull(wxScoreRules.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxScoreRulesService.saveOrUpdate(wxScoreRules); | |||||
| wxScoreRules.setTenantId(getTenantId()); | |||||
| wxScoreRulesService.saveOrUpdate(wxScoreRules); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -0,0 +1,152 @@ | |||||
| package com.simple.domain.po; | |||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import java.math.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | |||||
| import java.io.Serializable; | |||||
| @Table(name = "wx_level_config") | |||||
| public class WxLevelConfig implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| public Long getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Long id) { | |||||
| this.id = id; | |||||
| } | |||||
| public String getSortColumns() { | |||||
| return sortColumns; | |||||
| } | |||||
| public List<Long> getIds() { | |||||
| return ids; | |||||
| } | |||||
| public void setIds(List<Long> ids) { | |||||
| this.ids = ids; | |||||
| } | |||||
| /*成长值**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="成长值",name="points") | |||||
| private Integer points; | |||||
| /*等级**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="等级",name="level") | |||||
| private String level; | |||||
| /*描述**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="描述",name="description") | |||||
| private String description; | |||||
| /*创建时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| /*租户id**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId") | |||||
| private String tenantId; | |||||
| public Integer getPoints() { | |||||
| return points; | |||||
| } | |||||
| public void setPoints(Integer _points) { | |||||
| points = _points; | |||||
| } | |||||
| public String getLevel() { | |||||
| return level; | |||||
| } | |||||
| public void setLevel(String _level) { | |||||
| level = _level; | |||||
| } | |||||
| public String getDescription() { | |||||
| return description; | |||||
| } | |||||
| public void setDescription(String _description) { | |||||
| description = _description; | |||||
| } | |||||
| public Date getCreateDate() { | |||||
| return createDate; | |||||
| } | |||||
| public void setCreateDate(Date _createDate) { | |||||
| createDate = _createDate; | |||||
| } | |||||
| public String getTenantId() { | |||||
| return tenantId; | |||||
| } | |||||
| public void setTenantId(String _tenantId) { | |||||
| tenantId = _tenantId; | |||||
| } | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,Points_ASC("`points` ASC"),Points_DESC("`points` DESC") | |||||
| ,Level_ASC("`level` ASC"),Level_DESC("`level` DESC") | |||||
| ,Description_ASC("`description` ASC"),Description_DESC("`description` DESC") | |||||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` 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(WxLevelConfig.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(","); | |||||
| java.util.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)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -16,7 +16,7 @@ public class WxScoreRules implements Serializable { | |||||
| protected Long id; | protected Long id; | ||||
| @Transient | @Transient | ||||
| protected List<String> ids; | |||||
| protected List<Long> ids; | |||||
| @Transient | @Transient | ||||
| protected String sortColumns; | protected String sortColumns; | ||||
| @@ -32,10 +32,11 @@ public class WxScoreRules implements Serializable { | |||||
| return sortColumns; | return sortColumns; | ||||
| } | } | ||||
| public List<String> getIds() { | |||||
| public List<Long> getIds() { | |||||
| return ids; | return ids; | ||||
| } | } | ||||
| public void setIds(List<String> ids) { | |||||
| public void setIds(List<Long> ids) { | |||||
| this.ids = ids; | this.ids = ids; | ||||
| } | } | ||||
| @@ -46,7 +47,7 @@ public class WxScoreRules implements Serializable { | |||||
| private String tenantId; | private String tenantId; | ||||
| /*消费金额**/ | /*消费金额**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="消费金额",name="consumptionAmount") | @io.swagger.annotations.ApiModelProperty(value="消费金额",name="consumptionAmount") | ||||
| private BigDecimal consumptionAmount; | |||||
| private Integer consumptionAmount; | |||||
| /*获取积分**/ | /*获取积分**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="获取积分",name="scoreNumber") | @io.swagger.annotations.ApiModelProperty(value="获取积分",name="scoreNumber") | ||||
| private Integer scoreNumber; | private Integer scoreNumber; | ||||
| @@ -56,16 +57,22 @@ public class WxScoreRules implements Serializable { | |||||
| /*更新时间**/ | /*更新时间**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| /*登录次数**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="登录次数",name="loginCount") | |||||
| private Integer loginCount; | |||||
| /*类型:0 消费金额 1登录次数**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="类型:0 消费金额 1登录次数",name="type") | |||||
| private Integer type; | |||||
| public String getTenantId() { | public String getTenantId() { | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| public void setTenantId(String _tenantId) { | public void setTenantId(String _tenantId) { | ||||
| tenantId = _tenantId; | tenantId = _tenantId; | ||||
| } | } | ||||
| public BigDecimal getConsumptionAmount() { | |||||
| public Integer getConsumptionAmount() { | |||||
| return consumptionAmount; | return consumptionAmount; | ||||
| } | } | ||||
| public void setConsumptionAmount(BigDecimal _consumptionAmount) { | |||||
| public void setConsumptionAmount(Integer _consumptionAmount) { | |||||
| consumptionAmount = _consumptionAmount; | consumptionAmount = _consumptionAmount; | ||||
| } | } | ||||
| public Integer getScoreNumber() { | public Integer getScoreNumber() { | ||||
| @@ -86,6 +93,18 @@ public class WxScoreRules implements Serializable { | |||||
| public void setUpdateDate(Date _updateDate) { | public void setUpdateDate(Date _updateDate) { | ||||
| updateDate = _updateDate; | updateDate = _updateDate; | ||||
| } | } | ||||
| public Integer getLoginCount() { | |||||
| return loginCount; | |||||
| } | |||||
| public void setLoginCount(Integer _loginCount) { | |||||
| loginCount = _loginCount; | |||||
| } | |||||
| public Integer getType() { | |||||
| return type; | |||||
| } | |||||
| public void setType(Integer _type) { | |||||
| type = _type; | |||||
| } | |||||
| @@ -97,6 +116,8 @@ public class WxScoreRules implements Serializable { | |||||
| ,ScoreNumber_ASC("`scoreNumber` ASC"),ScoreNumber_DESC("`scoreNumber` DESC") | ,ScoreNumber_ASC("`scoreNumber` ASC"),ScoreNumber_DESC("`scoreNumber` DESC") | ||||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | ||||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | ||||
| ,LoginCount_ASC("`loginCount` ASC"),LoginCount_DESC("`loginCount` DESC") | |||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||||
| ; | ; | ||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| @@ -0,0 +1,17 @@ | |||||
| package com.simple.mapper; | |||||
| import java.util.*; | |||||
| import com.simple.common.CommonMapper; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import com.simple.domain.po.WxLevelConfig; | |||||
| public interface WxLevelConfigMapper extends CommonMapper<WxLevelConfig, Long> { | |||||
| List<WxLevelConfig> findList(WxLevelConfig wxLevelConfig); | |||||
| } | |||||
| @@ -0,0 +1,48 @@ | |||||
| package com.simple.service; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.domain.po.WxLevelConfig; | |||||
| public interface WxLevelConfigService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param offset | |||||
| * @param limit | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxLevelConfig> listAsPage(WxLevelConfig record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxLevelConfig getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxLevelConfig record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| } | |||||
| @@ -0,0 +1,54 @@ | |||||
| package com.simple.service.impl; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.domain.po.WxLevelConfig; | |||||
| import com.simple.mapper.WxLevelConfigMapper; | |||||
| import com.simple.service.WxLevelConfigService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.simple.common.IdWorker; | |||||
| @Service | |||||
| public class WxLevelConfigServiceImpl implements WxLevelConfigService { | |||||
| @Autowired | |||||
| WxLevelConfigMapper wxLevelConfigMapper; | |||||
| @Override | |||||
| public PageInfo<WxLevelConfig> listAsPage(WxLevelConfig record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxLevelConfigMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxLevelConfig getById(Long id) { | |||||
| return wxLevelConfigMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxLevelConfig record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| IdWorker idWorker = new IdWorker(0, 0); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxLevelConfigMapper.insertSelective(record); | |||||
| } else { | |||||
| wxLevelConfigMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxLevelConfigMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,68 @@ | |||||
| <?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.simple.mapper.WxLevelConfigMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxLevelConfig"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="points" jdbcType="INTEGER" property="points" /> | |||||
| <result column="level" jdbcType="VARCHAR" property="level" /> | |||||
| <result column="description" jdbcType="VARCHAR" property="description" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`points`,`level`,`description`,`create_date`,`tenant_id` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != points "> | |||||
| and `points` = #{points} | |||||
| </if> | |||||
| <if test=" null != level "> | |||||
| and `level` like concat('%', #{level},'%') | |||||
| </if> | |||||
| <if test=" null != description "> | |||||
| and `description` like concat('%', #{description},'%') | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||||
| </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.simple.domain.po.WxLevelConfig" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_level_config | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -4,14 +4,16 @@ | |||||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxScoreRules"> | <resultMap id="BaseResultMap" type="com.simple.domain.po.WxScoreRules"> | ||||
| <id column="id" jdbcType="BIGINT" property="id" /> | <id column="id" jdbcType="BIGINT" property="id" /> | ||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | ||||
| <result column="consumption_amount" jdbcType="DECIMAL" property="consumptionAmount" /> | |||||
| <result column="consumption_amount" jdbcType="INTEGER" property="consumptionAmount" /> | |||||
| <result column="score_number" jdbcType="INTEGER" property="scoreNumber" /> | <result column="score_number" jdbcType="INTEGER" property="scoreNumber" /> | ||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | ||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | ||||
| <result column="login_count" jdbcType="INTEGER" property="loginCount" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`consumption_amount`,`score_number`,`create_date`,`update_date` | |||||
| `id`,`tenant_id`,`consumption_amount`,`score_number`,`create_date`,`update_date`,`login_count`,`type` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -45,6 +47,16 @@ | |||||
| <if test=" null != updateDate "> | <if test=" null != updateDate "> | ||||
| and `update_date` = #{updateDate} | and `update_date` = #{updateDate} | ||||
| </if> | |||||
| <if test=" null != loginCount "> | |||||
| and `login_count` = #{loginCount} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | </if> | ||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||