系统消息接口

dev
张平 2023-12-08 12:01:03 +08:00
parent 78430643d3
commit 3cb2c3201a
19 changed files with 1100 additions and 319 deletions

View File

@ -6,7 +6,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@MapperScan(basePackages ="com.jinhaiqimeng.sysManageMicroservice.web.dao")
@EnableFeignClients(basePackages= "com.jinhaiqimeng.sysManageMicroservice.feign")
@SpringBootApplication
public class SysManageMicroserviceApplication {

View File

@ -24,9 +24,9 @@ import java.util.Scanner;
public class MybatisGenerator {
private static final String MYSQL_URL ="jdbc:mysql://120.46.194.248:13306/jinhaiqimengdb?useSSL=false";
private static final String MYSQL_DRIVE ="com.mysql.jdbc.Driver";
private static final String MYSQL_U ="orgMicroservice_user";
private static final String MYSQL_P ="!XkCEn#PWFcPq$hy";
private static final String MYSQL_DRIVE ="com.mysql.cj.jdbc.Driver";
private static final String MYSQL_U ="sysManageMicroservice_user";
private static final String MYSQL_P ="pEqzVsA$whvE";
/**
@ -57,7 +57,7 @@ public class MybatisGenerator {
GlobalConfig gc = new GlobalConfig();
final String projectPath = System.getProperty("user.dir");
gc.setOutputDir(projectPath + "/src/main/java");
gc.setAuthor("cxj");
gc.setAuthor("zp");
gc.setOpen(false);
gc.setServiceName("%sService");// service 命名方式
gc.setServiceImplName("%sServiceImpl");// service impl 命名方式
@ -85,7 +85,7 @@ public class MybatisGenerator {
// 包配置
PackageConfig pc = new PackageConfig();
//pc.setModuleName(scanner("模块名"));
pc.setParent("com.jinhaiqimeng.orgMicroservice.web");
pc.setParent("com.jinhaiqimeng.sysManageMicroservice.web");
pc.setEntity("entity");
pc.setService("service");
pc.setServiceImpl("service.impl");
@ -133,7 +133,7 @@ public class MybatisGenerator {
strategy.setInclude(scanner("表名"));
strategy.setControllerMappingHyphenStyle(true);
strategy.setEntityLombokModel(true);
strategy.setTablePrefix("t_org_microservice");
strategy.setTablePrefix("t_sysmanage_microservice");
strategy.setFieldPrefix("f_");
mpg.setStrategy(strategy);
mpg.setTemplateEngine(new FreemarkerTemplateEngine());

View File

@ -0,0 +1,27 @@
package com.jinhaiqimeng.sysManageMicroservice.exception;
/**
*
*/
public enum ResultCode {
SUCCESS(0,"成功"),
FAIL(1,"失败");
private int code;
private String info;
ResultCode(int code, String info) {
this.code = code;
this.info = info;
}
public int getCode() {
return code;
}
public String getInfo() {
return info;
}
}

View File

@ -0,0 +1,689 @@
package com.jinhaiqimeng.sysManageMicroservice.util;
import cn.hutool.core.date.DateException;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import com.jinhaiqimeng.sysManageMicroservice.exception.CommonException;
import com.jinhaiqimeng.sysManageMicroservice.exception.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.*;
/**
* , org.apache.commons.lang.time.DateUtils
*/
@Slf4j
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
//7天换算秒
public static final BigDecimal SECOND = new BigDecimal(60*60*24*7);
//30天换算分钟
public static final BigDecimal MINUTE = new BigDecimal(60*24*30);
//一年换算小时
public static final BigDecimal HOUR = new BigDecimal(24*30*12);
/**
* yyyy-MM-dd
*/
private static final String DATE_PATTERN = "^((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29))$";
private static String[] parsePatterns = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy", "yyyy-MM-dd HH",
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM", "yyyy-MM-dd'T'HH:mm:ss.SSS Z", "yyyy-MM-dd'T'HH:mm:ss",
"yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS+Z","yyyy-MM-dd'T'HH:mm:ss.S'Z'", "yyyy-MM-dd'T'HH:mm:ss'Z'"
};
/**
* yyyy-MM-dd
*/
public static String getDate() {
return getDate("yyyy-MM-dd");
}
/**
* yyyy-MM-dd pattern"yyyy-MM-dd" "HH:mm:ss" "E"
*/
public static String getDate(String pattern) {
return DateFormatUtils.format(new Date(), pattern);
}
/**
* yyyy-MM-dd pattern"yyyy-MM-dd" "HH:mm:ss" "E"
*/
public static String formatDate(Date date, Object... pattern) {
String formatDate = null;
if (pattern != null && pattern.length > 0) {
formatDate = DateFormatUtils.format(date, pattern[0].toString());
} else {
formatDate = DateFormatUtils.format(date, "yyyy-MM-dd");
}
return formatDate;
}
/**
* yyyy-MM-dd HH:mm:ss
*/
public static String formatDateTime(Date date) {
return formatDate(date, "yyyy-MM-dd HH:mm:ss");
}
/**
* HH:mm:ss
*/
public static String getTime() {
return formatDate(new Date(), "HH:mm:ss");
}
/**
* yyyy-MM-dd HH:mm:ss
*/
public static String getDateTime() {
return formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
}
/**
* yyyy
*/
public static String getYear() {
return formatDate(new Date(), "yyyy");
}
/**
* MM
*/
public static String getMonth() {
return formatDate(new Date(), "MM");
}
/**
* dd
*/
public static String getDay() {
return formatDate(new Date(), "dd");
}
/**
* E
*/
public static String getWeek() {
return formatDate(new Date(), "E");
}
/**
*
* { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm",
* "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm",
* "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm" }
*/
public static Date parseDate(Object str) {
if (str == null) {
return null;
}
try {
return parseDate(str.toString(), parsePatterns);
} catch (ParseException e) {
return null;
}
}
public static Date strToDate(String strDate, String pattern) {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
/**
*
*
* @param date
* @return
*/
public static long pastDays(Date date) {
long t = System.currentTimeMillis() - date.getTime();
return t / (24 * 60 * 60 * 1000);
}
/**
*
*
* @param date
* @return
*/
public static long pastHour(Date date) {
long t = System.currentTimeMillis() - date.getTime();
return t / (60 * 60 * 1000);
}
/**
*
*
* @param date
* @return
*/
public static long pastMinutes(Date date) {
long t = System.currentTimeMillis() - date.getTime();
return t / (60 * 1000);
}
/**
* ,::.
*
* @param timeMillis
* @return
*/
public static String formatDateTime(long timeMillis) {
long day = timeMillis / (24 * 60 * 60 * 1000);
long hour = (timeMillis / (60 * 60 * 1000) - day * 24);
long min = ((timeMillis / (60 * 1000)) - day * 24 * 60 - hour * 60);
long s = (timeMillis / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
long sss = (timeMillis - day * 24 * 60 * 60 * 1000 - hour * 60 * 60 * 1000 - min * 60 * 1000 - s * 1000);
return (day > 0 ? day + "," : "") + hour + ":" + min + ":" + s + "." + sss;
}
/**
*
*
* @param before
* @param after
* @return
*/
public static double getDistanceOfTwoDate(Date before, Date after) {
long beforeTime = before.getTime();
long afterTime = after.getTime();
return (double) (afterTime - beforeTime) / (1000 * 60 * 60 * 24);
}
/**
* StringDate
*/
public static Date StringToDate(String timeStr) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); //yyyy-MM-dd'T'HH:mm:ss.SSSZ
Date date = null;
try {
date = df.parse(timeStr);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
*
*
* @return
*/
public static String getWebsiteDatetime(String pattern) {
String webUrl = "http://www.baidu.com";//百度
//String webUrl = "http://www.taobao.com";//淘宝
//String webUrl = "http://www.ntsc.ac.cn";//中国科学院国家授时中心
//String webUrl = "http://www.360.cn";//360
//String webUrl = "http://www.beijing-time.org";//beijing-time
try {
URL url = new URL(webUrl);// 取得资源对象
URLConnection uc = url.openConnection();// 生成连接对象
uc.connect();// 发出连接
long ld = uc.getDate();// 读取网站日期时间
Date date = new Date(ld);// 转换为标准时间对象
SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.CHINA);// 输出北京时间
return sdf.format(date);
} catch (MalformedURLException e) {
log.error("读取网络时间错误", e);
} catch (IOException e) {
log.error("传输数据错误", e);
}
return null;
}
/**
*
*
* @return
*/
public static String getLostDayLater() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();//日历对象
calendar.setTime(new Date());//设置当前日期
calendar.add(Calendar.DAY_OF_MONTH, -1);//天数-1
return format.format(calendar.getTime());
}
/**
*
*
* @param type
* @return
*/
public static String getStartDateByType(String type) {
SimpleDateFormat format = null;
Calendar calendar = Calendar.getInstance(); //日历对象
String startDate = "";
switch (type) {
case "0":
//;日统计 本月初
format = new SimpleDateFormat("yyyy-MM-dd");
calendar.add(Calendar.MONTH, 0);
calendar.set(Calendar.DAY_OF_MONTH, 1);
startDate = format.format(calendar.getTime());
break;
case "1":
//月统计 本年
int year = calendar.get(Calendar.YEAR);
startDate = year + "-01";
break;
default:
}
return startDate;
}
/**
*
*
* @param type
* @return
*/
public static String getEndDateByType(String type) {
SimpleDateFormat format = null;
Calendar calendar = Calendar.getInstance();//日历对象
String endDate = "";
switch (type) {
case "0":
//;日统计 本月末
format = new SimpleDateFormat("yyyy-MM-dd");
calendar.add(Calendar.MONTH, 1);
calendar.set(Calendar.DAY_OF_MONTH, 0);
endDate = format.format(calendar.getTime());
break;
case "1":
//月统计 本年
int year = calendar.get(Calendar.YEAR);
endDate = year + "-12";
break;
default:
}
return endDate;
}
/**
* @description:
* @author chaixueteng
* @date 2019-09-12 15:12
*/
public static String JudgmentDay(Date date) {
Calendar pre = Calendar.getInstance();
Date predate = new Date(System.currentTimeMillis());
pre.setTime(predate);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
if (cal.get(Calendar.YEAR) == (pre.get(Calendar.YEAR))) {
int diffDay = cal.get(Calendar.DAY_OF_YEAR)
- pre.get(Calendar.DAY_OF_YEAR);
switch (diffDay) {
case -1: {
return "昨天 " + formatDate(date, "HH:mm");
}
case 0: {
return "今天 " + formatDate(date, "HH:mm");
}
default:
}
}
return formatDate(date, "yyyy-MM-dd HH:mm");
}
public static String getStringDateFormatter(Date date, String format) {
SimpleDateFormat formatter = new SimpleDateFormat(format);
String dateString = formatter.format(date);
return dateString;
}
/**
*
*/
public static String getStringDateFormatter(String date, String oldFormat, String newFormat) {
if (StrUtil.isBlank(date)){
return date;
}
SimpleDateFormat oldformatter = new SimpleDateFormat(oldFormat);
SimpleDateFormat newformatter = new SimpleDateFormat(newFormat);
Date parse = null;
try {
parse = oldformatter.parse(date);
} catch (ParseException e) {
log.error("时间转换错误", e);
}
return newformatter.format(parse);
}
/**
* yyyy-MM-dd pattern"yyyy-MM-dd" "HH:mm:ss" "E"
*/
public static long getTimeMillis() {
return System.currentTimeMillis() / 1000;
}
public static long strToTimeMillis(String strDate, String pattern) {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate.getTime() / 1000;
}
/**
* unix
*/
public static String TimeStampDate(Long timestamp, String formats) {
if (StringUtils.isEmpty(formats)) {
formats = "yyyy-MM-dd HH:mm:ss";
}
if (null == timestamp){
return "";
}
String date = new SimpleDateFormat(formats, Locale.CHINA).format(new Date(timestamp * 1000));
return date;
}
/**
* unix
*/
public static String timeMsStampDate(long timestamp, String formats) {
if (StringUtils.isEmpty(formats)) {
formats = "yyyy-MM-dd HH:mm:ss";
}
String date = new SimpleDateFormat(formats, Locale.CHINA).format(new Date(timestamp));
return date;
}
/**
* unix
*/
public static Long stringToUnix(String date) {
if (StringUtils.isBlank(date)) {
return null;
}
Date date1 = parseDate(date);
if (null == date1){
return null;
}
return date1.getTime() / 1000;
}
/**
* influxdb
*/
public static String paseInfluxdbTime(String timeStr, String formats) {
if (StringUtils.isEmpty(formats)) {
formats = "yyyy-MM-dd HH:mm:ss";
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); //yyyy-MM-dd'T'HH:mm:ss.SSSZ
Date date = null;
try {
date = df.parse(timeStr);
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat Time3 = new SimpleDateFormat(formats);
return Time3.format(date);
}
public static Map<String, BigDecimal> getDatePoor(Date endDate, Date nowDate) {
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
long ns = 1000;
// 获得两个时间的毫秒时间差异
BigDecimal time = new BigDecimal(endDate.getTime()).subtract(new BigDecimal(nowDate.getTime()));
//换算成秒
BigDecimal sec = time.divide(new BigDecimal(ns));
//换算成分钟
BigDecimal min = time.divide(new BigDecimal(nm));
//换算成小时
BigDecimal hour = time.divide(new BigDecimal(nh));
//换算成天
BigDecimal day = time.divide(new BigDecimal(nd));
Map<String, BigDecimal> map = new HashMap<>();
map.put("sec",sec);
map.put("min",min);
map.put("hour",hour);
map.put("day",day);
return map;
}
/**
* @param timeStr
* @return java.lang.String
* @Description influxdb
* @Date 2020/3/20 19:11
**/
public static String paseInfluxdbDate(String timeStr) {
if (StringUtils.isBlank(timeStr)) {
return timeStr;
}
Date date = parseDate(timeStr);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.HOUR_OF_DAY, -8);
Date calTime = cal.getTime();
return formatDate(calTime, "yyyy-MM-dd HH:mm:ss");
}
/**
*
*/
public static int getHour(String timeStr) {
Date influxdbDate = null;
try {
influxdbDate = parseDate(timeStr, "yyyy-MM-dd HH:mm:ss");
} catch (ParseException e) {
log.error("转换时间错误:{} - {}", timeStr, e.toString());
}
Calendar cal = Calendar.getInstance();
cal.setTime(influxdbDate);
return cal.get(Calendar.HOUR_OF_DAY);
}
/**
*
*/
public static int getInfluxdbHour(String timeStr) {
Calendar influxdbDate = getInfluxdbDate(timeStr);
return influxdbDate.get(Calendar.HOUR_OF_DAY);
}
/**
*
*/
public static int getInfluxdbDay(String timeStr) {
Calendar influxdbDate = getInfluxdbDate(timeStr);
return influxdbDate.get(Calendar.DATE) + 1;
}
/**
*
*/
public static int getInfluxdbMonth(String timeStr) {
Calendar influxdbDate = getInfluxdbDate(timeStr);
return influxdbDate.get(Calendar.MONTH);
}
/**
*
*/
public static long getInfluxdbUnix(String timeStr) {
Calendar influxdbDate = getInfluxdbDate(timeStr);
return influxdbDate.getTime().getTime() / 1000;
}
public static LocalDateTime getLocalDateTime(String timeStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime localDateTime = LocalDateTime.parse(timeStr, formatter);
return localDateTime;
}
/**
*
*/
public static Calendar getInfluxdbDate(String timeStr) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); //yyyy-MM-dd'T'HH:mm:ss.SSSZ
Date date = null;
try {
date = df.parse(timeStr);
} catch (ParseException e) {
log.error("转换influxdb时间错误{} - {}", timeStr, e.toString());
}
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal;
}
public static String getStartDateByQueryType(Integer queryType, String queryDate) {
Date date = strToDate(queryDate, "yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.setTime(date);
//日设置起止时间
cal.set(Calendar.HOUR_OF_DAY, 00);
cal.set(Calendar.MINUTE, 00);
cal.set(Calendar.SECOND, 00);
//月设置起止时间 2020-04-01
if (queryType != null && queryType.intValue() == 1) {
cal.set(Calendar.DAY_OF_MONTH, 1);
}
//年设置起止时间
if (queryType != null && queryType.intValue() == 2) {
cal.set(Calendar.MONTH, 0);//从0开始0表是1月1表示知2月依次类推道
cal.set(Calendar.DAY_OF_MONTH, 1);
}
return formatDate(cal.getTime(), "yyyy-MM-dd HH:mm:ss");
}
public static String getEndDateByQueryType(Integer queryType, String queryDate) {
Date date = strToDate(queryDate, "yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.setTime(date);
//日设置起止时间
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
//月设置起止时间 2020-04-01
if (queryType != null && queryType.intValue() == 1) {
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.add(Calendar.MONTH, 1);/*将本月+1变成2017年7月1日10:31:28*/
cal.add(Calendar.DAY_OF_MONTH, -1);
}
//年设置起止时间
if (queryType != null && queryType.intValue() == 2) {
cal.set(Calendar.MONTH, 11);//从0开始0表是1月1表示知2月依次类推道
cal.set(Calendar.DAY_OF_MONTH, 31);
}
return formatDate(cal.getTime(), "yyyy-MM-dd HH:mm:ss");
}
public static String setDateHour(Integer hour, String strDate) {
Date date = strToDate(strDate, "yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.setTime(date);
//日设置起止时间
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, 00);
cal.set(Calendar.SECOND, 00);
return formatDate(cal.getTime(), "yyyy-MM-dd'T'HH:mm:ss");
}
/**
* @param
* @return java.lang.String
* @Description
* @Date 2020/4/26 16:11
**/
public static String yesterday() {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, -24);
String yesterdayDate = dateFormat.format(calendar.getTime());
return yesterdayDate;
}
/**
*
*
* @param past
* @return
*/
public static Date getPastDate(int past) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
calendar.set(Calendar.HOUR_OF_DAY, 00);
calendar.set(Calendar.MINUTE, 00);
calendar.set(Calendar.SECOND, 00);
Date today = calendar.getTime();
return today;
}
/**
* ,
*
* @param startTime , 00:00:00
* @param begin true false
* @return
*/
public static String strOfDay(String startTime,boolean begin) {
if(StrUtil.isBlank(startTime)){
return "";
}
boolean flag = false;
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
DateUtil.parse(startTime, formatter);
} catch (DateTimeParseException e) {
flag = true;
}
if (flag) {
//判断日期是否符合yyyy-MM-dd
boolean match = ReUtil.isMatch(DATE_PATTERN, startTime);
if (!match) {
throw new CommonException(ResultCode.FAIL.getCode(), "时间格式不正确!");
}
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault());
LocalDate localDate = LocalDate.parse(startTime,formatter);
Instant instant = localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
Date date = Date.from(instant);
Date ofDay;
if(begin){
ofDay = DateUtil.beginOfDay(date);
}else{
ofDay = DateUtil.endOfDay(date);
}
startTime = DateUtil.format(ofDay, "yyyy-MM-dd HH:mm:ss");
} catch (DateTimeParseException e) {
throw new CommonException(ResultCode.FAIL.getCode(), "时间格式不正确!");
} catch (DateException e){
throw new CommonException(ResultCode.FAIL.getCode(), "时间格式不正确!");
}
}
return startTime;
}
}

