From 6a4b079181d22a54a11dfdafd5400b171a1f3fc4 Mon Sep 17 00:00:00 2001 From: lisy <java@lishouyideAir.lan> Date: 星期三, 14 六月 2023 12:11:10 +0800 Subject: [PATCH] 开始上课:用户的学员信息主页查询接口(实体类,表的工具类) --- cloud-server-account/src/main/java/com/dsh/account/util/CodeGeneration.java | 88 + cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageDiscountMapper.java | 16 cloud-server-other/src/main/java/com/dsh/other/util/DateUtil.java | 33 cloud-server-account/src/main/java/com/dsh/account/util/DateUtil.java | 39 cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/ExerciseVideo.java | 17 cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/CourseVenue.java | 37 cloud-server-course/src/main/java/com/dsh/app/service/TCourseService.java | 16 cloud-server-course/src/main/resources/mapper/TCoursePackagePaymentMapper.xml | 29 cloud-server-account/src/main/java/com/dsh/app/mapper/TAppUserMapper.java | 16 cloud-server-course/src/main/resources/mapper/TCoursePackageTypeMapper.xml | 13 cloud-server-other/pom.xml | 38 cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackagePaymentMapper.java | 16 cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageService.java | 16 cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackageType.java | 58 cloud-server-account/src/main/java/com/dsh/app/mapper/TStudentMapper.java | 16 cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuDetailsReq.java | 36 cloud-server-other/src/main/java/com/dsh/other/util/CodeGeneration.java | 88 + cloud-server-course/src/main/resources/mapper/TCoursePackageMapper.xml | 38 cloud-server-account/src/main/java/com/dsh/account/util/ToolUtil.java | 544 ++++++++ cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuPhysicalVo.java | 16 cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageDiscountService.java | 16 cloud-server-account/src/main/resources/mapper/TStudentMapper.xml | 24 cloud-server-course/src/main/java/com/dsh/course/util/DateUtil.java | 34 cloud-server-account/src/main/java/com/dsh/app/service/impl/TStudentServiceImpl.java | 20 cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageDiscountServiceImpl.java | 20 cloud-server-account/src/main/java/com/dsh/app/controller/ClassDetailsController.java | 135 + cloud-server-course/src/main/java/com/dsh/app/service/impl/TCourseServiceImpl.java | 20 cloud-server-other/src/main/resources/mapper/TImgConfigMapper.xml | 12 cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackageDiscount.java | 74 + cloud-server-course/src/main/java/com/dsh/course/util/CodeGeneration.java | 88 + cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageTypeServiceImpl.java | 20 cloud-server-account/src/main/java/com/dsh/app/feignclient/other/model/TImgConfig.java | 47 cloud-server-course/src/main/java/com/dsh/app/mapper/TCourseMapper.java | 16 cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackage.java | 158 ++ cloud-server-other/src/main/java/com/dsh/app/feignclient/ImgConfigClient.java | 14 cloud-server-account/src/main/java/com/dsh/app/feignclient/other/ImgConfigClient.java | 14 cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackagePaymentServiceImpl.java | 20 cloud-server-course/pom.xml | 39 cloud-server-account/src/main/java/com/dsh/app/entity/TAppUser.java | 142 ++ cloud-server-course/src/main/resources/mapper/TCoursePackageDiscountMapper.xml | 17 cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageTypeService.java | 16 cloud-server-account/src/main/java/com/dsh/app/entity/TStudent.java | 98 + cloud-server-account/src/main/java/com/dsh/app/service/impl/TAppUserServiceImpl.java | 56 cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuListVo.java | 30 cloud-server-course/src/main/resources/mapper/TCourseMapper.xml | 18 cloud-server-account/src/main/java/com/dsh/app/service/TStudentService.java | 16 cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/RegisteredCourse.java | 17 cloud-server-course/src/main/java/com/dsh/course/util/ToolUtil.java | 544 ++++++++ cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/WeekedCourse.java | 23 cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/ClassInfoVo.java | 60 cloud-server-other/src/main/java/com/dsh/app/service/TImgConfigService.java | 16 cloud-server-other/src/main/java/com/dsh/app/entity/TImgConfig.java | 53 cloud-server-other/src/main/java/com/dsh/other/util/ToolUtil.java | 542 +++++++ cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageTypeMapper.java | 16 cloud-server-other/src/main/java/com/dsh/app/service/impl/TImgConfigServiceImpl.java | 20 cloud-server-account/pom.xml | 37 cloud-server-account/src/main/resources/mapper/TAppUserMapper.xml | 34 cloud-server-other/src/main/java/com/dsh/app/controller/ImgConfigController.java | 45 cloud-server-other/src/main/java/com/dsh/app/mapper/TImgConfigMapper.java | 16 cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageMapper.java | 16 cloud-server-account/src/main/java/com/dsh/app/service/TAppUserService.java | 18 cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackagePaymentService.java | 16 cloud-server-course/src/main/java/com/dsh/app/entity/TCourse.java | 78 + cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackagePayment.java | 123 + cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageServiceImpl.java | 20 65 files changed, 4,028 insertions(+), 0 deletions(-) diff --git a/cloud-server-account/pom.xml b/cloud-server-account/pom.xml index bc84078..48b7de2 100644 --- a/cloud-server-account/pom.xml +++ b/cloud-server-account/pom.xml @@ -75,6 +75,43 @@ <artifactId>swagger-models</artifactId> <version>1.5.22</version> </dependency> + + <!-- mybatis generertor--> + + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatisplus-spring-boot-starter</artifactId> + <version>1.0.5</version> + </dependency> + + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus</artifactId> + <version>3.4.1</version> + </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-generate</artifactId> + <version>2.3</version> + </dependency> + <dependency> + <groupId>org.apache.velocity</groupId> + <artifactId>velocity</artifactId> + <version>1.7</version> + </dependency> + + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>2.3.30</version> + </dependency> + + <dependency> + <groupId>org.springframework.data</groupId> + <artifactId>spring-data-jpa</artifactId> + <version>1.11.4.RELEASE</version> + </dependency> + </dependencies> <build> diff --git a/cloud-server-account/src/main/java/com/dsh/account/util/CodeGeneration.java b/cloud-server-account/src/main/java/com/dsh/account/util/CodeGeneration.java new file mode 100644 index 0000000..9ab5dc2 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/util/CodeGeneration.java @@ -0,0 +1,88 @@ +package com.dsh.account.util; + +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.generator.AutoGenerator; +import com.baomidou.mybatisplus.generator.config.*; +import com.baomidou.mybatisplus.generator.config.rules.DbType; +import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; + +public class CodeGeneration { + + public static void gen(String tableName){ + + //C:\Users\linla\Desktop\project02\guns-admin + //项目目录 + ///Users/java/IdeaProjects/PlayPai_demo/cloud-server-account/src/main/java/com/dsh/app + String projectPath = "/Users/java/IdeaProjects/PlayPai_demo/cloud-server-account/src/main/java/"; //System.getProperty("user.dir"); + //String projectPath =System.getProperty("user.dir"); + AutoGenerator mpg = new AutoGenerator(); + //全局配置 + GlobalConfig gc = new GlobalConfig(); + gc.setOutputDir(projectPath ); + gc.setFileOverride(true); + gc.setActiveRecord(true);//不需要ActiveRecord特性的请改为false + gc.setEnableCache(false);//XML二级缓存 + gc.setBaseResultMap(true);//XML ResultMap + gc.setBaseColumnList(false);//XML columList + gc.setIdType(IdType.UUID); + gc.setAuthor("administrator");//作者 + gc.setOpen(false);//生成完成不打开文件夹 + + //自定义文件命名,注意%s 会自动填充表实体属性 + gc.setServiceName("%sService"); + gc.setServiceImplName("%sServiceImpl"); + gc.setMapperName("%sMapper"); + gc.setXmlName("%sMapper"); + gc.setControllerName("%sController"); + mpg.setGlobalConfig(gc); + + //数据源配置 + DataSourceConfig dsc = new DataSourceConfig(); + dsc.setDbType(DbType.MYSQL); +// dsc.setUrl("jdbc:mysql://192.168.110.80:3306/playpai_account?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8"); + dsc.setUrl("jdbc:mysql://127.0.0.1:3306/playpai_account?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8"); + dsc.setDriverName("com.mysql.cj.jdbc.Driver"); + dsc.setUsername("root"); + dsc.setPassword("earl9096"); + mpg.setDataSource(dsc); + + //数据库表配置 + StrategyConfig strategy = new StrategyConfig(); + strategy.setTablePrefix(new String[]{});//此处可以修改您的表前缀 + strategy.setNaming(NamingStrategy.underline_to_camel);//表名生成策略 + strategy.setInclude(new String[]{tableName});//需要生成的表 + strategy.setRestControllerStyle(true); + strategy.setEntityLombokModel(true); + strategy.setSuperServiceClass(null); + strategy.setSuperServiceImplClass(null); + strategy.setSuperMapperClass(null); + mpg.setStrategy(strategy); + + //模板配置 + TemplateConfig template=new TemplateConfig(); + //不生成controller + template.setController(null); + //不生成xml文件 + //template.setXml(null); + mpg.setTemplate(template); + //包配置 + PackageConfig pc = new PackageConfig(); + pc.setParent("com.dsh.app"); + pc.setEntity("entity"); + pc.setService("service"); + pc.setServiceImpl("service.impl"); + pc.setMapper("mapper"); + + pc.setXml("mapper.xml"); + +// pc.setController("controller.member"); + mpg.setPackageInfo(pc); + + //执行生成 + mpg.execute(); + } + + public static void main(String[] args) { + gen("t_app_user"); + } +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/util/DateUtil.java b/cloud-server-account/src/main/java/com/dsh/account/util/DateUtil.java index 605ec18..a546553 100644 --- a/cloud-server-account/src/main/java/com/dsh/account/util/DateUtil.java +++ b/cloud-server-account/src/main/java/com/dsh/account/util/DateUtil.java @@ -328,5 +328,44 @@ Date dt1 = rightNow.getTime(); return dt1.getTime(); } +// +// public static void main(String[] args) throws ParseException { +// String big = "1997-08-16"; +// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); +// int age = DateUtil.age(simpleDateFormat.parse(big)); +// System.out.println(age); +// } + + /** + * 计算年龄 + * @param birthDate + * @return + */ + public static int age(Date birthDate) { + // 当前日历 + Calendar nowCalendar = Calendar.getInstance(); + // 生日大于当前日期 + if (nowCalendar.before(birthDate)) { + throw new IllegalArgumentException("The birth date is before current time, it's unbelievable"); + } + // 当前年月日 + int yearNow = nowCalendar.get(Calendar.YEAR); + int monthNow = nowCalendar.get(Calendar.MONTH); + int dayNow = nowCalendar.get(Calendar.DAY_OF_MONTH); + // 出生日期年月日 + Calendar birthCalendar = Calendar.getInstance(); + birthCalendar.setTime(birthDate); + int yearBirth = birthCalendar.get(Calendar.YEAR); + int monthBirth = birthCalendar.get(Calendar.MONTH); + int dayBirth = birthCalendar.get(Calendar.DAY_OF_MONTH); + // 粗计算年龄 + int age = yearNow - yearBirth; + // 当前月份小于出生月份年龄减一 + if (monthNow < monthBirth) { age--; } + // 当前月份等于出生月份,日小于生日年龄减一 + else if (monthNow == monthBirth && dayNow < dayBirth) { age--; } + // 返回年龄值 + return age; + } } diff --git a/cloud-server-account/src/main/java/com/dsh/account/util/ToolUtil.java b/cloud-server-account/src/main/java/com/dsh/account/util/ToolUtil.java new file mode 100644 index 0000000..d88461e --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/util/ToolUtil.java @@ -0,0 +1,544 @@ +/** + * Copyright (c) 2015-2016, Chill Zhuang 庄骞 (smallchill@163.com). + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dsh.account.util; + + + + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Array; +import java.math.BigDecimal; +import java.net.URISyntaxException; +import java.util.*; +import java.util.Map.Entry; + +/** + * 高频方法集合类 + */ +public class ToolUtil { + + /** + * 获取随机位数的字符串 + * + * @author fengshuonan + * @Date 2017/8/24 14:09 + */ + public static String getRandomString(int length) { + String base = "abcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < length; i++) { + int number = random.nextInt(base.length()); + sb.append(base.charAt(number)); + } + return sb.toString(); + } + + /** + * 判断一个对象是否是时间类型 + * + * @author stylefeng + * @Date 2017/4/18 12:55 + */ + public static String dateType(Object o) { + if (o instanceof Date) { + return DateUtil.getDay((Date) o); + } else { + return o.toString(); + } + } + + /** + * 获取异常的具体信息 + * + * @author fengshuonan + * @Date 2017/3/30 9:21 + * @version 2.0 + */ + public static String getExceptionMsg(Exception e) { + StringWriter sw = new StringWriter(); + try { + e.printStackTrace(new PrintWriter(sw)); + } finally { + try { + sw.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + return sw.getBuffer().toString().replaceAll("\\$", "T"); + } + + /** + * 比较两个对象是否相等。<br> + * 相同的条件有两个,满足其一即可:<br> + * 1. obj1 == null && obj2 == null; 2. obj1.equals(obj2) + * + * @param obj1 对象1 + * @param obj2 对象2 + * @return 是否相等 + */ + public static boolean equals(Object obj1, Object obj2) { + return (obj1 != null) ? (obj1.equals(obj2)) : (obj2 == null); + } + + /** + * 计算对象长度,如果是字符串调用其length函数,集合类调用其size函数,数组调用其length属性,其他可遍历对象遍历计算长度 + * + * @param obj 被计算长度的对象 + * @return 长度 + */ + public static int length(Object obj) { + if (obj == null) { + return 0; + } + if (obj instanceof CharSequence) { + return ((CharSequence) obj).length(); + } + if (obj instanceof Collection) { + return ((Collection<?>) obj).size(); + } + if (obj instanceof Map) { + return ((Map<?, ?>) obj).size(); + } + + int count; + if (obj instanceof Iterator) { + Iterator<?> iter = (Iterator<?>) obj; + count = 0; + while (iter.hasNext()) { + count++; + iter.next(); + } + return count; + } + if (obj instanceof Enumeration) { + Enumeration<?> enumeration = (Enumeration<?>) obj; + count = 0; + while (enumeration.hasMoreElements()) { + count++; + enumeration.nextElement(); + } + return count; + } + if (obj.getClass().isArray() == true) { + return Array.getLength(obj); + } + return -1; + } + + /** + * 对象中是否包含元素 + * + * @param obj 对象 + * @param element 元素 + * @return 是否包含 + */ + public static boolean contains(Object obj, Object element) { + if (obj == null) { + return false; + } + if (obj instanceof String) { + if (element == null) { + return false; + } + return ((String) obj).contains(element.toString()); + } + if (obj instanceof Collection) { + return ((Collection<?>) obj).contains(element); + } + if (obj instanceof Map) { + return ((Map<?, ?>) obj).values().contains(element); + } + + if (obj instanceof Iterator) { + Iterator<?> iter = (Iterator<?>) obj; + while (iter.hasNext()) { + Object o = iter.next(); + if (equals(o, element)) { + return true; + } + } + return false; + } + if (obj instanceof Enumeration) { + Enumeration<?> enumeration = (Enumeration<?>) obj; + while (enumeration.hasMoreElements()) { + Object o = enumeration.nextElement(); + if (equals(o, element)) { + return true; + } + } + return false; + } + if (obj.getClass().isArray() == true) { + int len = Array.getLength(obj); + for (int i = 0; i < len; i++) { + Object o = Array.get(obj, i); + if (equals(o, element)) { + return true; + } + } + } + return false; + } + + /** + * 对象是否不为空(新增) + * + * @param o String,List,Map,Object[],int[],long[] + * @return + */ + public static boolean isNotEmpty(Object o) { + return !isEmpty(o); + } + + /** + * 对象是否为空 + * + * @param o String,List,Map,Object[],int[],long[] + * @return + */ + @SuppressWarnings("rawtypes") + public static boolean isEmpty(Object o) { + if (o == null) { + return true; + } + if (o instanceof String) { + if (o.toString().trim().equals("")) { + return true; + } + } else if (o instanceof List) { + if (((List) o).size() == 0) { + return true; + } + } else if (o instanceof Map) { + if (((Map) o).size() == 0) { + return true; + } + } else if (o instanceof Set) { + if (((Set) o).size() == 0) { + return true; + } + } else if (o instanceof Object[]) { + if (((Object[]) o).length == 0) { + return true; + } + } else if (o instanceof int[]) { + if (((int[]) o).length == 0) { + return true; + } + } else if (o instanceof long[]) { + if (((long[]) o).length == 0) { + return true; + } + } + return false; + } + + /** + * 对象组中是否存在 Empty Object + * + * @param os 对象组 + * @return + */ + public static boolean isOneEmpty(Object... os) { + for (Object o : os) { + if (isEmpty(o)) { + return true; + } + } + return false; + } + + /** + * 对象组中是否全是 Empty Object + * + * @param os + * @return + */ + public static boolean isAllEmpty(Object... os) { + for (Object o : os) { + if (!isEmpty(o)) { + return false; + } + } + return true; + } + + /** + * 是否为数字 + * + * @param obj + * @return + */ + public static boolean isNum(Object obj) { + try { + Integer.parseInt(obj.toString()); + } catch (Exception e) { + return false; + } + return true; + } + + /** + * 如果为空, 则调用默认值 + * + * @param str + * @return + */ + public static Object getValue(Object str, Object defaultValue) { + if (isEmpty(str)) { + return defaultValue; + } + return str; + } + + + /** + * 强转->string,并去掉多余空格 + * + * @param str + * @return + */ + public static String toStr(Object str) { + return toStr(str, ""); + } + + /** + * 强转->string,并去掉多余空格 + * + * @param str + * @param defaultValue + * @return + */ + public static String toStr(Object str, String defaultValue) { + if (null == str) { + return defaultValue; + } + return str.toString().trim(); + } + + /** + * 强转->int + * + * @param obj + * @return + */ +// public static int toInt(Object value) { +// return toInt(value, -1); +// } + + /** + * 强转->int + * + * @param obj + * @param defaultValue + * @return + */ +// public static int toInt(Object value, int defaultValue) { +// return Convert.toInt(value, defaultValue); +// } + + /** + * 强转->long + * + * @param obj + * @return + */ +// public static long toLong(Object value) { +// return toLong(value, -1); +// } + + /** + * 强转->long + * + * @param obj + * @param defaultValue + * @return + */ +// public static long toLong(Object value, long defaultValue) { +// return Convert.toLong(value, defaultValue); +// } +// +// public static String encodeUrl(String url) { +// return URLKit.encode(url, CharsetKit.UTF_8); +// } +// +// public static String decodeUrl(String url) { +// return URLKit.decode(url, CharsetKit.UTF_8); +// } + + /** + * map的key转为小写 + * + * @param map + * @return Map<String , Object> + */ + public static Map<String, Object> caseInsensitiveMap(Map<String, Object> map) { + Map<String, Object> tempMap = new HashMap<>(); + for (String key : map.keySet()) { + tempMap.put(key.toLowerCase(), map.get(key)); + } + return tempMap; + } + + /** + * 获取map中第一个数据值 + * + * @param <K> Key的类型 + * @param <V> Value的类型 + * @param map 数据源 + * @return 返回的值 + */ + public static <K, V> V getFirstOrNull(Map<K, V> map) { + V obj = null; + for (Entry<K, V> entry : map.entrySet()) { + obj = entry.getValue(); + if (obj != null) { + break; + } + } + return obj; + } + + /** + * 创建StringBuilder对象 + * + * @return StringBuilder对象 + */ + public static StringBuilder builder(String... strs) { + final StringBuilder sb = new StringBuilder(); + for (String str : strs) { + sb.append(str); + } + return sb; + } + + /** + * 创建StringBuilder对象 + * + * @return StringBuilder对象 + */ + public static void builder(StringBuilder sb, String... strs) { + for (String str : strs) { + sb.append(str); + } + } + + /** + * 去掉指定后缀 + * + * @param str 字符串 + * @param suffix 后缀 + * @return 切掉后的字符串,若后缀不是 suffix, 返回原字符串 + */ + public static String removeSuffix(String str, String suffix) { + if (isEmpty(str) || isEmpty(suffix)) { + return str; + } + + if (str.endsWith(suffix)) { + return str.substring(0, str.length() - suffix.length()); + } + return str; + } + + /** + * 当前时间 + * + * @author stylefeng + * @Date 2017/5/7 21:56 + */ + public static String currentTime() { + return DateUtil.getTime(); + } + + + + /** + * 判断是否是windows操作系统 + * + * @author stylefeng + * @Date 2017/5/24 22:34 + */ + public static Boolean isWinOs() { + String os = System.getProperty("os.name"); + if (os.toLowerCase().startsWith("win")) { + return true; + } else { + return false; + } + } + + /** + * 获取临时目录 + * + * @author stylefeng + * @Date 2017/5/24 22:35 + */ + public static String getTempPath() { + return System.getProperty("java.io.tmpdir"); + } + + /** + * 把一个数转化为int + * + * @author fengshuonan + * @Date 2017/11/15 下午11:10 + */ + public static Integer toInt(Object val) { + if (val instanceof Double) { + BigDecimal bigDecimal = new BigDecimal((Double) val); + return bigDecimal.intValue(); + } else { + return Integer.valueOf(val.toString()); + } + + } + + /** + * 获取项目路径 + */ + public static String getWebRootPath(String filePath) { + try { + String path = ToolUtil.class.getClassLoader().getResource("").toURI().getPath(); + path = path.replace("/WEB-INF/classes/", ""); + path = path.replace("/target/classes/", ""); + path = path.replace("file:/", ""); + if (ToolUtil.isEmpty(filePath)) { + return path; + } else { + return path + "/" + filePath; + } + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + + /** + * 获取文件后缀名 不包含点 + */ + public static String getFileSuffix(String fileWholeName) { + if (ToolUtil.isEmpty(fileWholeName)) { + return "none"; + } + int lastIndexOf = fileWholeName.lastIndexOf("."); + return fileWholeName.substring(lastIndexOf + 1); + } +} \ No newline at end of file diff --git a/cloud-server-account/src/main/java/com/dsh/app/controller/ClassDetailsController.java b/cloud-server-account/src/main/java/com/dsh/app/controller/ClassDetailsController.java new file mode 100644 index 0000000..fb537ce --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/controller/ClassDetailsController.java @@ -0,0 +1,135 @@ +package com.dsh.app.controller; + + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.dsh.account.util.DateUtil; +import com.dsh.app.entity.TStudent; +import com.dsh.app.model.vo.classDetails.classInsVo.ClassInfoVo; +import com.dsh.app.model.vo.classDetails.classInsVo.StuDetailsReq; +import com.dsh.app.model.vo.classDetails.classInsVo.StuListVo; +import com.dsh.app.model.vo.classDetails.classInsVo.StuPhysicalVo; +import com.dsh.app.service.TAppUserService; +import com.dsh.app.service.TStudentService; +import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + + +/** + * 学员上课情况 接口 + */ +@Api +@CrossOrigin +@RestController +@RequestMapping("/startCource") +public class ClassDetailsController { + + private Logger logger = LoggerFactory.getLogger("business-log"); + + @Autowired + private TStudentService istuService; + + @Autowired + private TAppUserService tappuService; + + + + @ResponseBody + @PostMapping("/stu/queryStudentData") + @ApiOperation(value = "根据登录用户ID查询学员信息", tags = {"用户——学员信息"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "用户id", name = "id", required = true, dataType = "int"), + @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ClassInfoVo queryCouponRecord(@RequestBody Integer id){ + try { + return tappuService.queryUserOfStus(id); + }catch (Exception e){ + e.printStackTrace(); + return null; + } + } + + + /** + * 获取学员测试报告 + */ + @PostMapping("/stu/queryPhysical") + public StuPhysicalVo getStuPhysicalInfo(@RequestBody Integer stuID){ + StuPhysicalVo vo = new StuPhysicalVo(); + TStudent tStudent = istuService.selectById(stuID); + vo.setBmi(tStudent.getBmi()); + vo.setUrl(tStudent.getLateralSurface()); + vo.setHeight(tStudent.getHeight()); + vo.setWeight(tStudent.getWeight()); + return vo; + } + + /** + * 添加学员信息 + */ + @PostMapping("/stu/addData") + public void addStu(@RequestBody StuDetailsReq stu){ + TStudent student = new TStudent(); + student.setAppUserId(stu.getUserID()); + student.setName(stu.getName()); + student.setHeadImg(stu.getHeadImg()); + student.setPhone(stu.getPhone()); + student.setSex(stu.getSex()); + student.setIdCard(stu.getIdCard()); + student.setBirthday(new Date(stu.getBirthday())); + student.setHeight(stu.getHeight()); + student.setWeight(stu.getWeight()); + BigDecimal bigDecimal = BigDecimal.valueOf(stu.getWeight()); + BigDecimal multiply = bigDecimal.subtract(BigDecimal.valueOf(stu.getHeight())).multiply(bigDecimal.subtract(BigDecimal.valueOf(stu.getHeight()))); + multiply.setScale(2); + student.setBmi(multiply.doubleValue()); + student.setInsertTime(new Date()); + student.setState(1); + istuService.insert(student); + } + + /** + * 该APP用户下的学员列表 + */ + @PostMapping("/stu/listOfStu") + public List<StuListVo> queryStuList(@RequestBody Integer appUserID){ + List<StuListVo> stuListVos = new ArrayList<>(); + List<TStudent> tStudents = istuService.selectList(new EntityWrapper<TStudent>() + .eq("appUserId",appUserID)); + if (tStudents.size() > 0){ + tStudents.forEach(sts -> { + StuListVo vo = new StuListVo(); + vo.setStuId(sts.getId()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + vo.setBirthday(simpleDateFormat.format(sts.getBirthday())); + vo.setStuName(sts.getName()); + vo.setStuAge(DateUtil.age(sts.getBirthday())); + vo.setStuHeight(sts.getHeight()); + vo.setStuWeight(sts.getWeight()); + vo.setIsNot(sts.getIsDefault()); + }); + } + return stuListVos; + } + + /** + * 课时详情 + */ + @PostMapping("/stu/lessonDetails") + public void coursePackageDetails(@RequestBody Integer lessonId){ + + } + + + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/entity/TAppUser.java b/cloud-server-account/src/main/java/com/dsh/app/entity/TAppUser.java new file mode 100644 index 0000000..d957625 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/entity/TAppUser.java @@ -0,0 +1,142 @@ +package com.dsh.app.entity; + +import com.baomidou.mybatisplus.enums.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableName; +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotations.Version; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * <p> + * 用户信息 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_app_user") +public class TAppUser extends Model<TAppUser> { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 编号 + */ + private String code; + /** + * 姓名 + */ + private String name; + /** + * 电话 + */ + private String phone; + /** + * 密码 + */ + private String password; + /** + * 生日 + */ + private Date birthday; + /** + * 性别(1=男,2=女) + */ + private Integer gender; + /** + * 身高 + */ + private Double height; + /** + * 体重 + */ + private Double weight; + /** + * bmi健康值 + */ + private Double bmi; + /** + * 身份证号 + */ + private String idCard; + /** + * 微信openid + */ + private String openid; + /** + * 省 + */ + private String province; + /** + * 省编号 + */ + private String provinceCode; + /** + * 市 + */ + private String city; + /** + * 市编号 + */ + private String cityCode; + /** + * 是否是年度会员(0=否,1=是) + */ + private Integer isVip; + /** + * 会员有效期 + */ + private Date vipEndTime; + /** + * 会员等级id + */ + private Integer viplevelId; + /** + * 推荐用户id + */ + private Integer referralUserId; + /** + * 销售员id + */ + private Integer salesmanUserId; + /** + * 状态(1=正常,2=冻结,3=删除) + */ + private Integer state; + /** + * 剩余积分 + */ + private Integer integral; + /** + * 玩湃币 + */ + private Integer playPaiCoins; + /** + * 用户头像 + */ + private String headImg; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/entity/TStudent.java b/cloud-server-account/src/main/java/com/dsh/app/entity/TStudent.java new file mode 100644 index 0000000..4bbdde8 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/entity/TStudent.java @@ -0,0 +1,98 @@ +package com.dsh.app.entity; + +import com.baomidou.mybatisplus.enums.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableName; +import java.io.Serializable; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * <p> + * 学员信息 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_student") +public class TStudent extends Model<TStudent> { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 用户id + */ + private Integer appUserId; + /** + * 学员姓名 + */ + private String name; + /** + * 学员电话 + */ + private String phone; + /** + * 生日 + */ + private Date birthday; + /** + * 性别(1=男,2=女) + */ + private Integer sex; + /** + * 身高 + */ + private Double height; + /** + * 体重 + */ + private Double weight; + /** + * bmi健康值 + */ + private Double bmi; + /** + * 身份证号 + */ + private String idCard; + /** + * 体侧表 + */ + private String lateralSurface; + /** + * 状态(1=正常,2=冻结,3=删除) + */ + private Integer state; + /** + * 添加时间 + */ + private Date insertTime; + /** + * 头像 + */ + private String headImg; + /** + * 是否默认 1默认 2不是默认 + */ + private Integer isDefault; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/feignclient/other/ImgConfigClient.java b/cloud-server-account/src/main/java/com/dsh/app/feignclient/other/ImgConfigClient.java new file mode 100644 index 0000000..47db28d --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/feignclient/other/ImgConfigClient.java @@ -0,0 +1,14 @@ +package com.dsh.app.feignclient.other; + +import com.dsh.app.feignclient.other.model.TImgConfig; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; + +@FeignClient(value = "mb-cloud-other") +public interface ImgConfigClient { + + @PostMapping("/imgConfig/getNoneStu") + List<TImgConfig> getNoneStuImgs(); +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/feignclient/other/model/TImgConfig.java b/cloud-server-account/src/main/java/com/dsh/app/feignclient/other/model/TImgConfig.java new file mode 100644 index 0000000..e514176 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/feignclient/other/model/TImgConfig.java @@ -0,0 +1,47 @@ +package com.dsh.app.feignclient.other.model; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * <p> + * 图片配置 + * </p> + * + * @author administrator + * @since 2023-06-13 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class TImgConfig extends Model<TImgConfig> { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 位置(1=无学员,2=成为会员,3=我的券包,4=线上商城,5=本周福利,6=今日免费) + */ + private Integer position; + /** + * 图片配置JSON + */ + private String content; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/mapper/TAppUserMapper.java b/cloud-server-account/src/main/java/com/dsh/app/mapper/TAppUserMapper.java new file mode 100644 index 0000000..6498dd7 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/mapper/TAppUserMapper.java @@ -0,0 +1,16 @@ +package com.dsh.app.mapper; + +import com.dsh.app.entity.TAppUser; +import com.baomidou.mybatisplus.mapper.BaseMapper; + +/** + * <p> + * 用户信息 Mapper 接口 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TAppUserMapper extends BaseMapper<TAppUser> { + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/mapper/TStudentMapper.java b/cloud-server-account/src/main/java/com/dsh/app/mapper/TStudentMapper.java new file mode 100644 index 0000000..2c2e23f --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/mapper/TStudentMapper.java @@ -0,0 +1,16 @@ +package com.dsh.app.mapper; + +import com.dsh.app.entity.TStudent; +import com.baomidou.mybatisplus.mapper.BaseMapper; + +/** + * <p> + * 学员信息 Mapper 接口 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TStudentMapper extends BaseMapper<TStudent> { + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/CourseVenue.java b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/CourseVenue.java new file mode 100644 index 0000000..5f3f135 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/CourseVenue.java @@ -0,0 +1,37 @@ +package com.dsh.app.model.vo.classDetails; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class CourseVenue { + + @ApiModelProperty(value = "门店名称") + private String areaName; + + @ApiModelProperty(value = "门店距离当前位置的 距离") + private String siteDistance; + + @ApiModelProperty(value = "课包列表") + private List<CouList> courses; + + @Data + static class CouList{ + + @ApiModelProperty(value = "课包ID") + Integer courseID; + + @ApiModelProperty(value = "课包名称") + String courseName; + + @ApiModelProperty(value = "时间段") + String timeStr; + + @ApiModelProperty(value = "详细说明") + String detail; + + } + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/ExerciseVideo.java b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/ExerciseVideo.java new file mode 100644 index 0000000..7eb041f --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/ExerciseVideo.java @@ -0,0 +1,17 @@ +package com.dsh.app.model.vo.classDetails; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class ExerciseVideo { + + @ApiModelProperty(value = "课后视频封面图链接") + private String videoCoverImgUrl; + + @ApiModelProperty(value = "课后视频链接") + private String videoUrl; + + @ApiModelProperty(value = "课后视频标题") + private String videoName; +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/RegisteredCourse.java b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/RegisteredCourse.java new file mode 100644 index 0000000..338b467 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/RegisteredCourse.java @@ -0,0 +1,17 @@ +package com.dsh.app.model.vo.classDetails; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class RegisteredCourse { + + @ApiModelProperty(value = "课程ID") + private Integer courseId; + + @ApiModelProperty(value = "课程名称") + private String courseName; + + + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/WeekedCourse.java b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/WeekedCourse.java new file mode 100644 index 0000000..cf0a1ea --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/WeekedCourse.java @@ -0,0 +1,23 @@ +package com.dsh.app.model.vo.classDetails; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class WeekedCourse { + + @ApiModelProperty(value = "是否为当天") + private Integer isToday; + + @ApiModelProperty(value = "星期缩写") + private String weekStr; + + @ApiModelProperty(value = "日期") + private String dayStr; + + @ApiModelProperty(value = "课包列表") + private List<CourseVenue> details; + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/ClassInfoVo.java b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/ClassInfoVo.java new file mode 100644 index 0000000..c1f8d3c --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/ClassInfoVo.java @@ -0,0 +1,60 @@ +package com.dsh.app.model.vo.classDetails.classInsVo; + + +import com.dsh.app.model.vo.classDetails.ExerciseVideo; +import com.dsh.app.model.vo.classDetails.RegisteredCourse; +import com.dsh.app.model.vo.classDetails.WeekedCourse; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class ClassInfoVo { + + @ApiModelProperty(value = "是否有学员信息 (1. 有学员信息 2.没有学员信息)") + private Integer isThere; + + @ApiModelProperty(value = "没有学员信息 对应的banner图") + private String imgs; + + @ApiModelProperty(value = "学员头像") + private String stuImg; + + @ApiModelProperty(value = "学员性别 1:男 2:女") + private Integer stuSex; + + @ApiModelProperty(value = "学员年龄") + private Integer stuAge; + + @ApiModelProperty(value = "学员名") + private String stuName; + + @ApiModelProperty(value = "身高") + private Double height; + + @ApiModelProperty(value = "体重") + private Double weight; + + @ApiModelProperty(value = "bmi指数") + private Double bmi; + + @ApiModelProperty(value = "课包-已报名课程列表") + private List<RegisteredCourse> courseList; + + @ApiModelProperty(value = "总学时数") + private Integer totalNums; + + @ApiModelProperty(value = "已扣学时数") + private Integer deductedNums; + + @ApiModelProperty(value = "剩余学时数") + private Integer remainingNums; + + @ApiModelProperty(value = "课包-本周可预约课包列表") + private List<WeekedCourse> weekCourseList; + + @ApiModelProperty(value = "课程-课后练习视频2个列表") + private List<ExerciseVideo> exerciseVideoList; + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuDetailsReq.java b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuDetailsReq.java new file mode 100644 index 0000000..5455c58 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuDetailsReq.java @@ -0,0 +1,36 @@ +package com.dsh.app.model.vo.classDetails.classInsVo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class StuDetailsReq { + + @ApiModelProperty(value = "头像") + private String headImg; + + @ApiModelProperty(value = "姓名") + private String name; + + @ApiModelProperty(value = "联系方式") + private String phone; + + @ApiModelProperty(value = "生日") + private String birthday; + + @ApiModelProperty(value = "性别 (1 男 2 女)") + private Integer sex; + + @ApiModelProperty(value = "身高") + private Double height; + + @ApiModelProperty(value = "体重") + private Double weight; + + @ApiModelProperty(value = "身份证号码") + private String idCard; + + @ApiModelProperty(value = "用户id") + private Integer userID; + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuListVo.java b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuListVo.java new file mode 100644 index 0000000..1e061d4 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuListVo.java @@ -0,0 +1,30 @@ +package com.dsh.app.model.vo.classDetails.classInsVo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class StuListVo { + + @ApiModelProperty(value = "学员id") + private Integer stuId; + + @ApiModelProperty(value = "学员姓名") + private String stuName; + + @ApiModelProperty(value = "学员年龄") + private Integer stuAge; + + @ApiModelProperty(value = "学员身高") + private Double stuHeight; + + @ApiModelProperty(value = "学员生日") + private String birthday; + + @ApiModelProperty(value = "学员体重") + private Double stuWeight; + + @ApiModelProperty(value = "是否默认(1. 是默认 2. 不是默认 )") + private Integer isNot; + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuPhysicalVo.java b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuPhysicalVo.java new file mode 100644 index 0000000..b7fa114 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/model/vo/classDetails/classInsVo/StuPhysicalVo.java @@ -0,0 +1,16 @@ +package com.dsh.app.model.vo.classDetails.classInsVo; + + +import lombok.Data; + +@Data +public class StuPhysicalVo { + + private Double height; + + private Double weight; + + private Double bmi; + + private String url; +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/service/TAppUserService.java b/cloud-server-account/src/main/java/com/dsh/app/service/TAppUserService.java new file mode 100644 index 0000000..c36ed8a --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/service/TAppUserService.java @@ -0,0 +1,18 @@ +package com.dsh.app.service; + +import com.dsh.app.entity.TAppUser; +import com.baomidou.mybatisplus.service.IService; +import com.dsh.app.model.vo.classDetails.classInsVo.ClassInfoVo; + +/** + * <p> + * 用户信息 服务类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TAppUserService extends IService<TAppUser> { + + ClassInfoVo queryUserOfStus(Integer id); +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/service/TStudentService.java b/cloud-server-account/src/main/java/com/dsh/app/service/TStudentService.java new file mode 100644 index 0000000..b118478 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/service/TStudentService.java @@ -0,0 +1,16 @@ +package com.dsh.app.service; + +import com.dsh.app.entity.TStudent; +import com.baomidou.mybatisplus.service.IService; + +/** + * <p> + * 学员信息 服务类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TStudentService extends IService<TStudent> { + +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/service/impl/TAppUserServiceImpl.java b/cloud-server-account/src/main/java/com/dsh/app/service/impl/TAppUserServiceImpl.java new file mode 100644 index 0000000..06ae43c --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/service/impl/TAppUserServiceImpl.java @@ -0,0 +1,56 @@ +package com.dsh.app.service.impl; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.dsh.app.entity.TAppUser; +import com.dsh.app.entity.TStudent; +import com.dsh.app.feignclient.other.ImgConfigClient; +import com.dsh.app.feignclient.other.model.TImgConfig; +import com.dsh.app.mapper.TAppUserMapper; +import com.dsh.app.mapper.TStudentMapper; +import com.dsh.app.model.vo.classDetails.classInsVo.ClassInfoVo; +import com.dsh.app.service.TAppUserService; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.dsh.account.util.ToolUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * <p> + * 用户信息 服务实现类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Service +public class TAppUserServiceImpl extends ServiceImpl<TAppUserMapper, TAppUser> implements TAppUserService { + + @Autowired + private TStudentMapper tsmapper; + + @Autowired + private ImgConfigClient configClient; + + @Override + public ClassInfoVo queryUserOfStus(Integer id) { + TAppUser tAppUser = this.baseMapper.selectById(id); + if (ToolUtil.isNotEmpty(tAppUser)){ + List<TStudent> tStudents = tsmapper.selectList(new EntityWrapper<TStudent>() + .eq("appUserId",tAppUser.getId()) + .eq("state",1)); + ClassInfoVo classInfoVo = new ClassInfoVo(); + if (null != tStudents){ + + }else { + classInfoVo.setIsThere(2); + List<TImgConfig> tImgConfigs = configClient.getNoneStuImgs(); + if (tImgConfigs.size() > 0){ + classInfoVo.setImgs(tImgConfigs.get(0).getContent()); + } + } + } + return null; + } +} diff --git a/cloud-server-account/src/main/java/com/dsh/app/service/impl/TStudentServiceImpl.java b/cloud-server-account/src/main/java/com/dsh/app/service/impl/TStudentServiceImpl.java new file mode 100644 index 0000000..a70a897 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/app/service/impl/TStudentServiceImpl.java @@ -0,0 +1,20 @@ +package com.dsh.app.service.impl; + +import com.dsh.app.entity.TStudent; +import com.dsh.app.mapper.TStudentMapper; +import com.dsh.app.service.TStudentService; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * <p> + * 学员信息 服务实现类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Service +public class TStudentServiceImpl extends ServiceImpl<TStudentMapper, TStudent> implements TStudentService { + +} diff --git a/cloud-server-account/src/main/resources/mapper/TAppUserMapper.xml b/cloud-server-account/src/main/resources/mapper/TAppUserMapper.xml new file mode 100644 index 0000000..fe20ba7 --- /dev/null +++ b/cloud-server-account/src/main/resources/mapper/TAppUserMapper.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dsh.app.mapper.TAppUserMapper"> + + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.dsh.app.entity.TAppUser"> + <id column="id" property="id" /> + <result column="code" property="code" /> + <result column="name" property="name" /> + <result column="phone" property="phone" /> + <result column="password" property="password" /> + <result column="birthday" property="birthday" /> + <result column="gender" property="gender" /> + <result column="height" property="height" /> + <result column="weight" property="weight" /> + <result column="bmi" property="bmi" /> + <result column="idCard" property="idCard" /> + <result column="openid" property="openid" /> + <result column="province" property="province" /> + <result column="provinceCode" property="provinceCode" /> + <result column="city" property="city" /> + <result column="cityCode" property="cityCode" /> + <result column="isVip" property="isVip" /> + <result column="vipEndTime" property="vipEndTime" /> + <result column="viplevelId" property="viplevelId" /> + <result column="referralUserId" property="referralUserId" /> + <result column="salesmanUserId" property="salesmanUserId" /> + <result column="state" property="state" /> + <result column="integral" property="integral" /> + <result column="playPaiCoins" property="playPaiCoins" /> + <result column="headImg" property="headImg" /> + </resultMap> + +</mapper> diff --git a/cloud-server-account/src/main/resources/mapper/TStudentMapper.xml b/cloud-server-account/src/main/resources/mapper/TStudentMapper.xml new file mode 100644 index 0000000..d41bb61 --- /dev/null +++ b/cloud-server-account/src/main/resources/mapper/TStudentMapper.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dsh.app.mapper.TStudentMapper"> + + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.dsh.app.entity.TStudent"> + <id column="id" property="id" /> + <result column="appUserId" property="appUserId" /> + <result column="name" property="name" /> + <result column="phone" property="phone" /> + <result column="birthday" property="birthday" /> + <result column="sex" property="sex" /> + <result column="height" property="height" /> + <result column="weight" property="weight" /> + <result column="bmi" property="bmi" /> + <result column="idCard" property="idCard" /> + <result column="lateralSurface" property="lateralSurface" /> + <result column="state" property="state" /> + <result column="insertTime" property="insertTime" /> + <result column="headImg" property="headImg" /> + <result column="isDefault" property="isDefault" /> + </resultMap> + +</mapper> diff --git a/cloud-server-course/pom.xml b/cloud-server-course/pom.xml index 29ac811..24636df 100644 --- a/cloud-server-course/pom.xml +++ b/cloud-server-course/pom.xml @@ -50,6 +50,45 @@ <artifactId>commons-beanutils</artifactId> <version>1.9.2</version> </dependency> + + + <!-- mybatis generertor--> + + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatisplus-spring-boot-starter</artifactId> + <version>1.0.5</version> + </dependency> + + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus</artifactId> + <version>3.4.1</version> + </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-generate</artifactId> + <version>2.3</version> + </dependency> + <dependency> + <groupId>org.apache.velocity</groupId> + <artifactId>velocity</artifactId> + <version>1.7</version> + </dependency> + + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>2.3.30</version> + </dependency> + + <dependency> + <groupId>org.springframework.data</groupId> + <artifactId>spring-data-jpa</artifactId> + <version>1.11.4.RELEASE</version> + </dependency> + + <dependency> <!--swagger2--> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> diff --git a/cloud-server-course/src/main/java/com/dsh/app/entity/TCourse.java b/cloud-server-course/src/main/java/com/dsh/app/entity/TCourse.java new file mode 100644 index 0000000..4c8c433 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/entity/TCourse.java @@ -0,0 +1,78 @@ +package com.dsh.app.entity; + +import com.baomidou.mybatisplus.enums.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableName; +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotations.Version; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * <p> + * 课程 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_course") +public class TCourse extends Model<TCourse> { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 课程名称 + */ + private String name; + /** + * 类型(1=课后练习,2=运动教学视频,3=器材教学视频) + */ + private Integer type; + /** + * 介绍 + */ + private String introduce; + /** + * 封面图 + */ + private String coverDrawing; + /** + * 介绍图 + */ + private String introductionDrawing; + /** + * 课程视频 + */ + private String courseVideo; + /** + * 状态(1=正常,2=冻结,3=删除) + */ + private Integer state; + /** + * 添加时间 + */ + private Date insertTime; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackage.java b/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackage.java new file mode 100644 index 0000000..0b3e1d1 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackage.java @@ -0,0 +1,158 @@ +package com.dsh.app.entity; + +import com.baomidou.mybatisplus.enums.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableName; +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotations.Version; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * <p> + * 课包 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_course_package") +public class TCoursePackage extends Model<TCoursePackage> { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 省 + */ + private String province; + /** + * 省编号 + */ + private String provinceCode; + /** + * 市 + */ + private String city; + /** + * 市编号 + */ + private String cityCode; + /** + * 门店id + */ + private Integer storeId; + /** + * 课包类型id + */ + private Integer coursePackageTypeId; + /** + * 课包名称 + */ + private String name; + /** + * 上课场地id + */ + private Integer siteId; + /** + * 教练id + */ + private Integer coachId; + /** + * 最多预约人数 + */ + private Integer maxSubscribeNumber; + /** + * 上课开始时间 + */ + private String classStartTime; + /** + * 上课结束时段 + */ + private String classEndTime; + /** + * 上课周,多个分号分隔 + */ + private String classWeeks; + /** + * 封面图 + */ + private String coverDrawing; + /** + * 详情图 + */ + private String detailDrawing; + /** + * 介绍图 + */ + private String introduceDrawing; + /** + * 排序 + */ + private Integer sort; + /** + * 支付方式(1=现金,2=玩湃币) + */ + private Integer payType; + /** + * 有效天数 + */ + private Integer validDays; + /** + * 课后练习课程id + */ + private Integer courseId; + /** + * 课后练习视频介绍 + */ + private String introduce; + /** + * 完成课后练习获取积分 + */ + private Integer integral; + /** + * 课程状态(1=未开始,2=进行中,3=已结束,4=已取消) + */ + private Integer status; + /** + * 审核状态(1=待审核,2=已同意,3=已拒绝) + */ + private Integer auditStatus; + /** + * 审核人id + */ + private Integer auditUserId; + /** + * 审核备注 + */ + private String authRemark; + /** + * 状态(1=正常,2=冻结,3=删除) + */ + private Integer state; + /** + * 添加时间 + */ + private Date insertTime; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackageDiscount.java b/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackageDiscount.java new file mode 100644 index 0000000..a166cea --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackageDiscount.java @@ -0,0 +1,74 @@ +package com.dsh.app.entity; + +import com.baomidou.mybatisplus.enums.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableName; +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotations.Version; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * <p> + * 课包折扣 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_course_package_discount") +public class TCoursePackageDiscount extends Model<TCoursePackageDiscount> { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 课包id + */ + private Integer coursePackageId; + /** + * 折扣类型(1=会员折扣,2=续课优惠,3=限时折扣,4=赠送课时) + */ + private Integer type; + /** + * 折扣优惠规则JSON + */ + private String content; + /** + * 审核状态(1=待审核,2=已通过,3=已拒绝) + */ + private Integer auditStatus; + /** + * 审核人id + */ + private Integer auditUserId; + /** + * 审核备注 + */ + private String auditRemark; + /** + * 添加时间 + */ + private Date insertTime; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackagePayment.java b/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackagePayment.java new file mode 100644 index 0000000..f518ce9 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackagePayment.java @@ -0,0 +1,123 @@ +package com.dsh.app.entity; + +import com.baomidou.mybatisplus.enums.IdType; +import java.math.BigDecimal; +import java.util.Date; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableName; +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotations.Version; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * <p> + * 用户课程包购买记录 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_course_package_payment") +public class TCoursePackagePayment extends Model<TCoursePackagePayment> { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 用户id + */ + private Integer appUserId; + /** + * 学员id + */ + private Integer studentId; + /** + * 课包id + */ + private Integer coursePackageId; + /** + * 支付方式(1=现金,2=玩湃币) + */ + private Integer payType; + /** + * 课时数 + */ + private Integer classHours; + /** + * 现金支付价格 + */ + private BigDecimal cashPayment; + /** + * 玩湃币价格 + */ + private Integer playPaiCoin; + /** + * 总课时 + */ + private Integer totalClassHours; + /** + * 剩余课时 + */ + private Integer laveClassHours; + /** + * 缺课次数 + */ + private Integer absencesNumber; + /** + * 支付用户类型(1=用户,2=管理员) + */ + private Integer payUserType; + /** + * 支付状态(1=待支付,2=已支付) + */ + private Integer payStatus; + /** + * 第三方支付流水号 + */ + private String orderNumber; + /** + * 支付用户id + */ + private Integer payUserId; + /** + * 课程状态(1=正常,2=已退课) + */ + private Integer status; + /** + * 退课时间 + */ + private Date withdrawalTime; + /** + * 退课凭证 + */ + private String certificate; + /** + * 状态(1=正常,2=冻结,3=删除) + */ + private Integer state; + /** + * 添加时间 + */ + private Date insertTime; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackageType.java b/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackageType.java new file mode 100644 index 0000000..aa9375d --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/entity/TCoursePackageType.java @@ -0,0 +1,58 @@ +package com.dsh.app.entity; + +import com.baomidou.mybatisplus.enums.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableName; +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotations.Version; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * <p> + * 课程包类型 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_course_package_type") +public class TCoursePackageType extends Model<TCoursePackageType> { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 类型名称 + */ + private String name; + /** + * 状态(1=正常,2=冻结,3=删除) + */ + private Integer state; + /** + * 添加时间 + */ + private Date insertTime; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/mapper/TCourseMapper.java b/cloud-server-course/src/main/java/com/dsh/app/mapper/TCourseMapper.java new file mode 100644 index 0000000..d99bd93 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/mapper/TCourseMapper.java @@ -0,0 +1,16 @@ +package com.dsh.app.mapper; + +import com.dsh.app.entity.TCourse; +import com.baomidou.mybatisplus.mapper.BaseMapper; + +/** + * <p> + * 课程 Mapper 接口 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TCourseMapper extends BaseMapper<TCourse> { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageDiscountMapper.java b/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageDiscountMapper.java new file mode 100644 index 0000000..fa91c27 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageDiscountMapper.java @@ -0,0 +1,16 @@ +package com.dsh.app.mapper; + +import com.dsh.app.entity.TCoursePackageDiscount; +import com.baomidou.mybatisplus.mapper.BaseMapper; + +/** + * <p> + * 课包折扣 Mapper 接口 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TCoursePackageDiscountMapper extends BaseMapper<TCoursePackageDiscount> { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageMapper.java b/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageMapper.java new file mode 100644 index 0000000..d6d1c5b --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageMapper.java @@ -0,0 +1,16 @@ +package com.dsh.app.mapper; + +import com.dsh.app.entity.TCoursePackage; +import com.baomidou.mybatisplus.mapper.BaseMapper; + +/** + * <p> + * 课包 Mapper 接口 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TCoursePackageMapper extends BaseMapper<TCoursePackage> { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackagePaymentMapper.java b/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackagePaymentMapper.java new file mode 100644 index 0000000..1656921 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackagePaymentMapper.java @@ -0,0 +1,16 @@ +package com.dsh.app.mapper; + +import com.dsh.app.entity.TCoursePackagePayment; +import com.baomidou.mybatisplus.mapper.BaseMapper; + +/** + * <p> + * 用户课程包购买记录 Mapper 接口 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TCoursePackagePaymentMapper extends BaseMapper<TCoursePackagePayment> { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageTypeMapper.java b/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageTypeMapper.java new file mode 100644 index 0000000..2d5b3f9 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/mapper/TCoursePackageTypeMapper.java @@ -0,0 +1,16 @@ +package com.dsh.app.mapper; + +import com.dsh.app.entity.TCoursePackageType; +import com.baomidou.mybatisplus.mapper.BaseMapper; + +/** + * <p> + * 课程包类型 Mapper 接口 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TCoursePackageTypeMapper extends BaseMapper<TCoursePackageType> { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageDiscountService.java b/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageDiscountService.java new file mode 100644 index 0000000..5544294 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageDiscountService.java @@ -0,0 +1,16 @@ +package com.dsh.app.service; + +import com.dsh.app.entity.TCoursePackageDiscount; +import com.baomidou.mybatisplus.service.IService; + +/** + * <p> + * 课包折扣 服务类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TCoursePackageDiscountService extends IService<TCoursePackageDiscount> { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackagePaymentService.java b/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackagePaymentService.java new file mode 100644 index 0000000..baf5a4f --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackagePaymentService.java @@ -0,0 +1,16 @@ +package com.dsh.app.service; + +import com.dsh.app.entity.TCoursePackagePayment; +import com.baomidou.mybatisplus.service.IService; + +/** + * <p> + * 用户课程包购买记录 服务类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TCoursePackagePaymentService extends IService<TCoursePackagePayment> { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageService.java b/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageService.java new file mode 100644 index 0000000..afbe346 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageService.java @@ -0,0 +1,16 @@ +package com.dsh.app.service; + +import com.dsh.app.entity.TCoursePackage; +import com.baomidou.mybatisplus.service.IService; + +/** + * <p> + * 课包 服务类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TCoursePackageService extends IService<TCoursePackage> { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageTypeService.java b/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageTypeService.java new file mode 100644 index 0000000..39abdf8 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/service/TCoursePackageTypeService.java @@ -0,0 +1,16 @@ +package com.dsh.app.service; + +import com.dsh.app.entity.TCoursePackageType; +import com.baomidou.mybatisplus.service.IService; + +/** + * <p> + * 课程包类型 服务类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TCoursePackageTypeService extends IService<TCoursePackageType> { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/service/TCourseService.java b/cloud-server-course/src/main/java/com/dsh/app/service/TCourseService.java new file mode 100644 index 0000000..47a5da2 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/service/TCourseService.java @@ -0,0 +1,16 @@ +package com.dsh.app.service; + +import com.dsh.app.entity.TCourse; +import com.baomidou.mybatisplus.service.IService; + +/** + * <p> + * 课程 服务类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TCourseService extends IService<TCourse> { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageDiscountServiceImpl.java b/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageDiscountServiceImpl.java new file mode 100644 index 0000000..1811eac --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageDiscountServiceImpl.java @@ -0,0 +1,20 @@ +package com.dsh.app.service.impl; + +import com.dsh.app.entity.TCoursePackageDiscount; +import com.dsh.app.mapper.TCoursePackageDiscountMapper; +import com.dsh.app.service.TCoursePackageDiscountService; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * <p> + * 课包折扣 服务实现类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Service +public class TCoursePackageDiscountServiceImpl extends ServiceImpl<TCoursePackageDiscountMapper, TCoursePackageDiscount> implements TCoursePackageDiscountService { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackagePaymentServiceImpl.java b/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackagePaymentServiceImpl.java new file mode 100644 index 0000000..be2ebd4 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackagePaymentServiceImpl.java @@ -0,0 +1,20 @@ +package com.dsh.app.service.impl; + +import com.dsh.app.entity.TCoursePackagePayment; +import com.dsh.app.mapper.TCoursePackagePaymentMapper; +import com.dsh.app.service.TCoursePackagePaymentService; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * <p> + * 用户课程包购买记录 服务实现类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Service +public class TCoursePackagePaymentServiceImpl extends ServiceImpl<TCoursePackagePaymentMapper, TCoursePackagePayment> implements TCoursePackagePaymentService { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageServiceImpl.java b/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageServiceImpl.java new file mode 100644 index 0000000..d2dfc1e --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageServiceImpl.java @@ -0,0 +1,20 @@ +package com.dsh.app.service.impl; + +import com.dsh.app.entity.TCoursePackage; +import com.dsh.app.mapper.TCoursePackageMapper; +import com.dsh.app.service.TCoursePackageService; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * <p> + * 课包 服务实现类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Service +public class TCoursePackageServiceImpl extends ServiceImpl<TCoursePackageMapper, TCoursePackage> implements TCoursePackageService { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageTypeServiceImpl.java b/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageTypeServiceImpl.java new file mode 100644 index 0000000..f84ed7f --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCoursePackageTypeServiceImpl.java @@ -0,0 +1,20 @@ +package com.dsh.app.service.impl; + +import com.dsh.app.entity.TCoursePackageType; +import com.dsh.app.mapper.TCoursePackageTypeMapper; +import com.dsh.app.service.TCoursePackageTypeService; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * <p> + * 课程包类型 服务实现类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Service +public class TCoursePackageTypeServiceImpl extends ServiceImpl<TCoursePackageTypeMapper, TCoursePackageType> implements TCoursePackageTypeService { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCourseServiceImpl.java b/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCourseServiceImpl.java new file mode 100644 index 0000000..6932e44 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/app/service/impl/TCourseServiceImpl.java @@ -0,0 +1,20 @@ +package com.dsh.app.service.impl; + +import com.dsh.app.entity.TCourse; +import com.dsh.app.mapper.TCourseMapper; +import com.dsh.app.service.TCourseService; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * <p> + * 课程 服务实现类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Service +public class TCourseServiceImpl extends ServiceImpl<TCourseMapper, TCourse> implements TCourseService { + +} diff --git a/cloud-server-course/src/main/java/com/dsh/course/util/CodeGeneration.java b/cloud-server-course/src/main/java/com/dsh/course/util/CodeGeneration.java new file mode 100644 index 0000000..67d4f03 --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/course/util/CodeGeneration.java @@ -0,0 +1,88 @@ +package com.dsh.course.util; + +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.generator.AutoGenerator; +import com.baomidou.mybatisplus.generator.config.*; +import com.baomidou.mybatisplus.generator.config.rules.DbType; +import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; + +public class CodeGeneration { + + public static void gen(String tableName){ + + //C:\Users\linla\Desktop\project02\guns-admin + //项目目录 + ///Users/java/IdeaProjects/PlayPai_demo/cloud-server-account/src/main/java/com/dsh/app + String projectPath = "/Users/java/IdeaProjects/PlayPai_demo/cloud-server-course/src/main/java/"; //System.getProperty("user.dir"); + //String projectPath =System.getProperty("user.dir"); + AutoGenerator mpg = new AutoGenerator(); + //全局配置 + GlobalConfig gc = new GlobalConfig(); + gc.setOutputDir(projectPath ); + gc.setFileOverride(true); + gc.setActiveRecord(true);//不需要ActiveRecord特性的请改为false + gc.setEnableCache(false);//XML二级缓存 + gc.setBaseResultMap(true);//XML ResultMap + gc.setBaseColumnList(false);//XML columList + gc.setIdType(IdType.UUID); + gc.setAuthor("administrator");//作者 + gc.setOpen(false);//生成完成不打开文件夹 + + //自定义文件命名,注意%s 会自动填充表实体属性 + gc.setServiceName("%sService"); + gc.setServiceImplName("%sServiceImpl"); + gc.setMapperName("%sMapper"); + gc.setXmlName("%sMapper"); + gc.setControllerName("%sController"); + mpg.setGlobalConfig(gc); + + //数据源配置 + DataSourceConfig dsc = new DataSourceConfig(); + dsc.setDbType(DbType.MYSQL); +// dsc.setUrl("jdbc:mysql://192.168.110.80:3306/playpai_account?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8"); + dsc.setUrl("jdbc:mysql://127.0.0.1:3306/playpai_course?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8"); + dsc.setDriverName("com.mysql.cj.jdbc.Driver"); + dsc.setUsername("root"); + dsc.setPassword("earl9096"); + mpg.setDataSource(dsc); + + //数据库表配置 + StrategyConfig strategy = new StrategyConfig(); + strategy.setTablePrefix(new String[]{});//此处可以修改您的表前缀 + strategy.setNaming(NamingStrategy.underline_to_camel);//表名生成策略 + strategy.setInclude(new String[]{tableName});//需要生成的表 + strategy.setRestControllerStyle(true); + strategy.setEntityLombokModel(true); + strategy.setSuperServiceClass(null); + strategy.setSuperServiceImplClass(null); + strategy.setSuperMapperClass(null); + mpg.setStrategy(strategy); + + //模板配置 + TemplateConfig template=new TemplateConfig(); + //不生成controller + template.setController(null); + //不生成xml文件 + //template.setXml(null); + mpg.setTemplate(template); + //包配置 + PackageConfig pc = new PackageConfig(); + pc.setParent("com.dsh.app"); + pc.setEntity("entity"); + pc.setService("service"); + pc.setServiceImpl("service.impl"); + pc.setMapper("mapper"); + + pc.setXml("mapper.xml"); + +// pc.setController("controller.member"); + mpg.setPackageInfo(pc); + + //执行生成 + mpg.execute(); + } + + public static void main(String[] args) { + gen("t_course_package_discount"); + } +} diff --git a/cloud-server-course/src/main/java/com/dsh/course/util/DateUtil.java b/cloud-server-course/src/main/java/com/dsh/course/util/DateUtil.java index f9e576f..b4de802 100644 --- a/cloud-server-course/src/main/java/com/dsh/course/util/DateUtil.java +++ b/cloud-server-course/src/main/java/com/dsh/course/util/DateUtil.java @@ -329,4 +329,38 @@ return dt1.getTime(); } + + /** + * 计算年龄 + * @param birthDate + * @return + */ + public static int age(Date birthDate) { + // 当前日历 + Calendar nowCalendar = Calendar.getInstance(); + // 生日大于当前日期 + if (nowCalendar.before(birthDate)) { + throw new IllegalArgumentException("The birth date is before current time, it's unbelievable"); + } + // 当前年月日 + int yearNow = nowCalendar.get(Calendar.YEAR); + int monthNow = nowCalendar.get(Calendar.MONTH); + int dayNow = nowCalendar.get(Calendar.DAY_OF_MONTH); + // 出生日期年月日 + Calendar birthCalendar = Calendar.getInstance(); + birthCalendar.setTime(birthDate); + int yearBirth = birthCalendar.get(Calendar.YEAR); + int monthBirth = birthCalendar.get(Calendar.MONTH); + int dayBirth = birthCalendar.get(Calendar.DAY_OF_MONTH); + // 粗计算年龄 + int age = yearNow - yearBirth; + // 当前月份小于出生月份年龄减一 + if (monthNow < monthBirth) { age--; } + // 当前月份等于出生月份,日小于生日年龄减一 + else if (monthNow == monthBirth && dayNow < dayBirth) { age--; } + // 返回年龄值 + return age; + } + + } diff --git a/cloud-server-course/src/main/java/com/dsh/course/util/ToolUtil.java b/cloud-server-course/src/main/java/com/dsh/course/util/ToolUtil.java new file mode 100644 index 0000000..1202cfd --- /dev/null +++ b/cloud-server-course/src/main/java/com/dsh/course/util/ToolUtil.java @@ -0,0 +1,544 @@ +/** + * Copyright (c) 2015-2016, Chill Zhuang 庄骞 (smallchill@163.com). + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dsh.course.util; + + + + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Array; +import java.math.BigDecimal; +import java.net.URISyntaxException; +import java.util.*; +import java.util.Map.Entry; + +/** + * 高频方法集合类 + */ +public class ToolUtil { + + /** + * 获取随机位数的字符串 + * + * @author fengshuonan + * @Date 2017/8/24 14:09 + */ + public static String getRandomString(int length) { + String base = "abcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < length; i++) { + int number = random.nextInt(base.length()); + sb.append(base.charAt(number)); + } + return sb.toString(); + } + + /** + * 判断一个对象是否是时间类型 + * + * @author stylefeng + * @Date 2017/4/18 12:55 + */ + public static String dateType(Object o) { + if (o instanceof Date) { + return DateUtil.getDay((Date) o); + } else { + return o.toString(); + } + } + + /** + * 获取异常的具体信息 + * + * @author fengshuonan + * @Date 2017/3/30 9:21 + * @version 2.0 + */ + public static String getExceptionMsg(Exception e) { + StringWriter sw = new StringWriter(); + try { + e.printStackTrace(new PrintWriter(sw)); + } finally { + try { + sw.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + return sw.getBuffer().toString().replaceAll("\\$", "T"); + } + + /** + * 比较两个对象是否相等。<br> + * 相同的条件有两个,满足其一即可:<br> + * 1. obj1 == null && obj2 == null; 2. obj1.equals(obj2) + * + * @param obj1 对象1 + * @param obj2 对象2 + * @return 是否相等 + */ + public static boolean equals(Object obj1, Object obj2) { + return (obj1 != null) ? (obj1.equals(obj2)) : (obj2 == null); + } + + /** + * 计算对象长度,如果是字符串调用其length函数,集合类调用其size函数,数组调用其length属性,其他可遍历对象遍历计算长度 + * + * @param obj 被计算长度的对象 + * @return 长度 + */ + public static int length(Object obj) { + if (obj == null) { + return 0; + } + if (obj instanceof CharSequence) { + return ((CharSequence) obj).length(); + } + if (obj instanceof Collection) { + return ((Collection<?>) obj).size(); + } + if (obj instanceof Map) { + return ((Map<?, ?>) obj).size(); + } + + int count; + if (obj instanceof Iterator) { + Iterator<?> iter = (Iterator<?>) obj; + count = 0; + while (iter.hasNext()) { + count++; + iter.next(); + } + return count; + } + if (obj instanceof Enumeration) { + Enumeration<?> enumeration = (Enumeration<?>) obj; + count = 0; + while (enumeration.hasMoreElements()) { + count++; + enumeration.nextElement(); + } + return count; + } + if (obj.getClass().isArray() == true) { + return Array.getLength(obj); + } + return -1; + } + + /** + * 对象中是否包含元素 + * + * @param obj 对象 + * @param element 元素 + * @return 是否包含 + */ + public static boolean contains(Object obj, Object element) { + if (obj == null) { + return false; + } + if (obj instanceof String) { + if (element == null) { + return false; + } + return ((String) obj).contains(element.toString()); + } + if (obj instanceof Collection) { + return ((Collection<?>) obj).contains(element); + } + if (obj instanceof Map) { + return ((Map<?, ?>) obj).values().contains(element); + } + + if (obj instanceof Iterator) { + Iterator<?> iter = (Iterator<?>) obj; + while (iter.hasNext()) { + Object o = iter.next(); + if (equals(o, element)) { + return true; + } + } + return false; + } + if (obj instanceof Enumeration) { + Enumeration<?> enumeration = (Enumeration<?>) obj; + while (enumeration.hasMoreElements()) { + Object o = enumeration.nextElement(); + if (equals(o, element)) { + return true; + } + } + return false; + } + if (obj.getClass().isArray() == true) { + int len = Array.getLength(obj); + for (int i = 0; i < len; i++) { + Object o = Array.get(obj, i); + if (equals(o, element)) { + return true; + } + } + } + return false; + } + + /** + * 对象是否不为空(新增) + * + * @param o String,List,Map,Object[],int[],long[] + * @return + */ + public static boolean isNotEmpty(Object o) { + return !isEmpty(o); + } + + /** + * 对象是否为空 + * + * @param o String,List,Map,Object[],int[],long[] + * @return + */ + @SuppressWarnings("rawtypes") + public static boolean isEmpty(Object o) { + if (o == null) { + return true; + } + if (o instanceof String) { + if (o.toString().trim().equals("")) { + return true; + } + } else if (o instanceof List) { + if (((List) o).size() == 0) { + return true; + } + } else if (o instanceof Map) { + if (((Map) o).size() == 0) { + return true; + } + } else if (o instanceof Set) { + if (((Set) o).size() == 0) { + return true; + } + } else if (o instanceof Object[]) { + if (((Object[]) o).length == 0) { + return true; + } + } else if (o instanceof int[]) { + if (((int[]) o).length == 0) { + return true; + } + } else if (o instanceof long[]) { + if (((long[]) o).length == 0) { + return true; + } + } + return false; + } + + /** + * 对象组中是否存在 Empty Object + * + * @param os 对象组 + * @return + */ + public static boolean isOneEmpty(Object... os) { + for (Object o : os) { + if (isEmpty(o)) { + return true; + } + } + return false; + } + + /** + * 对象组中是否全是 Empty Object + * + * @param os + * @return + */ + public static boolean isAllEmpty(Object... os) { + for (Object o : os) { + if (!isEmpty(o)) { + return false; + } + } + return true; + } + + /** + * 是否为数字 + * + * @param obj + * @return + */ + public static boolean isNum(Object obj) { + try { + Integer.parseInt(obj.toString()); + } catch (Exception e) { + return false; + } + return true; + } + + /** + * 如果为空, 则调用默认值 + * + * @param str + * @return + */ + public static Object getValue(Object str, Object defaultValue) { + if (isEmpty(str)) { + return defaultValue; + } + return str; + } + + + /** + * 强转->string,并去掉多余空格 + * + * @param str + * @return + */ + public static String toStr(Object str) { + return toStr(str, ""); + } + + /** + * 强转->string,并去掉多余空格 + * + * @param str + * @param defaultValue + * @return + */ + public static String toStr(Object str, String defaultValue) { + if (null == str) { + return defaultValue; + } + return str.toString().trim(); + } + + /** + * 强转->int + * + * @param obj + * @return + */ +// public static int toInt(Object value) { +// return toInt(value, -1); +// } + + /** + * 强转->int + * + * @param obj + * @param defaultValue + * @return + */ +// public static int toInt(Object value, int defaultValue) { +// return Convert.toInt(value, defaultValue); +// } + + /** + * 强转->long + * + * @param obj + * @return + */ +// public static long toLong(Object value) { +// return toLong(value, -1); +// } + + /** + * 强转->long + * + * @param obj + * @param defaultValue + * @return + */ +// public static long toLong(Object value, long defaultValue) { +// return Convert.toLong(value, defaultValue); +// } +// +// public static String encodeUrl(String url) { +// return URLKit.encode(url, CharsetKit.UTF_8); +// } +// +// public static String decodeUrl(String url) { +// return URLKit.decode(url, CharsetKit.UTF_8); +// } + + /** + * map的key转为小写 + * + * @param map + * @return Map<String , Object> + */ + public static Map<String, Object> caseInsensitiveMap(Map<String, Object> map) { + Map<String, Object> tempMap = new HashMap<>(); + for (String key : map.keySet()) { + tempMap.put(key.toLowerCase(), map.get(key)); + } + return tempMap; + } + + /** + * 获取map中第一个数据值 + * + * @param <K> Key的类型 + * @param <V> Value的类型 + * @param map 数据源 + * @return 返回的值 + */ + public static <K, V> V getFirstOrNull(Map<K, V> map) { + V obj = null; + for (Entry<K, V> entry : map.entrySet()) { + obj = entry.getValue(); + if (obj != null) { + break; + } + } + return obj; + } + + /** + * 创建StringBuilder对象 + * + * @return StringBuilder对象 + */ + public static StringBuilder builder(String... strs) { + final StringBuilder sb = new StringBuilder(); + for (String str : strs) { + sb.append(str); + } + return sb; + } + + /** + * 创建StringBuilder对象 + * + * @return StringBuilder对象 + */ + public static void builder(StringBuilder sb, String... strs) { + for (String str : strs) { + sb.append(str); + } + } + + /** + * 去掉指定后缀 + * + * @param str 字符串 + * @param suffix 后缀 + * @return 切掉后的字符串,若后缀不是 suffix, 返回原字符串 + */ + public static String removeSuffix(String str, String suffix) { + if (isEmpty(str) || isEmpty(suffix)) { + return str; + } + + if (str.endsWith(suffix)) { + return str.substring(0, str.length() - suffix.length()); + } + return str; + } + + /** + * 当前时间 + * + * @author stylefeng + * @Date 2017/5/7 21:56 + */ + public static String currentTime() { + return DateUtil.getTime(); + } + + + + /** + * 判断是否是windows操作系统 + * + * @author stylefeng + * @Date 2017/5/24 22:34 + */ + public static Boolean isWinOs() { + String os = System.getProperty("os.name"); + if (os.toLowerCase().startsWith("win")) { + return true; + } else { + return false; + } + } + + /** + * 获取临时目录 + * + * @author stylefeng + * @Date 2017/5/24 22:35 + */ + public static String getTempPath() { + return System.getProperty("java.io.tmpdir"); + } + + /** + * 把一个数转化为int + * + * @author fengshuonan + * @Date 2017/11/15 下午11:10 + */ + public static Integer toInt(Object val) { + if (val instanceof Double) { + BigDecimal bigDecimal = new BigDecimal((Double) val); + return bigDecimal.intValue(); + } else { + return Integer.valueOf(val.toString()); + } + + } + + /** + * 获取项目路径 + */ + public static String getWebRootPath(String filePath) { + try { + String path = ToolUtil.class.getClassLoader().getResource("").toURI().getPath(); + path = path.replace("/WEB-INF/classes/", ""); + path = path.replace("/target/classes/", ""); + path = path.replace("file:/", ""); + if (ToolUtil.isEmpty(filePath)) { + return path; + } else { + return path + "/" + filePath; + } + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + + /** + * 获取文件后缀名 不包含点 + */ + public static String getFileSuffix(String fileWholeName) { + if (ToolUtil.isEmpty(fileWholeName)) { + return "none"; + } + int lastIndexOf = fileWholeName.lastIndexOf("."); + return fileWholeName.substring(lastIndexOf + 1); + } +} \ No newline at end of file diff --git a/cloud-server-course/src/main/resources/mapper/TCourseMapper.xml b/cloud-server-course/src/main/resources/mapper/TCourseMapper.xml new file mode 100644 index 0000000..c5ebed2 --- /dev/null +++ b/cloud-server-course/src/main/resources/mapper/TCourseMapper.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dsh.app.mapper.TCourseMapper"> + + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.dsh.app.entity.TCourse"> + <id column="id" property="id" /> + <result column="name" property="name" /> + <result column="type" property="type" /> + <result column="introduce" property="introduce" /> + <result column="coverDrawing" property="coverDrawing" /> + <result column="introductionDrawing" property="introductionDrawing" /> + <result column="courseVideo" property="courseVideo" /> + <result column="state" property="state" /> + <result column="insertTime" property="insertTime" /> + </resultMap> + +</mapper> diff --git a/cloud-server-course/src/main/resources/mapper/TCoursePackageDiscountMapper.xml b/cloud-server-course/src/main/resources/mapper/TCoursePackageDiscountMapper.xml new file mode 100644 index 0000000..44f2b90 --- /dev/null +++ b/cloud-server-course/src/main/resources/mapper/TCoursePackageDiscountMapper.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dsh.app.mapper.TCoursePackageDiscountMapper"> + + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.dsh.app.entity.TCoursePackageDiscount"> + <id column="id" property="id" /> + <result column="coursePackageId" property="coursePackageId" /> + <result column="type" property="type" /> + <result column="content" property="content" /> + <result column="auditStatus" property="auditStatus" /> + <result column="auditUserId" property="auditUserId" /> + <result column="auditRemark" property="auditRemark" /> + <result column="insertTime" property="insertTime" /> + </resultMap> + +</mapper> diff --git a/cloud-server-course/src/main/resources/mapper/TCoursePackageMapper.xml b/cloud-server-course/src/main/resources/mapper/TCoursePackageMapper.xml new file mode 100644 index 0000000..068aba2 --- /dev/null +++ b/cloud-server-course/src/main/resources/mapper/TCoursePackageMapper.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dsh.app.mapper.TCoursePackageMapper"> + + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.dsh.app.entity.TCoursePackage"> + <id column="id" property="id" /> + <result column="province" property="province" /> + <result column="provinceCode" property="provinceCode" /> + <result column="city" property="city" /> + <result column="cityCode" property="cityCode" /> + <result column="storeId" property="storeId" /> + <result column="coursePackageTypeId" property="coursePackageTypeId" /> + <result column="name" property="name" /> + <result column="siteId" property="siteId" /> + <result column="coachId" property="coachId" /> + <result column="maxSubscribeNumber" property="maxSubscribeNumber" /> + <result column="classStartTime" property="classStartTime" /> + <result column="classEndTime" property="classEndTime" /> + <result column="classWeeks" property="classWeeks" /> + <result column="coverDrawing" property="coverDrawing" /> + <result column="detailDrawing" property="detailDrawing" /> + <result column="introduceDrawing" property="introduceDrawing" /> + <result column="sort" property="sort" /> + <result column="payType" property="payType" /> + <result column="validDays" property="validDays" /> + <result column="courseId" property="courseId" /> + <result column="introduce" property="introduce" /> + <result column="integral" property="integral" /> + <result column="status" property="status" /> + <result column="auditStatus" property="auditStatus" /> + <result column="auditUserId" property="auditUserId" /> + <result column="authRemark" property="authRemark" /> + <result column="state" property="state" /> + <result column="insertTime" property="insertTime" /> + </resultMap> + +</mapper> diff --git a/cloud-server-course/src/main/resources/mapper/TCoursePackagePaymentMapper.xml b/cloud-server-course/src/main/resources/mapper/TCoursePackagePaymentMapper.xml new file mode 100644 index 0000000..fa1aab4 --- /dev/null +++ b/cloud-server-course/src/main/resources/mapper/TCoursePackagePaymentMapper.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dsh.app.mapper.TCoursePackagePaymentMapper"> + + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.dsh.app.entity.TCoursePackagePayment"> + <id column="id" property="id" /> + <result column="appUserId" property="appUserId" /> + <result column="studentId" property="studentId" /> + <result column="coursePackageId" property="coursePackageId" /> + <result column="payType" property="payType" /> + <result column="classHours" property="classHours" /> + <result column="cashPayment" property="cashPayment" /> + <result column="playPaiCoin" property="playPaiCoin" /> + <result column="totalClassHours" property="totalClassHours" /> + <result column="laveClassHours" property="laveClassHours" /> + <result column="absencesNumber" property="absencesNumber" /> + <result column="payUserType" property="payUserType" /> + <result column="payStatus" property="payStatus" /> + <result column="orderNumber" property="orderNumber" /> + <result column="payUserId" property="payUserId" /> + <result column="status" property="status" /> + <result column="withdrawalTime" property="withdrawalTime" /> + <result column="certificate" property="certificate" /> + <result column="state" property="state" /> + <result column="insertTime" property="insertTime" /> + </resultMap> + +</mapper> diff --git a/cloud-server-course/src/main/resources/mapper/TCoursePackageTypeMapper.xml b/cloud-server-course/src/main/resources/mapper/TCoursePackageTypeMapper.xml new file mode 100644 index 0000000..77a8d6a --- /dev/null +++ b/cloud-server-course/src/main/resources/mapper/TCoursePackageTypeMapper.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dsh.app.mapper.TCoursePackageTypeMapper"> + + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.dsh.app.entity.TCoursePackageType"> + <id column="id" property="id" /> + <result column="name" property="name" /> + <result column="state" property="state" /> + <result column="insertTime" property="insertTime" /> + </resultMap> + +</mapper> diff --git a/cloud-server-other/pom.xml b/cloud-server-other/pom.xml index fa1bdef..92e86ad 100644 --- a/cloud-server-other/pom.xml +++ b/cloud-server-other/pom.xml @@ -75,6 +75,44 @@ <artifactId>swagger-models</artifactId> <version>1.5.22</version> </dependency> + + + <!-- mybatis generertor--> + + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatisplus-spring-boot-starter</artifactId> + <version>1.0.5</version> + </dependency> + + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus</artifactId> + <version>3.4.1</version> + </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-generate</artifactId> + <version>2.3</version> + </dependency> + <dependency> + <groupId>org.apache.velocity</groupId> + <artifactId>velocity</artifactId> + <version>1.7</version> + </dependency> + + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>2.3.30</version> + </dependency> + + <dependency> + <groupId>org.springframework.data</groupId> + <artifactId>spring-data-jpa</artifactId> + <version>1.11.4.RELEASE</version> + </dependency> + </dependencies> <build> diff --git a/cloud-server-other/src/main/java/com/dsh/app/controller/ImgConfigController.java b/cloud-server-other/src/main/java/com/dsh/app/controller/ImgConfigController.java new file mode 100644 index 0000000..942f910 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/app/controller/ImgConfigController.java @@ -0,0 +1,45 @@ +package com.dsh.app.controller; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.dsh.app.entity.TImgConfig; +import com.dsh.app.service.TImgConfigService; +import com.dsh.other.util.ResultUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 图片配置控制器 + */ +@Api +@CrossOrigin +@RestController +@RequestMapping("") +public class ImgConfigController { + + private Logger logger = LoggerFactory.getLogger("business-log"); + + + @Autowired + private TImgConfigService imgConfigService; + + + /** + * 获取 没有学员信息的图片配置 + */ + @PostMapping("/imgConfig/getNoneStu") + public List<TImgConfig> getDriver(){ + return imgConfigService.selectList(new EntityWrapper<TImgConfig>() + .eq("position", 1)); + } + +} diff --git a/cloud-server-other/src/main/java/com/dsh/app/entity/TImgConfig.java b/cloud-server-other/src/main/java/com/dsh/app/entity/TImgConfig.java new file mode 100644 index 0000000..b86c73c --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/app/entity/TImgConfig.java @@ -0,0 +1,53 @@ +package com.dsh.app.entity; + +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableName; +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotations.Version; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * <p> + * 图片配置 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_img_config") +public class TImgConfig extends Model<TImgConfig> { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 位置(1=无学员,2=成为会员,3=我的券包,4=线上商城,5=本周福利,6=今日免费) + */ + private Integer position; + /** + * 图片配置JSON + */ + private String content; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/cloud-server-other/src/main/java/com/dsh/app/feignclient/ImgConfigClient.java b/cloud-server-other/src/main/java/com/dsh/app/feignclient/ImgConfigClient.java new file mode 100644 index 0000000..be547e7 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/app/feignclient/ImgConfigClient.java @@ -0,0 +1,14 @@ +package com.dsh.app.feignclient; + +import com.dsh.app.entity.TImgConfig; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; + +@FeignClient(value = "mb-cloud-other") +public interface ImgConfigClient { + + @PostMapping("/imgConfig/getNoneStu") + List<TImgConfig> getNoneStuImgs(); +} diff --git a/cloud-server-other/src/main/java/com/dsh/app/mapper/TImgConfigMapper.java b/cloud-server-other/src/main/java/com/dsh/app/mapper/TImgConfigMapper.java new file mode 100644 index 0000000..485819f --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/app/mapper/TImgConfigMapper.java @@ -0,0 +1,16 @@ +package com.dsh.app.mapper; + +import com.dsh.app.entity.TImgConfig; +import com.baomidou.mybatisplus.mapper.BaseMapper; + +/** + * <p> + * 图片配置 Mapper 接口 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TImgConfigMapper extends BaseMapper<TImgConfig> { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/app/service/TImgConfigService.java b/cloud-server-other/src/main/java/com/dsh/app/service/TImgConfigService.java new file mode 100644 index 0000000..58a02e2 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/app/service/TImgConfigService.java @@ -0,0 +1,16 @@ +package com.dsh.app.service; + +import com.dsh.app.entity.TImgConfig; +import com.baomidou.mybatisplus.service.IService; + +/** + * <p> + * 图片配置 服务类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +public interface TImgConfigService extends IService<TImgConfig> { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/app/service/impl/TImgConfigServiceImpl.java b/cloud-server-other/src/main/java/com/dsh/app/service/impl/TImgConfigServiceImpl.java new file mode 100644 index 0000000..a200e01 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/app/service/impl/TImgConfigServiceImpl.java @@ -0,0 +1,20 @@ +package com.dsh.app.service.impl; + +import com.dsh.app.entity.TImgConfig; +import com.dsh.app.mapper.TImgConfigMapper; +import com.dsh.app.service.TImgConfigService; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * <p> + * 图片配置 服务实现类 + * </p> + * + * @author administrator + * @since 2023-06-14 + */ +@Service +public class TImgConfigServiceImpl extends ServiceImpl<TImgConfigMapper, TImgConfig> implements TImgConfigService { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/util/CodeGeneration.java b/cloud-server-other/src/main/java/com/dsh/other/util/CodeGeneration.java new file mode 100644 index 0000000..07ab976 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/util/CodeGeneration.java @@ -0,0 +1,88 @@ +package com.dsh.other.util; + +import com.baomidou.mybatisplus.enums.IdType; +import com.baomidou.mybatisplus.generator.AutoGenerator; +import com.baomidou.mybatisplus.generator.config.*; +import com.baomidou.mybatisplus.generator.config.rules.DbType; +import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; + +public class CodeGeneration { + + public static void gen(String tableName){ + + //C:\Users\linla\Desktop\project02\guns-admin + //项目目录 + // + String projectPath = "/Users/java/IdeaProjects/PlayPai_demo/cloud-server-other/src/main/java/"; //System.getProperty("user.dir"); + //String projectPath =System.getProperty("user.dir"); + AutoGenerator mpg = new AutoGenerator(); + //全局配置 + GlobalConfig gc = new GlobalConfig(); + gc.setOutputDir(projectPath ); + gc.setFileOverride(true); + gc.setActiveRecord(true);//不需要ActiveRecord特性的请改为false + gc.setEnableCache(false);//XML二级缓存 + gc.setBaseResultMap(true);//XML ResultMap + gc.setBaseColumnList(false);//XML columList + gc.setIdType(IdType.UUID); + gc.setAuthor("administrator");//作者 + gc.setOpen(false);//生成完成不打开文件夹 + + //自定义文件命名,注意%s 会自动填充表实体属性 + gc.setServiceName("%sService"); + gc.setServiceImplName("%sServiceImpl"); + gc.setMapperName("%sMapper"); + gc.setXmlName("%sMapper"); + gc.setControllerName("%sController"); + mpg.setGlobalConfig(gc); + + //数据源配置 + DataSourceConfig dsc = new DataSourceConfig(); + dsc.setDbType(DbType.MYSQL); +// dsc.setUrl("jdbc:mysql://192.168.110.80:3306/playpai_account?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8"); + dsc.setUrl("jdbc:mysql://127.0.0.1:3306/playpai_other?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8"); + dsc.setDriverName("com.mysql.cj.jdbc.Driver"); + dsc.setUsername("root"); + dsc.setPassword("earl9096"); + mpg.setDataSource(dsc); + + //数据库表配置 + StrategyConfig strategy = new StrategyConfig(); + strategy.setTablePrefix(new String[]{});//此处可以修改您的表前缀 + strategy.setNaming(NamingStrategy.underline_to_camel);//表名生成策略 + strategy.setInclude(new String[]{tableName});//需要生成的表 + strategy.setRestControllerStyle(true); + strategy.setEntityLombokModel(true); + strategy.setSuperServiceClass(null); + strategy.setSuperServiceImplClass(null); + strategy.setSuperMapperClass(null); + mpg.setStrategy(strategy); + + //模板配置 + TemplateConfig template=new TemplateConfig(); + //不生成controller + template.setController(null); + //不生成xml文件 + //template.setXml(null); + mpg.setTemplate(template); + //包配置 + PackageConfig pc = new PackageConfig(); + pc.setParent("com.dsh.app"); + pc.setEntity("entity"); + pc.setService("service"); + pc.setServiceImpl("service.impl"); + pc.setMapper("mapper"); + + pc.setXml("mapper.xml"); + +// pc.setController("controller.member"); + mpg.setPackageInfo(pc); + + //执行生成 + mpg.execute(); + } + + public static void main(String[] args) { + gen("t_img_config"); + } +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/util/DateUtil.java b/cloud-server-other/src/main/java/com/dsh/other/util/DateUtil.java index d23cc1b..38365c2 100644 --- a/cloud-server-other/src/main/java/com/dsh/other/util/DateUtil.java +++ b/cloud-server-other/src/main/java/com/dsh/other/util/DateUtil.java @@ -329,4 +329,37 @@ return dt1.getTime(); } + + /** + * 计算年龄 + * @param birthDate + * @return + */ + public static int age(Date birthDate) { + // 当前日历 + Calendar nowCalendar = Calendar.getInstance(); + // 生日大于当前日期 + if (nowCalendar.before(birthDate)) { + throw new IllegalArgumentException("The birth date is before current time, it's unbelievable"); + } + // 当前年月日 + int yearNow = nowCalendar.get(Calendar.YEAR); + int monthNow = nowCalendar.get(Calendar.MONTH); + int dayNow = nowCalendar.get(Calendar.DAY_OF_MONTH); + // 出生日期年月日 + Calendar birthCalendar = Calendar.getInstance(); + birthCalendar.setTime(birthDate); + int yearBirth = birthCalendar.get(Calendar.YEAR); + int monthBirth = birthCalendar.get(Calendar.MONTH); + int dayBirth = birthCalendar.get(Calendar.DAY_OF_MONTH); + // 粗计算年龄 + int age = yearNow - yearBirth; + // 当前月份小于出生月份年龄减一 + if (monthNow < monthBirth) { age--; } + // 当前月份等于出生月份,日小于生日年龄减一 + else if (monthNow == monthBirth && dayNow < dayBirth) { age--; } + // 返回年龄值 + return age; + } + } diff --git a/cloud-server-other/src/main/java/com/dsh/other/util/ToolUtil.java b/cloud-server-other/src/main/java/com/dsh/other/util/ToolUtil.java new file mode 100644 index 0000000..d52d319 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/util/ToolUtil.java @@ -0,0 +1,542 @@ +/** + * Copyright (c) 2015-2016, Chill Zhuang 庄骞 (smallchill@163.com). + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dsh.other.util; + + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Array; +import java.math.BigDecimal; +import java.net.URISyntaxException; +import java.util.*; +import java.util.Map.Entry; + +/** + * 高频方法集合类 + */ +public class ToolUtil { + + /** + * 获取随机位数的字符串 + * + * @author fengshuonan + * @Date 2017/8/24 14:09 + */ + public static String getRandomString(int length) { + String base = "abcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < length; i++) { + int number = random.nextInt(base.length()); + sb.append(base.charAt(number)); + } + return sb.toString(); + } + + /** + * 判断一个对象是否是时间类型 + * + * @author stylefeng + * @Date 2017/4/18 12:55 + */ + public static String dateType(Object o) { + if (o instanceof Date) { + return DateUtil.getDay((Date) o); + } else { + return o.toString(); + } + } + + /** + * 获取异常的具体信息 + * + * @author fengshuonan + * @Date 2017/3/30 9:21 + * @version 2.0 + */ + public static String getExceptionMsg(Exception e) { + StringWriter sw = new StringWriter(); + try { + e.printStackTrace(new PrintWriter(sw)); + } finally { + try { + sw.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + return sw.getBuffer().toString().replaceAll("\\$", "T"); + } + + /** + * 比较两个对象是否相等。<br> + * 相同的条件有两个,满足其一即可:<br> + * 1. obj1 == null && obj2 == null; 2. obj1.equals(obj2) + * + * @param obj1 对象1 + * @param obj2 对象2 + * @return 是否相等 + */ + public static boolean equals(Object obj1, Object obj2) { + return (obj1 != null) ? (obj1.equals(obj2)) : (obj2 == null); + } + + /** + * 计算对象长度,如果是字符串调用其length函数,集合类调用其size函数,数组调用其length属性,其他可遍历对象遍历计算长度 + * + * @param obj 被计算长度的对象 + * @return 长度 + */ + public static int length(Object obj) { + if (obj == null) { + return 0; + } + if (obj instanceof CharSequence) { + return ((CharSequence) obj).length(); + } + if (obj instanceof Collection) { + return ((Collection<?>) obj).size(); + } + if (obj instanceof Map) { + return ((Map<?, ?>) obj).size(); + } + + int count; + if (obj instanceof Iterator) { + Iterator<?> iter = (Iterator<?>) obj; + count = 0; + while (iter.hasNext()) { + count++; + iter.next(); + } + return count; + } + if (obj instanceof Enumeration) { + Enumeration<?> enumeration = (Enumeration<?>) obj; + count = 0; + while (enumeration.hasMoreElements()) { + count++; + enumeration.nextElement(); + } + return count; + } + if (obj.getClass().isArray() == true) { + return Array.getLength(obj); + } + return -1; + } + + /** + * 对象中是否包含元素 + * + * @param obj 对象 + * @param element 元素 + * @return 是否包含 + */ + public static boolean contains(Object obj, Object element) { + if (obj == null) { + return false; + } + if (obj instanceof String) { + if (element == null) { + return false; + } + return ((String) obj).contains(element.toString()); + } + if (obj instanceof Collection) { + return ((Collection<?>) obj).contains(element); + } + if (obj instanceof Map) { + return ((Map<?, ?>) obj).values().contains(element); + } + + if (obj instanceof Iterator) { + Iterator<?> iter = (Iterator<?>) obj; + while (iter.hasNext()) { + Object o = iter.next(); + if (equals(o, element)) { + return true; + } + } + return false; + } + if (obj instanceof Enumeration) { + Enumeration<?> enumeration = (Enumeration<?>) obj; + while (enumeration.hasMoreElements()) { + Object o = enumeration.nextElement(); + if (equals(o, element)) { + return true; + } + } + return false; + } + if (obj.getClass().isArray() == true) { + int len = Array.getLength(obj); + for (int i = 0; i < len; i++) { + Object o = Array.get(obj, i); + if (equals(o, element)) { + return true; + } + } + } + return false; + } + + /** + * 对象是否不为空(新增) + * + * @param o String,List,Map,Object[],int[],long[] + * @return + */ + public static boolean isNotEmpty(Object o) { + return !isEmpty(o); + } + + /** + * 对象是否为空 + * + * @param o String,List,Map,Object[],int[],long[] + * @return + */ + @SuppressWarnings("rawtypes") + public static boolean isEmpty(Object o) { + if (o == null) { + return true; + } + if (o instanceof String) { + if (o.toString().trim().equals("")) { + return true; + } + } else if (o instanceof List) { + if (((List) o).size() == 0) { + return true; + } + } else if (o instanceof Map) { + if (((Map) o).size() == 0) { + return true; + } + } else if (o instanceof Set) { + if (((Set) o).size() == 0) { + return true; + } + } else if (o instanceof Object[]) { + if (((Object[]) o).length == 0) { + return true; + } + } else if (o instanceof int[]) { + if (((int[]) o).length == 0) { + return true; + } + } else if (o instanceof long[]) { + if (((long[]) o).length == 0) { + return true; + } + } + return false; + } + + /** + * 对象组中是否存在 Empty Object + * + * @param os 对象组 + * @return + */ + public static boolean isOneEmpty(Object... os) { + for (Object o : os) { + if (isEmpty(o)) { + return true; + } + } + return false; + } + + /** + * 对象组中是否全是 Empty Object + * + * @param os + * @return + */ + public static boolean isAllEmpty(Object... os) { + for (Object o : os) { + if (!isEmpty(o)) { + return false; + } + } + return true; + } + + /** + * 是否为数字 + * + * @param obj + * @return + */ + public static boolean isNum(Object obj) { + try { + Integer.parseInt(obj.toString()); + } catch (Exception e) { + return false; + } + return true; + } + + /** + * 如果为空, 则调用默认值 + * + * @param str + * @return + */ + public static Object getValue(Object str, Object defaultValue) { + if (isEmpty(str)) { + return defaultValue; + } + return str; + } + + + /** + * 强转->string,并去掉多余空格 + * + * @param str + * @return + */ + public static String toStr(Object str) { + return toStr(str, ""); + } + + /** + * 强转->string,并去掉多余空格 + * + * @param str + * @param defaultValue + * @return + */ + public static String toStr(Object str, String defaultValue) { + if (null == str) { + return defaultValue; + } + return str.toString().trim(); + } + + /** + * 强转->int + * + * @param obj + * @return + */ +// public static int toInt(Object value) { +// return toInt(value, -1); +// } + + /** + * 强转->int + * + * @param obj + * @param defaultValue + * @return + */ +// public static int toInt(Object value, int defaultValue) { +// return Convert.toInt(value, defaultValue); +// } + + /** + * 强转->long + * + * @param obj + * @return + */ +// public static long toLong(Object value) { +// return toLong(value, -1); +// } + + /** + * 强转->long + * + * @param obj + * @param defaultValue + * @return + */ +// public static long toLong(Object value, long defaultValue) { +// return Convert.toLong(value, defaultValue); +// } +// +// public static String encodeUrl(String url) { +// return URLKit.encode(url, CharsetKit.UTF_8); +// } +// +// public static String decodeUrl(String url) { +// return URLKit.decode(url, CharsetKit.UTF_8); +// } + + /** + * map的key转为小写 + * + * @param map + * @return Map<String , Object> + */ + public static Map<String, Object> caseInsensitiveMap(Map<String, Object> map) { + Map<String, Object> tempMap = new HashMap<>(); + for (String key : map.keySet()) { + tempMap.put(key.toLowerCase(), map.get(key)); + } + return tempMap; + } + + /** + * 获取map中第一个数据值 + * + * @param <K> Key的类型 + * @param <V> Value的类型 + * @param map 数据源 + * @return 返回的值 + */ + public static <K, V> V getFirstOrNull(Map<K, V> map) { + V obj = null; + for (Entry<K, V> entry : map.entrySet()) { + obj = entry.getValue(); + if (obj != null) { + break; + } + } + return obj; + } + + /** + * 创建StringBuilder对象 + * + * @return StringBuilder对象 + */ + public static StringBuilder builder(String... strs) { + final StringBuilder sb = new StringBuilder(); + for (String str : strs) { + sb.append(str); + } + return sb; + } + + /** + * 创建StringBuilder对象 + * + * @return StringBuilder对象 + */ + public static void builder(StringBuilder sb, String... strs) { + for (String str : strs) { + sb.append(str); + } + } + + /** + * 去掉指定后缀 + * + * @param str 字符串 + * @param suffix 后缀 + * @return 切掉后的字符串,若后缀不是 suffix, 返回原字符串 + */ + public static String removeSuffix(String str, String suffix) { + if (isEmpty(str) || isEmpty(suffix)) { + return str; + } + + if (str.endsWith(suffix)) { + return str.substring(0, str.length() - suffix.length()); + } + return str; + } + + /** + * 当前时间 + * + * @author stylefeng + * @Date 2017/5/7 21:56 + */ + public static String currentTime() { + return DateUtil.getTime(); + } + + + + /** + * 判断是否是windows操作系统 + * + * @author stylefeng + * @Date 2017/5/24 22:34 + */ + public static Boolean isWinOs() { + String os = System.getProperty("os.name"); + if (os.toLowerCase().startsWith("win")) { + return true; + } else { + return false; + } + } + + /** + * 获取临时目录 + * + * @author stylefeng + * @Date 2017/5/24 22:35 + */ + public static String getTempPath() { + return System.getProperty("java.io.tmpdir"); + } + + /** + * 把一个数转化为int + * + * @author fengshuonan + * @Date 2017/11/15 下午11:10 + */ + public static Integer toInt(Object val) { + if (val instanceof Double) { + BigDecimal bigDecimal = new BigDecimal((Double) val); + return bigDecimal.intValue(); + } else { + return Integer.valueOf(val.toString()); + } + + } + + /** + * 获取项目路径 + */ + public static String getWebRootPath(String filePath) { + try { + String path = ToolUtil.class.getClassLoader().getResource("").toURI().getPath(); + path = path.replace("/WEB-INF/classes/", ""); + path = path.replace("/target/classes/", ""); + path = path.replace("file:/", ""); + if (ToolUtil.isEmpty(filePath)) { + return path; + } else { + return path + "/" + filePath; + } + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + + /** + * 获取文件后缀名 不包含点 + */ + public static String getFileSuffix(String fileWholeName) { + if (ToolUtil.isEmpty(fileWholeName)) { + return "none"; + } + int lastIndexOf = fileWholeName.lastIndexOf("."); + return fileWholeName.substring(lastIndexOf + 1); + } +} \ No newline at end of file diff --git a/cloud-server-other/src/main/resources/mapper/TImgConfigMapper.xml b/cloud-server-other/src/main/resources/mapper/TImgConfigMapper.xml new file mode 100644 index 0000000..5a0a7c2 --- /dev/null +++ b/cloud-server-other/src/main/resources/mapper/TImgConfigMapper.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dsh.app.mapper.TImgConfigMapper"> + + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.dsh.app.entity.TImgConfig"> + <id column="id" property="id" /> + <result column="position" property="position" /> + <result column="content" property="content" /> + </resultMap> + +</mapper> -- Gitblit v1.7.1