| @@ -0,0 +1,192 @@ | |||||
| 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_date_amount_record") | |||||
| public class WxDateAmountRecord 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="date") | |||||
| private Date date; | |||||
| /*周几 从1开始**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="周几 从1开始",name="dayOfWeek") | |||||
| private Integer dayOfWeek; | |||||
| /*一年第几周**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="一年第几周",name="weekOfYear") | |||||
| private Integer weekOfYear; | |||||
| /*金额**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="金额",name="payPrice") | |||||
| private Integer payPrice; | |||||
| /*租户id**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId") | |||||
| private String tenantId; | |||||
| /*月份**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="月份",name="month") | |||||
| private Integer month; | |||||
| /*商户id**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户id",name="merchantId") | |||||
| private Long merchantId; | |||||
| /*创建日期**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建日期",name="createDate") | |||||
| private Date createDate; | |||||
| /*更新日期**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新日期",name="updateDate") | |||||
| private Date updateDate; | |||||
| public Date getDate() { | |||||
| return date; | |||||
| } | |||||
| public void setDate(Date _date) { | |||||
| date = _date; | |||||
| } | |||||
| public Integer getDayOfWeek() { | |||||
| return dayOfWeek; | |||||
| } | |||||
| public void setDayOfWeek(Integer _dayOfWeek) { | |||||
| dayOfWeek = _dayOfWeek; | |||||
| } | |||||
| public Integer getWeekOfYear() { | |||||
| return weekOfYear; | |||||
| } | |||||
| public void setWeekOfYear(Integer _weekOfYear) { | |||||
| weekOfYear = _weekOfYear; | |||||
| } | |||||
| public Integer getPayPrice() { | |||||
| return payPrice; | |||||
| } | |||||
| public void setPayPrice(Integer _payPrice) { | |||||
| payPrice = _payPrice; | |||||
| } | |||||
| public String getTenantId() { | |||||
| return tenantId; | |||||
| } | |||||
| public void setTenantId(String _tenantId) { | |||||
| tenantId = _tenantId; | |||||
| } | |||||
| public Integer getMonth() { | |||||
| return month; | |||||
| } | |||||
| public void setMonth(Integer _month) { | |||||
| month = _month; | |||||
| } | |||||
| public Long getMerchantId() { | |||||
| return merchantId; | |||||
| } | |||||
| public void setMerchantId(Long _merchantId) { | |||||
| merchantId = _merchantId; | |||||
| } | |||||
| public Date getCreateDate() { | |||||
| return createDate; | |||||
| } | |||||
| public void setCreateDate(Date _createDate) { | |||||
| createDate = _createDate; | |||||
| } | |||||
| public Date getUpdateDate() { | |||||
| return updateDate; | |||||
| } | |||||
| public void setUpdateDate(Date _updateDate) { | |||||
| updateDate = _updateDate; | |||||
| } | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,Date_ASC("`date` ASC"),Date_DESC("`date` DESC") | |||||
| ,DayOfWeek_ASC("`dayOfWeek` ASC"),DayOfWeek_DESC("`dayOfWeek` DESC") | |||||
| ,WeekOfYear_ASC("`weekOfYear` ASC"),WeekOfYear_DESC("`weekOfYear` DESC") | |||||
| ,PayPrice_ASC("`payPrice` ASC"),PayPrice_DESC("`payPrice` DESC") | |||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||||
| ,Month_ASC("`month` ASC"),Month_DESC("`month` DESC") | |||||
| ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") | |||||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` 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(WxDateAmountRecord.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)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -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.WxDateAmountRecord; | |||||
| public interface WxDateAmountRecordMapper extends CommonMapper<WxDateAmountRecord, String> { | |||||
| List<WxDateAmountRecord> findList(WxDateAmountRecord wxDateAmountRecord); | |||||
| } | |||||
| @@ -0,0 +1,48 @@ | |||||
| package com.simple.service; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.domain.po.WxDateAmountRecord; | |||||
| public interface WxDateAmountRecordService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param offset | |||||
| * @param limit | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxDateAmountRecord> listAsPage(WxDateAmountRecord record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxDateAmountRecord getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxDateAmountRecord 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.WxDateAmountRecord; | |||||
| import com.simple.mapper.WxDateAmountRecordMapper; | |||||
| import com.simple.service.WxDateAmountRecordService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.simple.common.IdWorker; | |||||
| @Service | |||||
| public class WxDateAmountRecordServiceImpl implements WxDateAmountRecordService { | |||||
| @Autowired | |||||
| WxDateAmountRecordMapper wxDateAmountRecordMapper; | |||||
| @Override | |||||
| public PageInfo<WxDateAmountRecord> listAsPage(WxDateAmountRecord record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxDateAmountRecordMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxDateAmountRecord getById(Long id) { | |||||
| return wxDateAmountRecordMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxDateAmountRecord record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| IdWorker idWorker = new IdWorker(0, 0); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxDateAmountRecordMapper.insertSelective(record); | |||||
| } else { | |||||
| wxDateAmountRecordMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxDateAmountRecordMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,92 @@ | |||||
| <?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.WxDateAmountRecordMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxDateAmountRecord"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="date" jdbcType="TIMESTAMP" property="date" /> | |||||
| <result column="day_of_week" jdbcType="INTEGER" property="dayOfWeek" /> | |||||
| <result column="week_of_year" jdbcType="INTEGER" property="weekOfYear" /> | |||||
| <result column="pay_price" jdbcType="INTEGER" property="payPrice" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="month" jdbcType="INTEGER" property="month" /> | |||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`date`,`day_of_week`,`week_of_year`,`pay_price`,`tenant_id`,`month`,`merchant_id`,`create_date`,`update_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != date "> | |||||
| and `date` = #{date} | |||||
| </if> | |||||
| <if test=" null != dayOfWeek "> | |||||
| and `day_of_week` = #{dayOfWeek} | |||||
| </if> | |||||
| <if test=" null != weekOfYear "> | |||||
| and `week_of_year` = #{weekOfYear} | |||||
| </if> | |||||
| <if test=" null != payPrice "> | |||||
| and `pay_price` = #{payPrice} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||||
| </if> | |||||
| <if test=" null != month "> | |||||
| and `month` = #{month} | |||||
| </if> | |||||
| <if test=" null != merchantId "> | |||||
| and `merchant_id` = #{merchantId} | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </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.WxDateAmountRecord" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_date_amount_record | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||