Commit 0dd1527b by songxiang

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

parent 8b4e8aee
......@@ -19,8 +19,7 @@ public interface BaseDao<T> {
/**
* 根据实体对象新增记录.
*
* @param entity
* .
* @param entity .
* @return id .
*/
long insert(T entity);
......@@ -28,8 +27,7 @@ public interface BaseDao<T> {
/**
* 批量保存对象.
*
* @param entity
* .
* @param entity .
* @return id .
*/
long insert(List<T> list);
......@@ -37,8 +35,7 @@ public interface BaseDao<T> {
/**
* 更新实体对应的记录.
*
* @param entity
* .
* @param entity .
* @return
*/
long update(T entity);
......@@ -53,10 +50,19 @@ public interface BaseDao<T> {
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);
......@@ -64,8 +70,7 @@ public interface BaseDao<T> {
/**
* 根据ID查找记录.
*
* @param id
* .
* @param id .
* @return entity .
*/
T getById(long id);
......@@ -73,8 +78,7 @@ public interface BaseDao<T> {
/**
* 根据ID删除记录.
*
* @param id
* .
* @param id .
* @return
*/
long deleteById(long id);
......@@ -82,10 +86,8 @@ public interface BaseDao<T> {
/**
* 分页查询 .
*
* @param pageParam
* 分页参数.
* @param paramMap
* 业务条件查询参数.
* @param pageParam 分页参数.
* @param paramMap 业务条件查询参数.
* @return
*/
PageBean listPage(PageParam pageParam, Map<String, Object> paramMap);
......
......@@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.pcloud.common.utils.string.StringUtil;
import org.apache.ibatis.jdbc.SqlRunner;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
......@@ -118,6 +119,27 @@ public abstract class BaseDaoImpl<T extends BaseEntity> implements BaseDao<T> {
return result;
}
public long update(T t, String sqlId, String errorMessage) {
if (t == null)
throw new RuntimeException("T is null");
int result = 0;
try {
result = sqlSessionTemplate.update(getStatement(sqlId), t);
} catch (Exception e) {
logger.error("update fail[" + sqlId + "]:" + e.getMessage(), e);
throw BizException.DB_DML_FAIL;
}
if (result <= 0) {
if (StringUtil.isEmpty(errorMessage))
throw BizException.DB_UPDATE_RESULT_0;
else
throw new BizException(10000, errorMessage);
}
return result;
}
public long update(List<T> list) {
if (list == null || list.size() <= 0)
......@@ -230,7 +252,7 @@ public abstract class BaseDaoImpl<T extends BaseEntity> implements BaseDao<T> {
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public List<T> listBy(Map<String, Object> paramMap) {
return (List) this.listBy(paramMap, SQL_LIST_BY);
}
......
......@@ -6,9 +6,10 @@ import java.util.Map;
/**
* 模板消息dto
*
* @author 作者 : lili
* @date 创建时间:2016年11月17日 下午12:03:48
* @version 1.0
* @date 创建时间:2016年11月17日 下午12:03:48
* @return
*/
public class TemplateMessageDto implements Serializable {
......@@ -93,6 +94,18 @@ public class TemplateMessageDto implements Serializable {
*/
private String appType;
/**
* 消息来源分类
*/
private String fromCategory;
public String getFromCategory() {
return fromCategory;
}
public void setFromCategory(String fromCategory) {
this.fromCategory = fromCategory;
}
public Long getAccountSettingId() {
return accountSettingId;
......
......@@ -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,8 +10,6 @@ import org.springframework.beans.BeanUtils;
import com.google.common.collect.Lists;
/**
*
*
* @author:songx
* @date:2018年8月24日,下午2:18:40
*/
......@@ -21,10 +20,8 @@ public class BeanNewUtils {
/**
* 实体类之间的转换
*
* @param source
* 来源
* @param clazz
* 目标对象
* @param source 来源
* @param clazz 目标对象
* @return
*/
public static <T> T copyProperties(Object source, Class<T> clazz) {
......@@ -44,10 +41,8 @@ public class BeanNewUtils {
/**
* 实体类之间的转换
*
* @param sources
* 来源
* @param clazz
* 目标对象
* @param sources 来源
* @param clazz 目标对象
* @return
*/
public static <T> List<T> copyProperties(List<?> sources, Class<T> clazz) {
......@@ -61,4 +56,32 @@ public class BeanNewUtils {
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);
}
/**
......
......@@ -20,6 +20,7 @@ import com.pcloud.common.exceptions.BizException;
* @创建时间:2016年3月10日,上午11:49:07 @版本:1.0
*/
public class StringUtil extends StringUtilParent {
/**
* 判断字符串是否为空
*
......@@ -51,8 +52,7 @@ public class StringUtil extends StringUtilParent {
/**
* 判断字符串是否为空(自动截取首尾空白)
*
* @param str
* 源字符串
* @param str 源字符串
* @return
*/
public static boolean isEmpty(String str) {
......@@ -62,10 +62,8 @@ public class StringUtil extends StringUtilParent {
/**
* 判断字符串是否为空
*
* @param str
* 源字符串
* @param trim
* 是否截取首尾空白
* @param str 源字符串
* @param trim 是否截取首尾空白
* @return
*/
public static boolean isEmpty(String str, boolean trim) {
......@@ -83,12 +81,10 @@ public class StringUtil extends StringUtilParent {
}
/**
* @param str
* the string need to be parsed
* @param delim
* the delimiter to seperate created by zqf at 6/1/2013
* @param str the string need to be parsed
* @param delim the delimiter to seperate created by zqf at 6/1/2013
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public static String[] parseToArray(String str, String delim) {
ArrayList arr = new ArrayList();
StringTokenizer st = new StringTokenizer(str, delim);
......@@ -105,12 +101,9 @@ public class StringUtil extends StringUtilParent {
/**
* replace a old substring with rep in str
*
* @param str
* the string need to be replaced
* @param old
* the string need to be removed
* @param rep
* the string to be inserted
* @param str the string need to be replaced
* @param old the string need to be removed
* @param rep the string to be inserted
* @return string replaced
*/
public static String replace(String str, String old, String rep) {
......@@ -165,12 +158,9 @@ public class StringUtil extends StringUtilParent {
/**
* 用于字符串替换
*
* @param target
* 目标对象 需要替换的字符串
* @param replacement
* 要替换的字符串
* @param value
* 替换的值
* @param target 目标对象 需要替换的字符串
* @param replacement 要替换的字符串
* @param value 替换的值
* @return
*/
public static String replacement(String target, String replacement, String value) {
......@@ -225,8 +215,8 @@ public class StringUtil extends StringUtilParent {
}
/**
* @description 获取当前服务器日期
* @return
* @description 获取当前服务器日期
*/
public static String getCurrdate(String formatStr) {
Calendar cal = Calendar.getInstance();
......@@ -274,11 +264,24 @@ public class StringUtil extends StringUtilParent {
return Integer.valueOf(String.valueOf(value));
}
/**
* 将Object值转换成String类型
*
* @param value
* @return
*/
public static String getByObj(Object value) {
if (value == null) {
return null;
}
return value.toString();
}
/**
* 解析字符串 ---> 去掉字符串中回车、换行、空格
*
* @param str
* 被解析字符串
* @param str 被解析字符串
* @return String 解析后的字符串
*/
public static String parse(String str) {
......@@ -344,13 +347,9 @@ public class StringUtil extends StringUtilParent {
}
/**
*
* @param initCode
* 初始化编码
* @param length
* 需要生成编码长度
* @param ind
* 地增量
* @param initCode 初始化编码
* @param length 需要生成编码长度
* @param ind 地增量
* @return 递增后的编码
*/
public static String getNextCode(String initCode, int length, int ind) {
......@@ -414,8 +413,7 @@ public class StringUtil extends StringUtilParent {
/**
* 中文数字转换为阿拉伯数
*
* @param String
* s
* @param String s
*/
public static int cnNumToInt(String s) {
int result = 0;
......@@ -520,9 +518,7 @@ public class StringUtil extends StringUtilParent {
}
/**
*
* @param obj
* 传数值类型的obj
* @param obj 传数值类型的obj
* @param format
* @return
*/
......@@ -534,9 +530,7 @@ public class StringUtil extends StringUtilParent {
}
/**
*
* @param obj
* 传数值类型的obj
* @param obj 传数值类型的obj
* @param format
* @return
*/
......
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