View File

@ -1,33 +0,0 @@
package com.jinhaiqimeng.sysManageMicroservice.util;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* @author cxt
* @date 2023-10-31 8:38
*/
@Target({FIELD})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {EnumSensitiveWordValidator.class})
public @interface EnumSensitiveWord {
// 默认错误消息
String message() default "必须为指定值";
String value() default "";
//1 匹配敏感词,错误信息会返回敏感词信息 2:包含敏感词
int type() default 2;
// 分组
Class<?>[] groups() default {};
// 负载
Class<? extends Payload>[] payload() default {};
}

View File

@ -1,64 +0,0 @@
package com.jinhaiqimeng.sysManageMicroservice.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.jinhaiqimeng.sysManageMicroservice.result.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* @author cxt
* @date 2023-10-19 13:50
*/
@Component
@Slf4j
public class EnumSensitiveWordValidator implements ConstraintValidator<EnumSensitiveWord, String> {
@Autowired
ContentAuditingMicroservice contentAuditingMicroservice;
private int type;
@Override
public void initialize(EnumSensitiveWord constraintAnnotation) {
this.type = constraintAnnotation.type();
}
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
if (StrUtil.isBlank(value)){
return true;
}
PartMatchDTO partMatchDTO = new PartMatchDTO();
partMatchDTO.setContent(value);
partMatchDTO.setPartMatch(false);
if (1 == type){
ResponseResult<SensitiveWordsVO> responseResult = contentAuditingMicroservice.matchSensitiveWord(partMatchDTO);
if (responseResult.isFail()){
log.error("调用敏感词服务失败!"+responseResult.getMsg());
return true;
} else {
SensitiveWordsVO data1 = responseResult.getData();
if (CollUtil.isEmpty(data1.getSensitiveWords())){
return true;
}
context.disableDefaultConstraintViolation();//禁用默认的message的值
context.buildConstraintViolationWithTemplate("文本包含敏感词为:"+ JSON.toJSONString(data1.getSensitiveWords())).addConstraintViolation();
return false;
}
} else if (2 == type){
ResponseResult responseResult = contentAuditingMicroservice.containsSensitiveWord(partMatchDTO);
if (responseResult.isFail()){
log.error("调用敏感词服务失败!"+responseResult.getMsg());
return true;
} else {
boolean data1 = (boolean)responseResult.getData();
return !data1;
}
}
return false;
}
}

View File

@ -0,0 +1,18 @@
package com.jinhaiqimeng.sysManageMicroservice.web.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author cxt
* @date 2023-10-20 8:52
*/
@Data
@ApiModel(value = "IdDTO",description = "主键DTO")
public class IdDTO{
@ApiModelProperty(value = "主键")
@NotNull(message = "主键不可为空!")
private Long id;
}

View File

@ -0,0 +1,42 @@
package com.jinhaiqimeng.sysManageMicroservice.web.dto;
import com.jinhaiqimeng.sysManageMicroservice.web.vo.common.BaseListDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @author zp
* @date 2023-12-07 16:50
*/
@Data
@ApiModel(value = "PushMessageListDTO",description = "消息推送列表DTO")
public class PushMessageListDTO extends BaseListDTO implements Serializable {
@ApiModelProperty(value = "消息id")
private Long messageld;
@ApiModelProperty(value = "消息操作开始时间")
private String messageOperationStartTime;
@ApiModelProperty(value = "消息操作结束时间")
private String messageOperationEndTime;
@ApiModelProperty(value = "消息推送开始时间")
private String messagePushStartTime;
@ApiModelProperty(value = "消息推送结束时间")
private String messagePushEndTime;
@ApiModelProperty(value = "消息推送状态1已推送2末推送")
private Integer messagePushStatus;
@ApiModelProperty(value = "消息标题")
private String messageTitle;
}

View File

@ -0,0 +1,28 @@
package com.jinhaiqimeng.sysManageMicroservice.web.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.jinhaiqimeng.sysManageMicroservice.web.vo.common.BaseListDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author zp
* @date 2023-12-07 16:50
*/
@Data
@ApiModel(value = "PushMessageSaveDTO",description = "保存消息推送DTO")
public class PushMessageSaveDTO implements Serializable {
@ApiModelProperty(value = "消息标题")
private String messageTitle;
@ApiModelProperty(value = "消息描述")
private String messageDescription;
@ApiModelProperty(value = "消息推送时间")
private String messagePushTime;
}

View File

@ -0,0 +1,32 @@
package com.jinhaiqimeng.sysManageMicroservice.web.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.jinhaiqimeng.sysManageMicroservice.web.vo.common.BaseListDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author zp
* @date 2023-12-07 16:50
*/
@Data
@ApiModel(value = "PushMessageUpdateDTO",description = "更新消息推送DTO")
public class PushMessageUpdateDTO implements Serializable {
@ApiModelProperty(value = "消息id")
private Long messageld;
@ApiModelProperty(value = "消息标题")
private String messageTitle;
@ApiModelProperty(value = "消息描述")
private String messageDescription;
@ApiModelProperty(value = "消息推送时间")
private String messagePushTime;
}

View File

@ -1,31 +0,0 @@
//package com.jinhaiqimeng.sysManageMicroservice.web.service.impl;
//
//import cn.hutool.core.collection.CollUtil;
//import com.google.common.collect.Lists;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.List;
//
///**
// * @author cxt
// * @date 2023-10-26 12:34
// */
//@Service
//public class UserServiceImpl implements UserService {
// @Autowired
// AllianceMemberDao allianceMemberDao;
//
// @Override
// public UserDTO getUserById(Long userId) {
// return allianceMemberDao.getUserById(userId);
// }
//
// @Override
// public List<UserDTO> getUserByIds(List<Long> userIds) {
// if (CollUtil.isEmpty(userIds)){
// return Lists.newArrayList();
// }
// return allianceMemberDao.getUserByIds(userIds);
// }
//}

View File

@ -1,17 +0,0 @@
//package com.jinhaiqimeng.sysManageMicroservice.web.service;
//
//import com.jinhaiqimeng.sysManageMicroservice.web.dto.alliance.JoinAllianceDTO;
//import com.baomidou.mybatisplus.extension.service.IService;
//
///**
// * <p>
// * 联盟入会申请 服务类
// * </p>
// *
// * @author cxj
// * @since 2023-10-20
// */
//public interface AllianceJoinApplyService extends IService<AllianceJoinApply> {
//
// void enterprisesJoinAllianceApply(JoinAllianceDTO joinAllianceDTO);
//}

