From 3cb2c3201aba0e97c6be7317025f22d4358e8a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B9=B3?= Date: Fri, 8 Dec 2023 12:01:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SysManageMicroserviceApplication.java | 1 - .../config/MybatisGenerator.java | 12 +- .../exception/ResultCode.java | 27 + .../sysManageMicroservice/util/DateUtils.java | 689 ++++++++++++++++++ .../util/EnumSensitiveWord.java | 33 - .../util/EnumSensitiveWordValidator.java | 64 -- .../sysManageMicroservice/web/dto/IdDTO.java | 18 + .../web/dto/PushMessageListDTO.java | 42 ++ .../web/dto/PushMessageSaveDTO.java | 28 + .../web/dto/PushMessageUpdateDTO.java | 32 + .../sysManageMicroserviceServiceImpl.java | 31 - .../service/sysManageMicroserviceService.java | 17 - .../web/vo/common/BaseListDTO.java | 103 +++ .../web/vo/common/IdListVO.java | 19 + .../web/vo/common/IdVO.java | 17 + .../web/vo/common/ListVO.java | 63 ++ src/main/resources/application-dev.yml | 52 ++ src/main/resources/application-prod.yml | 62 +- src/main/resources/application.yml | 109 +-- 19 files changed, 1100 insertions(+), 319 deletions(-) create mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/exception/ResultCode.java create mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/DateUtils.java delete mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWord.java delete mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWordValidator.java create mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/IdDTO.java create mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageListDTO.java create mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageSaveDTO.java create mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageUpdateDTO.java delete mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/impl/sysManageMicroserviceServiceImpl.java delete mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/sysManageMicroserviceService.java create mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/BaseListDTO.java create mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/IdListVO.java create mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/IdVO.java create mode 100644 src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/ListVO.java create mode 100644 src/main/resources/application-dev.yml diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/SysManageMicroserviceApplication.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/SysManageMicroserviceApplication.java index db9bdf8..b22df48 100644 --- a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/SysManageMicroserviceApplication.java +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/SysManageMicroserviceApplication.java @@ -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 { diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/MybatisGenerator.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/MybatisGenerator.java index ff16737..3a5ea57 100644 --- a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/MybatisGenerator.java +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/config/MybatisGenerator.java @@ -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()); diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/exception/ResultCode.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/exception/ResultCode.java new file mode 100644 index 0000000..b301506 --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/exception/ResultCode.java @@ -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; + } + +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/DateUtils.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/DateUtils.java new file mode 100644 index 0000000..58e0fb6 --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/DateUtils.java @@ -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); + } + + /** + * String类型时区格式字符串转Date + */ + 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 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 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; + } +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWord.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWord.java deleted file mode 100644 index 6b3df69..0000000 --- a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWord.java +++ /dev/null @@ -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[] payload() default {}; -} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWordValidator.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWordValidator.java deleted file mode 100644 index 39e9ef5..0000000 --- a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/util/EnumSensitiveWordValidator.java +++ /dev/null @@ -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 { - @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 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; - } -} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/IdDTO.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/IdDTO.java new file mode 100644 index 0000000..9b84011 --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/IdDTO.java @@ -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; +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageListDTO.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageListDTO.java new file mode 100644 index 0000000..3cdad7f --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageListDTO.java @@ -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; + +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageSaveDTO.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageSaveDTO.java new file mode 100644 index 0000000..a13098b --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageSaveDTO.java @@ -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; + +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageUpdateDTO.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageUpdateDTO.java new file mode 100644 index 0000000..b4ca51e --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dto/PushMessageUpdateDTO.java @@ -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; + +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/impl/sysManageMicroserviceServiceImpl.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/impl/sysManageMicroserviceServiceImpl.java deleted file mode 100644 index ad38a1b..0000000 --- a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/impl/sysManageMicroserviceServiceImpl.java +++ /dev/null @@ -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 getUserByIds(List userIds) { -// if (CollUtil.isEmpty(userIds)){ -// return Lists.newArrayList(); -// } -// return allianceMemberDao.getUserByIds(userIds); -// } -//} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/sysManageMicroserviceService.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/sysManageMicroserviceService.java deleted file mode 100644 index 5a63878..0000000 --- a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/sysManageMicroserviceService.java +++ /dev/null @@ -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; -// -///** -// *

-// * 联盟入会申请 服务类 -// *

-// * -// * @author cxj -// * @since 2023-10-20 -// */ -//public interface AllianceJoinApplyService extends IService { -// -// void enterprisesJoinAllianceApply(JoinAllianceDTO joinAllianceDTO); -//} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/BaseListDTO.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/BaseListDTO.java new file mode 100644 index 0000000..0f4e0b4 --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/BaseListDTO.java @@ -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 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 getSortParam() { + if (ObjectUtil.isNull(sortParam)){ + sortParam = Maps.newHashMap(); + } + return sortParam; + } + + public void setSortParam(Map sortParam) { + this.sortParam = sortParam; + } +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/IdListVO.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/IdListVO.java new file mode 100644 index 0000000..4bb44bf --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/IdListVO.java @@ -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 id; +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/IdVO.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/IdVO.java new file mode 100644 index 0000000..20db8ff --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/IdVO.java @@ -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; +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/ListVO.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/ListVO.java new file mode 100644 index 0000000..87d2820 --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/common/ListVO.java @@ -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 { + + public ListVO() { + } + @ApiModelProperty(value = "当前页") + private Integer pageNum; + + @ApiModelProperty(value = "总记录数") + private Long total; + + @ApiModelProperty(value = "数据集") + private List list; + + public ListVO(List arr) { + this.pageNum = 1; + this.list = arr; + this.total = (long)arr.size(); + } + + public ListVO(List arr, Long total) { + this.pageNum = 1; + this.list = arr; + this.total = total; + } + + public ListVO(List 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 getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..9dd6e32 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -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 + diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index c7cf983..40f6cba 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -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 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9105191..3d7808a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -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