Commit 0dd1527b by songxiang

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

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