View File

@ -0,0 +1,103 @@
package com.jinhaiqimeng.sysManageMicroservice.web.vo.common;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Maps;
import com.jinhaiqimeng.sysManageMicroservice.util.SpecialReplaceUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Map;
@ApiModel(value = "列表查询基础dto")
public class BaseListDTO implements Serializable {
@ApiModelProperty(value = "当前页从1开始")
private Integer pageNum=1;
@ApiModelProperty(value = "每页条数")
private Integer pageSize=15;
@ApiModelProperty(value = "开始时间 yyyy-MM-dd HH:mm:ss")
private String startTime;
@ApiModelProperty(value = "结束时间 yyyy-MM-dd HH:mm:ss")
private String endTime;
@ApiModelProperty(value = "关键字")
private String keyword;
@ApiModelProperty(value = "是否分页")
private Boolean page;
@ApiModelProperty(value = "排序参数 key:为约定排序类型 value为:asc升序 desc降序")
private Map<String,String> sortParam;
public BaseListDTO() {
this.page = true;
}
public Integer getPageNum() {
if(pageNum==null||pageNum==0){
return 1;
}
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
if(pageSize==null||pageSize==0){
return 15;
}
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getKeyword() {
if (StrUtil.isNotBlank(keyword)){
return SpecialReplaceUtil.replace(keyword);
}
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public Boolean getPage() {
return page;
}
public void setPage(Boolean page) {
this.page = page;
}
public Map<String, String> getSortParam() {
if (ObjectUtil.isNull(sortParam)){
sortParam = Maps.newHashMap();
}
return sortParam;
}
public void setSortParam(Map<String, String> sortParam) {
this.sortParam = sortParam;
}
}

View File

@ -0,0 +1,19 @@
package com.jinhaiqimeng.sysManageMicroservice.web.vo.common;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author cxt
* @date 2023-10-16 13:26
*/
@Data
@ApiModel(value = "IdVO",description = "idVO")
public class IdListVO {
@ApiModelProperty(value = "主键")
private List<Long> id;
}

View File

@ -0,0 +1,17 @@
package com.jinhaiqimeng.sysManageMicroservice.web.vo.common;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author cxt
* @date 2023-10-16 13:26
*/
@Data
@ApiModel(value = "IdVO",description = "idVO")
public class IdVO {
@ApiModelProperty(value = "主键")
private Long id;
}

View File

@ -0,0 +1,63 @@
package com.jinhaiqimeng.sysManageMicroservice.web.vo.common;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
@ApiModel(value = "列表查询基础Vo")
public class ListVO<T> {
public ListVO() {
}
@ApiModelProperty(value = "当前页")
private Integer pageNum;
@ApiModelProperty(value = "总记录数")
private Long total;
@ApiModelProperty(value = "数据集")
private List<T> list;
public ListVO(List<T> arr) {
this.pageNum = 1;
this.list = arr;
this.total = (long)arr.size();
}
public ListVO(List<T> arr, Long total) {
this.pageNum = 1;
this.list = arr;
this.total = total;
}
public ListVO(List<T> arr, Long total, Integer pageNum){
this.pageNum = pageNum;
this.list = arr;
this.total = total;
}
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
}

View File

@ -0,0 +1,52 @@
# 应用服务 WEB 访问端口
server:
port: 8021
servlet:
context-path: /sysManageMicroservice
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
application:
name: sysManageMicroservice
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver # mysql驱动包
url: jdbc:mysql://120.46.194.248:13306/jinhaiqimengdb?useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true # 数据库名称
username: sysManageMicroservice_user
password: pEqzVsA$whvE
druid:
# 初始化大小,最小,最大
initial-size: 5
min-idle: 5
max-active: 20
# 配置获取连接等待超时的时间
max-wait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
time-between-eviction-runs-millis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
# 打开PSCache并且指定每个连接上PSCache的大小
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
# 通过connectProperties属性来打开mergeSql功能慢SQL记录
connect-properties:
druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
# 合并多个DruidDataSource的监控数据
use-global-data-source-stat: true
filters: stat,wall
logging:
config: classpath:logback-spring.xml
#mybatisPlus
mybatis-plus:
mapper-locations: classpath:mapping/*.xml #注意一定要对应mapper映射xml文件的所在路径
type-aliases-package: com.jinhaiqimeng.sysManageMicroservice.web.entity,com.jinhaiqimeng.orgMicroservice.web.dto # 注意:对应实体类的路径
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

View File

@ -1,34 +1,15 @@
# 应用服务 WEB 访问端口
server:
port: 8007
port: 8021
servlet:
context-path: /sysManageMicroservice
compression:
enabled: true
min-response-size: 1024
mime-types:
- image/png
- image/jpeg
- image/jpg
- text/html
- application/javascript
- text/css
- application/octet-stream
- application/json
spring:
jmx:
enabled: false
application:
name: sysManageMicroservice
http:
encoding:
charset: UTF-8
force: true
enabled: true
mvc:
pathmatch:
matching-strategy: ant_path_matcher
application:
name: sysManageMicroservice
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver # mysql驱动包
@ -59,43 +40,6 @@ spring:
# 合并多个DruidDataSource的监控数据
use-global-data-source-stat: true
filters: stat,wall
# redis:
# lettuce:
# pool:
# max-active: 200
# max-idle: 10
# min-idle: -1
# host: redis-6962c01f-a6ab-40c7-9ae1-6dcc29aeb6f3.cn-north-4.dcs.myhuaweicloud.com
# port: 6379
# password: juGmpEv*=p6!&*m6
# timeout: 1000
# database: 1
cloud:
sentinel:
transport:
# 控制台地址
dashboard: 127.0.0.1:8718
eager: true
# 声明式服务
feign:
# 开启okhttp客户端
okhttp:
enabled: true
# 请求与响应的压缩以提高通信效率
compression:
request:
enabled: true
min-request-size: 2048
mime-types: text/xml,application/xml,application/json
response:
enabled: true
httpclient:
enabled: false
logging:
config: classpath:logback-spring.xml

View File

@ -1,110 +1,3 @@
# 应用服务 WEB 访问端口
server:
port: 8007
servlet:
context-path: /sysManageMicroservice
encoding:
charset: UTF-8
force: true
enabled: true
compression:
enabled: true
min-response-size: 1024
mime-types:
- image/png
- image/jpeg
- image/jpg
- text/html
- application/javascript
- text/css
- application/octet-stream
- application/json
spring:
jmx:
enabled: false
# 当前环境名称(注意:不可设置为 test 它是单元测试专用的名称)
profiles:
active: prod
application:
name: sysManageMicroservice
mvc:
pathmatch:
matching-strategy: ant_path_matcher
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver # mysql驱动包
url: jdbc:mysql://120.46.194.248:13306/jinhaiqimengdb?useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true # 数据库名称
username: sysManageMicroservice_user
password: pEqzVsA$whvE
druid:
# 初始化大小,最小,最大
initial-size: 5
min-idle: 5
max-active: 20
# 配置获取连接等待超时的时间
max-wait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
time-between-eviction-runs-millis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
# 打开PSCache并且指定每个连接上PSCache的大小
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
# 通过connectProperties属性来打开mergeSql功能慢SQL记录
connect-properties:
druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
# 合并多个DruidDataSource的监控数据
use-global-data-source-stat: true
filters: stat,wall
# redis:
# lettuce:
# pool:
# max-active: 200
# max-idle: 10
# min-idle: -1
# host: 120.46.171.171
# port: 6379
# password: bcd4@g2wp*PZv#&U
# timeout: 1000
# database: 1
cloud:
sentinel:
transport:
# 控制台地址
dashboard: 127.0.0.1:8718
eager: true
# 声明式服务
feign:
# 开启okhttp客户端
okhttp:
enabled: true
# 请求与响应的压缩以提高通信效率
compression:
request:
enabled: true
min-request-size: 2048
mime-types: text/xml,application/xml,application/json
response:
enabled: true
httpclient:
enabled: false
logging:
config: classpath:logback-spring.xml
#mybatisPlus
mybatis-plus:
mapper-locations: classpath:mapping/*.xml #注意一定要对应mapper映射xml文件的所在路径
type-aliases-package: com.jinhaiqimeng.sysManageMicroservice.web.entity,com.jinhaiqimeng.orgMicroservice.web.dto # 注意:对应实体类的路径
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
active: dev