Commit 0dd1527b by songxiang

模板消息发送增加来源分类和类型

parent 8b4e8aee
package com.pcloud.common.core.dao;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import com.pcloud.common.page.PageBean;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
/**
* @描述:数据访问层基础支撑接口. @作者:DiSeng.H
* @创建时间:2016年3月11日,下午4:02:32 @版本:1.0
*/
public interface BaseDao<T> {
/**
* 根据实体对象新增记录.
*
* @param entity
* .
* @return id .
*/
long insert(T entity);
/**
* 批量保存对象.
*
* @param entity
* .
* @return id .
*/
long insert(List<T> list);
/**
* 更新实体对应的记录.
*
* @param entity
* .
* @return
*/
long update(T entity);
/**
* 更新实体对应的记录.
*
* @param entity
* @param sqlId
* @return
*/
long update(T entity, String sqlId);
/**
* 批量更新对象.
*
* @param entity
* .
* @return int .
*/
long update(List<T> list);
/**
* 根据ID查找记录.
*
* @param id
* .
* @return entity .
*/
T getById(long id);
/**
* 根据ID删除记录.
*
* @param id
* .
* @return
*/
long deleteById(long id);
/**
* 分页查询 .
*
* @param pageParam
* 分页参数.
* @param paramMap
* 业务条件查询参数.
* @return
*/
PageBean listPage(PageParam pageParam, Map<String, Object> paramMap);
PageBean listSimplePage(PageParam pageParam, Map<String, Object> paramMap, String sqlId);
PageBean listPage(PageParam pageParam, Map<String, Object> paramMap, String sqlId);
<C> PageBeanNew<C> listPageNew(PageParam pageParam, Map<String, Object> paramMap, String sqlId);
PageBean listPage(PageParam pageParam, Map<String, Object> paramMap, String sqlId, String countSqlId);
/**
* 根据条件查询 listBy: <br/>
*
* @param paramMap
* @return 返回集合
*/
List<T> listBy(Map<String, Object> paramMap);
List<Object> listBy(Map<String, Object> paramMap, String sqlId);
/**
* 根据条件查询 listBy: <br/>
*
* @param paramMap
* @return 返回实体
*/
T getBy(Map<String, Object> paramMap);
Object getBy(Map<String, Object> paramMap, String sqlId);
/**
* 根据序列名称获取下一个值
*
* @return
*/
String getSeqNextValue(String seqName);
SqlSessionTemplate getSessionTemplate();
SqlSession getSqlSession();
}
package com.pcloud.common.core.dao;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import com.pcloud.common.page.PageBean;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
/**
* @描述:数据访问层基础支撑接口. @作者:DiSeng.H
* @创建时间:2016年3月11日,下午4:02:32 @版本:1.0
*/
public interface BaseDao<T> {
/**
* 根据实体对象新增记录.
*
* @param entity .
* @return id .
*/
long insert(T entity);
/**
* 批量保存对象.
*
* @param entity .
* @return id .
*/
long insert(List<T> list);
/**
* 更新实体对应的记录.
*
* @param entity .
* @return
*/
long update(T entity);
/**
* 更新实体对应的记录.
*
* @param entity
* @param sqlId
* @return
*/
long update(T entity, String sqlId);
/**
* 更新实体对应的记录.
*
* @param entity
* @param sqlId
* @param errorMessage 错误消息
* @return
*/
long update(T entity, String sqlId, String errorMessage);
/**
* 批量更新对象.
*
* @param entity .
* @return int .
*/
long update(List<T> list);
/**
* 根据ID查找记录.
*
* @param id .
* @return entity .
*/
T getById(long id);
/**
* 根据ID删除记录.
*
* @param id .
* @return
*/
long deleteById(long id);
/**
* 分页查询 .
*
* @param pageParam 分页参数.
* @param paramMap 业务条件查询参数.
* @return
*/
PageBean listPage(PageParam pageParam, Map<String, Object> paramMap);
PageBean listSimplePage(PageParam pageParam, Map<String, Object> paramMap, String sqlId);
PageBean listPage(PageParam pageParam, Map<String, Object> paramMap, String sqlId);
<C> PageBeanNew<C> listPageNew(PageParam pageParam, Map<String, Object> paramMap, String sqlId);
PageBean listPage(PageParam pageParam, Map<String, Object> paramMap, String sqlId, String countSqlId);
/**
* 根据条件查询 listBy: <br/>
*
* @param paramMap
* @return 返回集合
*/
List<T> listBy(Map<String, Object> paramMap);
List<Object> listBy(Map<String, Object> paramMap, String sqlId);
/**
* 根据条件查询 listBy: <br/>
*
* @param paramMap
* @return 返回实体
*/
T getBy(Map<String, Object> paramMap);
Object getBy(Map<String, Object> paramMap, String sqlId);
/**
* 根据序列名称获取下一个值
*
* @return
*/
String getSeqNextValue(String seqName);
SqlSessionTemplate getSessionTemplate();
SqlSession getSqlSession();
}
package com.pcloud.common.core.dto;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 模板消息dto
* @author 作者 : lili
* @date 创建时间:2016年11月17日 下午12:03:48
* @version 1.0
* @return
*/
public class TemplateMessageDto implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4132417523244980195L;
/**
* 场景编码值
*/
private String sceneCode;
/**
* 接收消息的当事人ID
*/
private Long receivePartyId;
/**
* 成员账号接收人
*/
private List<Long> receiveMemberPartyIds;
/**
* 接收消息角色(CHANNEL/AGENT/MERCHANT/ADVISER)
*/
private String receivePartyRole;
/**
* 公众号所属当事人ID
*/
private Long sendPartyId;
/**
* 公众号所属当事人角色(CHANNEL/AGENT)
*/
private String sendPartyRole;
/**
* 微信用户
*/
private Long wechatUserId;
/**
* openId
*/
private String openId;
/**
* 昵称
*/
private String nickName;
/**
* url
*/
private String url;
/**
* 参数
*/
private Map<String, String> temParam;
/**
* 发送类型(0: 通过wechatUserId 1 :通过openId 及昵称 2.通过当事人标识)
*/
private String sendType;
/**
* 公众号标识
*/
private Long accountSettingId;
/**
* 是否为应用
*/
private Boolean isApp;
/**
* 应用类型
*/
private String appType;
public Long getAccountSettingId() {
return accountSettingId;
}
public void setAccountSettingId(Long accountSettingId) {
this.accountSettingId = accountSettingId;
}
public String getSceneCode() {
return sceneCode;
}
public void setSceneCode(String sceneCode) {
this.sceneCode = sceneCode;
}
public Long getWechatUserId() {
return wechatUserId;
}
public void setWechatUserId(Long wechatUserId) {
this.wechatUserId = wechatUserId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Map<String, String> getTemParam() {
return temParam;
}
public void setTemParam(Map<String, String> temParam) {
this.temParam = temParam;
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getSendType() {
return sendType;
}
public void setSendType(String sendType) {
this.sendType = sendType;
}
public Long getReceivePartyId() {
return receivePartyId;
}
public void setReceivePartyId(Long receivePartyId) {
this.receivePartyId = receivePartyId;
}
public String getReceivePartyRole() {
return receivePartyRole;
}
public void setReceivePartyRole(String receivePartyRole) {
this.receivePartyRole = receivePartyRole;
}
public Long getSendPartyId() {
return sendPartyId;
}
public void setSendPartyId(Long sendPartyId) {
this.sendPartyId = sendPartyId;
}
public String getSendPartyRole() {
return sendPartyRole;
}
public void setSendPartyRole(String sendPartyRole) {
this.sendPartyRole = sendPartyRole;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public Boolean getIsApp() {
return isApp;
}
public void setIsApp(Boolean isApp) {
this.isApp = isApp;
}
public String getAppType() {
return appType;
}
public void setAppType(String appType) {
this.appType = appType;
}
public List<Long> getReceiveMemberPartyIds() {
return receiveMemberPartyIds;
}
public void setReceiveMemberPartyIds(List<Long> receiveMemberPartyIds) {
this.receiveMemberPartyIds = receiveMemberPartyIds;
}
@Override
public String toString() {
return "TemplateMessageDto [sceneCode=" + sceneCode + ", receivePartyId=" + receivePartyId
+ ", receiveMemberPartyIds=" + receiveMemberPartyIds + ", receivePartyRole=" + receivePartyRole
+ ", sendPartyId=" + sendPartyId + ", sendPartyRole=" + sendPartyRole + ", wechatUserId=" + wechatUserId
+ ", openId=" + openId + ", nickName=" + nickName + ", url=" + url + ", temParam=" + temParam
+ ", sendType=" + sendType + ", accountSettingId=" + accountSettingId + ", isApp=" + isApp
+ ", appType=" + appType + "]";
}
}
package com.pcloud.common.core.dto;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 模板消息dto
*
* @author 作者 : lili
* @version 1.0
* @date 创建时间:2016年11月17日 下午12:03:48
* @return
*/
public class TemplateMessageDto implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4132417523244980195L;
/**
* 场景编码值
*/
private String sceneCode;
/**
* 接收消息的当事人ID
*/
private Long receivePartyId;
/**
* 成员账号接收人
*/
private List<Long> receiveMemberPartyIds;
/**
* 接收消息角色(CHANNEL/AGENT/MERCHANT/ADVISER)
*/
private String receivePartyRole;
/**
* 公众号所属当事人ID
*/
private Long sendPartyId;
/**
* 公众号所属当事人角色(CHANNEL/AGENT)
*/
private String sendPartyRole;
/**
* 微信用户
*/
private Long wechatUserId;
/**
* openId
*/
private String openId;
/**
* 昵称
*/
private String nickName;
/**
* url
*/
private String url;
/**
* 参数
*/
private Map<String, String> temParam;
/**
* 发送类型(0: 通过wechatUserId 1 :通过openId 及昵称 2.通过当事人标识)
*/
private String sendType;
/**
* 公众号标识
*/
private Long accountSettingId;
/**
* 是否为应用
*/
private Boolean isApp;
/**
* 应用类型
*/
private String appType;
/**
* 消息来源分类
*/
private String fromCategory;
public String getFromCategory() {
return fromCategory;
}
public void setFromCategory(String fromCategory) {
this.fromCategory = fromCategory;
}
public Long getAccountSettingId() {
return accountSettingId;
}
public void setAccountSettingId(Long accountSettingId) {
this.accountSettingId = accountSettingId;
}
public String getSceneCode() {
return sceneCode;
}
public void setSceneCode(String sceneCode) {
this.sceneCode = sceneCode;
}
public Long getWechatUserId() {
return wechatUserId;
}
public void setWechatUserId(Long wechatUserId) {
this.wechatUserId = wechatUserId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Map<String, String> getTemParam() {
return temParam;
}
public void setTemParam(Map<String, String> temParam) {
this.temParam = temParam;
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getSendType() {
return sendType;
}
public void setSendType(String sendType) {
this.sendType = sendType;
}
public Long getReceivePartyId() {
return receivePartyId;
}
public void setReceivePartyId(Long receivePartyId) {
this.receivePartyId = receivePartyId;
}
public String getReceivePartyRole() {
return receivePartyRole;
}
public void setReceivePartyRole(String receivePartyRole) {
this.receivePartyRole = receivePartyRole;
}
public Long getSendPartyId() {
return sendPartyId;
}
public void setSendPartyId(Long sendPartyId) {
this.sendPartyId = sendPartyId;
}
public String getSendPartyRole() {
return sendPartyRole;
}
public void setSendPartyRole(String sendPartyRole) {
this.sendPartyRole = sendPartyRole;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public Boolean getIsApp() {
return isApp;
}
public void setIsApp(Boolean isApp) {
this.isApp = isApp;
}
public String getAppType() {
return appType;
}
public void setAppType(String appType) {
this.appType = appType;
}
public List<Long> getReceiveMemberPartyIds() {
return receiveMemberPartyIds;
}
public void setReceiveMemberPartyIds(List<Long> receiveMemberPartyIds) {
this.receiveMemberPartyIds = receiveMemberPartyIds;
}
@Override
public String toString() {
return "TemplateMessageDto [sceneCode=" + sceneCode + ", receivePartyId=" + receivePartyId
+ ", receiveMemberPartyIds=" + receiveMemberPartyIds + ", receivePartyRole=" + receivePartyRole
+ ", sendPartyId=" + sendPartyId + ", sendPartyRole=" + sendPartyRole + ", wechatUserId=" + wechatUserId
+ ", openId=" + openId + ", nickName=" + nickName + ", url=" + url + ", temParam=" + temParam
+ ", sendType=" + sendType + ", accountSettingId=" + accountSettingId + ", isApp=" + isApp
+ ", appType=" + appType + "]";
}
}
......@@ -2,6 +2,7 @@ package com.pcloud.common.utils;
import java.util.List;
import com.pcloud.common.page.PageBeanNew;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
......@@ -9,56 +10,78 @@ import org.springframework.beans.BeanUtils;
import com.google.common.collect.Lists;
/**
*
*
* @author:songx
* @date:2018年8月24日,下午2:18:40
*/
public class BeanNewUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(BeanNewUtils.class);
private static final Logger LOGGER = LoggerFactory.getLogger(BeanNewUtils.class);
/**
* 实体类之间的转换
*
* @param source
* 来源
* @param clazz
* 目标对象
* @return
*/
public static <T> T copyProperties(Object source, Class<T> clazz) {
if (source == null) {
return null;
}
T t = null;
try {
t = clazz.newInstance();
} catch (Exception e) {
LOGGER.error("clazz newInstance is error:" + e.getMessage(), e);
}
BeanUtils.copyProperties(source, t);
return t;
}
/**
* 实体类之间的转换
*
* @param source 来源
* @param clazz 目标对象
* @return
*/
public static <T> T copyProperties(Object source, Class<T> clazz) {
if (source == null) {
return null;
}
T t = null;
try {
t = clazz.newInstance();
} catch (Exception e) {
LOGGER.error("clazz newInstance is error:" + e.getMessage(), e);
}
BeanUtils.copyProperties(source, t);
return t;
}
/**
* 实体类之间的转换
*
* @param sources
* 来源
* @param clazz
* 目标对象
* @return
*/
public static <T> List<T> copyProperties(List<?> sources, Class<T> clazz) {
if (ListUtils.isEmpty(sources)) {
return null;
}
List<T> results = Lists.newArrayList();
for (Object source : sources) {
results.add(copyProperties(source, clazz));
}
return results;
}
/**
* 实体类之间的转换
*
* @param sources 来源
* @param clazz 目标对象
* @return
*/
public static <T> List<T> copyProperties(List<?> sources, Class<T> clazz) {
if (ListUtils.isEmpty(sources)) {
return null;
}
List<T> results = Lists.newArrayList();
for (Object source : sources) {
results.add(copyProperties(source, clazz));
}
return results;
}
/**
* 分页结果的实体类之间的转换
*
* @param source
* @param clazz
* @param <T>
* @return
*/
public static <T> PageBeanNew<T> copyProperties(PageBeanNew<?> source, Class<T> clazz) {
if (source == null) {
return null;
}
List<?> recordList = source.getRecordList();
PageBeanNew<T> result = new PageBeanNew<T>();
result.setCurrentPage(source.getCurrentPage());
result.setNumPerPage(source.getNumPerPage());
result.setPageCount(source.getPageCount());
result.setTotalCount(source.getTotalCount());
source.setBeginPageIndex(source.getBeginPageIndex());
source.setEndPageIndex(source.getEndPageIndex());
if (ListUtils.isEmpty(recordList)) {
result.setRecordList(Lists.newArrayList());
return result;
}
result.setRecordList(copyProperties(recordList, clazz));
return result;
}
}
......@@ -20,13 +20,38 @@ import com.pcloud.common.utils.string.StringUtil;
*/
public class LocalDateUtils {
private static final DateTimeFormatter TIME = DateTimeFormatter.ofPattern("HHmmss");
private static final DateTimeFormatter SHORT_MILLISECOND = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
private static final DateTimeFormatter SHORT_DATETIME = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
private static final DateTimeFormatter DATETIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static final DateTimeFormatter SHORT_DATE = DateTimeFormatter.ofPattern("yyyyMMdd");
private static final DateTimeFormatter DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd");
/**
* 获取当前的日期字符串(yyyy-MM-dd)
*
* @return
*/
public static String getDateNow() {
return LocalDate.now().toString();
return LocalDate.now().format(DATE);
}
/**
* 获取当前的日期字符串(yyyyMMdd)
*
* @return
*/
public static String getShortDateNow() {
return LocalDate.now().format(SHORT_DATE);
}
/**
* 获取当前的时间字符串(HHmmss)
*
* @return
*/
public static String getShortTimeNow() {
return LocalDateTime.now().format(TIME);
}
/**
......@@ -35,7 +60,16 @@ public class LocalDateUtils {
* @return
*/
public static String getDateTimeNow() {
return LocalDateTime.now().withNano(0).toString().replace("T", " ");
return LocalDateTime.now().format(DATETIME);
}
/**
* 获取当前的日期字符串(yyyyMMddHHmmss)
*
* @return
*/
public static String getShortDateTimeNow() {
return LocalDateTime.now().format(SHORT_DATETIME);
}
/**
......@@ -44,8 +78,7 @@ public class LocalDateUtils {
* @return
*/
public static String getYmdhmss() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
return LocalDateTime.now().format(formatter);
return LocalDateTime.now().format(SHORT_MILLISECOND);
}
/**
......@@ -65,7 +98,10 @@ public class LocalDateUtils {
* @return
*/
public static String convertToString(LocalDateTime localDateTime) {
return localDateTime.withNano(0).toString().replace("T", " ");
if (localDateTime == null) {
return null;
}
return localDateTime.format(DATETIME);
}
/**
......
package com.pcloud.common.utils;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.MapUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.pcloud.common.page.PageBeanNew;
/**
* 返回结果工具类
*
* @author:songx
* @date:2018年8月8日,下午2:09:16
*/
public class ResultUtils {
/**
* 集合查询结果判断
*
* @param lists
* @return
*/
public static <T> List<T> list(List<T> lists) {
if (!ListUtils.isEmpty(lists)) {
return lists;
}
return Lists.newArrayList();
}
/**
* map查询结果判断
*
* @param lists
* @return
*/
public static <K, V> Map<K, V> map(Map<K, V> map) {
if (!MapUtils.isEmpty(map)) {
return map;
}
return Maps.newHashMap();
}
/**
* 分页查询结果判断
*
* @param pageBeanNew
* @return
*/
public static <T> PageBeanNew<T> pageBeanNew(PageBeanNew<T> pageBeanNew, Integer currentPage, Integer numPerPage) {
if (pageBeanNew != null) {
return pageBeanNew;
}
return new PageBeanNew<T>(currentPage, numPerPage, 0, Lists.newArrayList());
}
}
package com.pcloud.common.utils;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.MapUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.pcloud.common.page.PageBeanNew;
/**
* 返回结果工具类
*
* @author:songx
* @date:2018年8月8日,下午2:09:16
*/
public class ResultUtils {
/**
* 集合查询结果判断
*
* @param lists
* @return
*/
public static <T> List<T> list(List<T> lists) {
if (!ListUtils.isEmpty(lists)) {
return lists;
}
return Lists.newArrayList();
}
/**
* map查询结果判断
*
* @param lists
* @return
*/
public static <K, V> Map<K, V> map(Map<K, V> map) {
if (!MapUtils.isEmpty(map)) {
return map;
}
return Maps.newHashMap();
}
/**
* 分页查询结果判断
*
* @param pageBeanNew
* @return
*/
public static <T> PageBeanNew<T> pageBeanNew(PageBeanNew<T> pageBeanNew, Integer currentPage, Integer numPerPage) {
if (pageBeanNew != null) {
return pageBeanNew;
}
return new PageBeanNew<T>(currentPage, numPerPage, 0, Lists.newArrayList());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment