From 9fa87e11d6b47302981a5176c42333661773b902 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Wed, 26 Aug 2020 16:11:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=85=B3=E8=81=94?= =?UTF-8?q?=E7=9A=84=E6=B5=8B=E8=AF=84=E5=89=A9=E4=BD=99=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msdw/tms/api/QuestionsControllerApi.java | 8 +- .../tms/controller/QuestionsController.java | 11 ++- .../com/msdw/tms/entity/vo/EvaluationVO.java | 4 - .../msdw/tms/service/QuestionsService.java | 4 +- .../service/impl/QuestionsServiceImpl.java | 85 +++++++++++++------ .../tms/service/QuestionsServiceTest.java | 2 +- 6 files changed, 80 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/msdw/tms/api/QuestionsControllerApi.java b/src/main/java/com/msdw/tms/api/QuestionsControllerApi.java index 82b731d..1257152 100644 --- a/src/main/java/com/msdw/tms/api/QuestionsControllerApi.java +++ b/src/main/java/com/msdw/tms/api/QuestionsControllerApi.java @@ -81,7 +81,13 @@ public interface QuestionsControllerApi { * 抽题测评 */ @ApiOperation(value = "抽题测评", notes = "抽题测评") - R evaluation (Integer userId); + R evaluation (); + + /** + * 抽题测评 + */ + @ApiOperation(value = "获取测评剩余时间", notes = "获取测评剩余时间") + R getEvaluationRemainingTime (Integer userId); /** * 通过excel批量导出 diff --git a/src/main/java/com/msdw/tms/controller/QuestionsController.java b/src/main/java/com/msdw/tms/controller/QuestionsController.java index 1763e08..7431a2d 100644 --- a/src/main/java/com/msdw/tms/controller/QuestionsController.java +++ b/src/main/java/com/msdw/tms/controller/QuestionsController.java @@ -145,11 +145,18 @@ public class QuestionsController implements QuestionsControllerApi { @Override @GetMapping("/evaluation") - public R evaluation(Integer userId) { - EvaluationVO evaluation = questionsService.evaluation(userId); + public R evaluation() { + EvaluationVO evaluation = questionsService.evaluation(); return R.ok().put("data", evaluation); } + @Override + @GetMapping("/remaining") + public R getEvaluationRemainingTime(Integer userId) { + String remainingTime = questionsService.getEvaluationRemainingTime(userId); + return R.ok().put("data", remainingTime); + } + @Override @GetMapping("/export") public void exportQuestion(HttpServletResponse response) throws Exception { diff --git a/src/main/java/com/msdw/tms/entity/vo/EvaluationVO.java b/src/main/java/com/msdw/tms/entity/vo/EvaluationVO.java index e6e0b07..68a8172 100644 --- a/src/main/java/com/msdw/tms/entity/vo/EvaluationVO.java +++ b/src/main/java/com/msdw/tms/entity/vo/EvaluationVO.java @@ -27,10 +27,6 @@ public class EvaluationVO implements Serializable { * 测评时长,单位:分钟 */ private Integer duration; - /** - * 当前用户的剩余时长,格式 HH:ss - */ - private String remainingDuration; /** * 测评总题数 */ diff --git a/src/main/java/com/msdw/tms/service/QuestionsService.java b/src/main/java/com/msdw/tms/service/QuestionsService.java index a55d45a..ee57a5e 100644 --- a/src/main/java/com/msdw/tms/service/QuestionsService.java +++ b/src/main/java/com/msdw/tms/service/QuestionsService.java @@ -44,8 +44,10 @@ public interface QuestionsService extends IService { void downloadFiles(HttpServletResponse response) throws IOException; - EvaluationVO evaluation(Integer userId); + EvaluationVO evaluation(); void exportQuestion(HttpServletResponse response) throws Exception; + + String getEvaluationRemainingTime(Integer userId); } diff --git a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java index a87d5c1..55cdf06 100644 --- a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java @@ -397,7 +397,7 @@ public class QuestionsServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("is_del", Constant.IsDel.NOT_DEL.getType()) //未删除 @@ -410,30 +410,35 @@ public class QuestionsServiceImpl extends ServiceImpl ops = stringRedisTemplate.opsForValue(); - String key = REMAINING_TINE_KEY + userId; - String startTime = ops.get(key); - // 剩余时间,单位:秒 - int remainingTime = duration * 60; - if (StringUtils.isEmpty(startTime)) { - //如果没有,表示是开始测评,向redis中插入一条数据,key是前缀加用户id,value是当前时间,过期时间是测评时长加十秒 - ops.set(key, String.valueOf(System.currentTimeMillis()), duration * 60 + 10, TimeUnit.SECONDS); - } else { - // 当前时间与开始时间得时间差,单位:毫秒 - long difference = System.currentTimeMillis() - Long.parseLong(startTime); - remainingTime = (duration * 60) - (new Long(difference).intValue() / 1000); - if (remainingTime < 0) { - ExceptionCast.cast(CommonCode.EVALUATION_TIME_INVALID); - } - } - evaluation.setRemainingDuration(DateUtil.secondToTime(remainingTime)); + + +// //时长转成秒来计算 +// //先查询该用户有没有开始考试,既redis中有没有跟该用户id相关联的key +// //如果没有,表示是开始测评,向redis中插入一条数据,key是前缀加用户id,value是当前时间,过期时间是测评时长加三十秒 +// //如果有,则得到value,既开始测评的时间,用当前时间和开始测评时间做差,测评时长减去该差值 +// //TODO 提交测评时删除redis中的该条数据 +// //得到总时长,单位:分 +// Integer duration = evaluation.getDuration(); +// ValueOperations ops = stringRedisTemplate.opsForValue(); +// String key = REMAINING_TINE_KEY + userId; +// String startTime = ops.get(key); +// // 剩余时间,单位:秒 +// int remainingTime = duration * 60; +// if (StringUtils.isEmpty(startTime)) { +// //如果没有,表示是开始测评,向redis中插入一条数据,key是前缀加用户id,value是当前时间,过期时间是测评时长加十秒 +// ops.set(key, String.valueOf(System.currentTimeMillis()), duration * 60 + 10, TimeUnit.SECONDS); +// } else { +// // 当前时间与开始时间得时间差,单位:毫秒 +// long difference = System.currentTimeMillis() - Long.parseLong(startTime); +// remainingTime = (duration * 60) - (new Long(difference).intValue() / 1000); +// if (remainingTime < 0) { +// ExceptionCast.cast(CommonCode.EVALUATION_TIME_INVALID); +// } +// } +// evaluation.setRemainingDuration(DateUtil.secondToTime(remainingTime)); + + + //搜集随机抽取的试题 Set set = new HashSet<>(); //根据测评规则的类型不同 @@ -505,6 +510,36 @@ public class QuestionsServiceImpl extends ServiceImpl ops = stringRedisTemplate.opsForValue(); + String key = REMAINING_TINE_KEY + userId; + String startTime = ops.get(key); + // 剩余时间,单位:秒 + int remainingTime = duration * 60; + if (StringUtils.isEmpty(startTime)) { + //如果没有,表示是开始测评,向redis中插入一条数据,key是前缀加用户id,value是当前时间,过期时间是测评时长加十秒 + ops.set(key, String.valueOf(System.currentTimeMillis()), duration * 60 + 10, TimeUnit.SECONDS); + } else { + // 当前时间与开始时间得时间差,单位:毫秒 + long difference = System.currentTimeMillis() - Long.parseLong(startTime); + remainingTime = (duration * 60) - (new Long(difference).intValue() / 1000); + if (remainingTime < 0) { + ExceptionCast.cast(CommonCode.EVALUATION_TIME_INVALID); + } + } + return DateUtil.secondToTime(remainingTime); + } + private Set getRandomList(int len, List list) { Set set = new HashSet<>(); Random random = new Random(); diff --git a/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java b/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java index 5493328..062824a 100644 --- a/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java +++ b/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java @@ -121,7 +121,7 @@ class QuestionsServiceTest { @Test void evaluation() { - EvaluationVO evaluation = questionsService.evaluation(1); + EvaluationVO evaluation = questionsService.evaluation(); System.out.println(evaluation.toString()); } } From 4dce5e1a29262a6df60b5bfa3570b7610bef5112 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Wed, 26 Aug 2020 20:21:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=95=B4=E4=BD=93=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=92=8C=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/msdw/tms/common/utils/Constant.java | 17 ++-- .../tms/controller/QuestionsController.java | 6 +- .../com/msdw/tms/entity/QuestionsEntity.java | 4 - .../request/QuestionsUpdateRequest.java | 5 -- .../msdw/tms/entity/response/CommonCode.java | 1 + .../service/impl/QuestionsServiceImpl.java | 48 ++++------- .../excel-template/试题导出模板.xlsx | Bin 0 -> 10889 bytes .../resources/mapper/tms/QuestionsDao.xml | 1 - src/main/resources/sql/data.sql | 81 ++++++++++++++++++ .../com/msdw/tms/TmsApplicationTests.java | 9 ++ 10 files changed, 123 insertions(+), 49 deletions(-) create mode 100644 src/main/resources/excel-template/试题导出模板.xlsx create mode 100644 src/main/resources/sql/data.sql diff --git a/src/main/java/com/msdw/tms/common/utils/Constant.java b/src/main/java/com/msdw/tms/common/utils/Constant.java index 14962fa..4588be9 100644 --- a/src/main/java/com/msdw/tms/common/utils/Constant.java +++ b/src/main/java/com/msdw/tms/common/utils/Constant.java @@ -41,11 +41,15 @@ public class Constant { /** * 通过excel批量导入试题数据时起始行 */ - public static final int STARTING_ROW = 2; + public static final int ROW_INDEX = 2; /** - * 通过excel批量导入试题数据时起始列 + * 通过excel批量导入试题数据时起始行 + */ + public static final int CELL_INDEX = 0; + /** + * 需要提取的样式所在的行号 */ - public static final int STARTING_CELL = 0; + public static final int STYLE_INDEX = 2; /** * 试题选项A */ @@ -77,7 +81,10 @@ public class Constant { /** * 测评规则表id */ - public static final int EVALUATION_RULES_ID = 1; + public static final int EVALUATION_RULES_ID = 1;/** + * 测评规则表id + */ + public static final String EXCEL_SUFFIX = ".xlsx"; /** * 菜单类型 * @@ -211,7 +218,7 @@ public class Constant { /** * 删除 */ - DEL(1, "删除"), + DEL(1, "已删除"), /** * 不删除 */ diff --git a/src/main/java/com/msdw/tms/controller/QuestionsController.java b/src/main/java/com/msdw/tms/controller/QuestionsController.java index 7431a2d..cbb1eb7 100644 --- a/src/main/java/com/msdw/tms/controller/QuestionsController.java +++ b/src/main/java/com/msdw/tms/controller/QuestionsController.java @@ -18,6 +18,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Arrays; +import java.util.List; /** @@ -115,10 +116,9 @@ public class QuestionsController implements QuestionsControllerApi { @PostMapping("/import") //@RequiresPermissions("qms:questions:import") public R importQuestion(@RequestParam(name = "file") MultipartFile file) throws IOException { - //TODO boolean b = questionsService.importQuestion(file); + List list = questionsService.importQuestion(file); - //return b ? R.ok() : R.error(); - return null; + return R.ok().put("data", list); } /** diff --git a/src/main/java/com/msdw/tms/entity/QuestionsEntity.java b/src/main/java/com/msdw/tms/entity/QuestionsEntity.java index a536930..1a47701 100644 --- a/src/main/java/com/msdw/tms/entity/QuestionsEntity.java +++ b/src/main/java/com/msdw/tms/entity/QuestionsEntity.java @@ -86,8 +86,4 @@ public class QuestionsEntity implements Serializable { * 修改时间,用于排序,创建时,修改时间等于创建时间 */ private Date modifyTime; - /** - * 试题科目 - */ - private String subjects; } diff --git a/src/main/java/com/msdw/tms/entity/request/QuestionsUpdateRequest.java b/src/main/java/com/msdw/tms/entity/request/QuestionsUpdateRequest.java index c84895a..f44f6fa 100644 --- a/src/main/java/com/msdw/tms/entity/request/QuestionsUpdateRequest.java +++ b/src/main/java/com/msdw/tms/entity/request/QuestionsUpdateRequest.java @@ -67,9 +67,4 @@ public class QuestionsUpdateRequest { */ @ApiModelProperty(value = "答案解析", name = "answerAnalysis", example = "鲸鱼是最大的哺乳动物") private String answerAnalysis; - /** - * 试题科目 - */ - @ApiModelProperty(value = "试题科目", name = "subjects", example = "基础通识") - private String subjects; } diff --git a/src/main/java/com/msdw/tms/entity/response/CommonCode.java b/src/main/java/com/msdw/tms/entity/response/CommonCode.java index 23b65c5..542b19e 100644 --- a/src/main/java/com/msdw/tms/entity/response/CommonCode.java +++ b/src/main/java/com/msdw/tms/entity/response/CommonCode.java @@ -14,6 +14,7 @@ public enum CommonCode implements ResultCode { QUESTIONTYPE_INVALID(false, 10006, "题型错误!"), EXCEL_INVALID(false, 10007, "excel表内容错误!"), EVALUATION_TIME_INVALID(false, 10008, "测评时间错误!"), + EXCEL_FILE_INVALID(false, 10009, "上传excel文件错误!"), FAIL(false, 11111, "操作失败!"), SERVER_ERROR(false, 99999, "抱歉,系统繁忙,请稍后重试!"); //操作是否成功 diff --git a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java index 55cdf06..2a97bc2 100644 --- a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java @@ -323,9 +323,15 @@ public class QuestionsServiceImpl extends ServiceImpl importQuestion(MultipartFile file) throws IOException { + // 参数合法性校验,只能上传.xlsx后缀的文件 + if (StringUtils.isBlank(file.getOriginalFilename()) + || !file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")).equals(Constant.EXCEL_SUFFIX)) { + ExceptionCast.cast(CommonCode.EXCEL_FILE_INVALID); + } + // 使用excel导入工具类获取试题数据列表 List list = new ExcelImportUtil(QuestionsImportRequest.class) - .readExcel(file.getInputStream(), Constant.STARTING_ROW, Constant.STARTING_CELL); + .readExcel(file.getInputStream(), Constant.ROW_INDEX, Constant.CELL_INDEX); if (list == null || list.size() == 0) { ExceptionCast.cast(CommonCode.EXCEL_INVALID); @@ -380,6 +386,13 @@ public class QuestionsServiceImpl extends ServiceImpl ops = stringRedisTemplate.opsForValue(); -// String key = REMAINING_TINE_KEY + userId; -// String startTime = ops.get(key); -// // 剩余时间,单位:秒 -// int remainingTime = duration * 60; -// if (StringUtils.isEmpty(startTime)) { -// //如果没有,表示是开始测评,向redis中插入一条数据,key是前缀加用户id,value是当前时间,过期时间是测评时长加十秒 -// ops.set(key, String.valueOf(System.currentTimeMillis()), duration * 60 + 10, TimeUnit.SECONDS); -// } else { -// // 当前时间与开始时间得时间差,单位:毫秒 -// long difference = System.currentTimeMillis() - Long.parseLong(startTime); -// remainingTime = (duration * 60) - (new Long(difference).intValue() / 1000); -// if (remainingTime < 0) { -// ExceptionCast.cast(CommonCode.EVALUATION_TIME_INVALID); -// } -// } -// evaluation.setRemainingDuration(DateUtil.secondToTime(remainingTime)); - - + //TODO 提交测评时删除redis中的该条数据 //搜集随机抽取的试题 Set set = new HashSet<>(); @@ -501,11 +487,11 @@ public class QuestionsServiceImpl extends ServiceImplwX=nr0kgM*Jy{_%ByBzb68!%Ej{o8ws8Anv>|sUk&^izj@6?Pch$t(ACvGFw z1Mb1S^-j_THfk&5FgUBAD2 zl+Kd?y{piStA7*oG9Mr1^b~fc5l+5k(UjSi;+cX9_hkbj$8Ptz;=X8kq>va@2mMYN z74OKdP{EXacLV++Jufr`*KRVb?0RHr$cQ9E^O% z&NryFCg2kz6}G8>C~;sXMdk=cK(A%PJ}0vZf@PsxX&Y%_N9Q&8i-@bDyLF9OoNOz;w`_^yzl zgOQKKT&?G?V~KCemrz%73PniQ(!Qe-J%M@l{0s$9{u@mjHCQPx!M-OCeu@O9sgbLN zy&DVj&-4H2`CrV*zkGT{l7dn%D{}a$^h3nZ&Fsn>bWu4k5$Sev^?)FmWwge)A|TPq zCmLdOb;1xRslbkahmoZffw+Sq^6L%GiWp36e#$1V%JB3%7Y{gkYS%PLmx}d14A0rC z+3O4`+1Iq59SQX1EhPnV!>g2%GvCE)(I=U;2obQ}6Nlrz$_UmSP|*2i`lAYBR#fe{ zGQ6glJO3bgGAnQ{?ZZBbP$aMX(dP`DAvaU2g(|-xd-AJWLJc)*UYi=zTvtAd*GA^{ zT^Hh6pRgYNm=v>zR4F(yf3QzV4N~P_1?o0%ejm+w-N%j4TRwC)42mHw`39b`{z($1 zV4&|6m>?^#000`eXT0rMyqsL^Or4zUe$HbR8Y)g%tmpxG4bMT|#m11p{3LpWQe2y? z!X`T-3XOOd5Kh+^7mCL0b0-Ia%+gVTT?A&<=Gujq*XqJ9ov){0bb@m8 z2+cP)T{znI2O|_8O8}^CYely+LEt3rW$->BiFVXlNCgN=(-~T9qIeozx_nj^dib6! zGjMGuv-bjLbpKef4YsN*uVpHAM1gWpRYC28HDQ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#Yo0_c@9# zgZACNF3zMC#IXu9;tGrXXSWCe20{WJ<>9K0%^N|{^3EeDtXf$;C)@3z$O*E?x3ZQi zi$*>SBFn@vzOuxu`nmtr3;7H#F*3nkhz?d@=zsM> z6KCiDIU%^q{y4Iex*eB(miA%pP{U8+vK?u|g*8>)G5E~a0Azf$EckHg_@q^yk;6c&e~qeMza)T9h2*p-=^D&ZtwNL0O@r+vri*iubjwEp?< z9+vogMnGt@M#7mYg~r5b2zF2>=JX{~$H|Y+@dujQnMcp}LFr>w%rKw@O1f#MG&>$hazLzDAHb@qxNrnA7NQC}lNw>eFcQGx7*m9k~~YtS?)bGZ8N0_sXyBZb7k*{5q)T} z0|{<_ohF7XUsu4=J*ee_gyd4jnB6v)vf$N6+_t4vWKw;_N$T5(>vPQdcv|6e8k73bGt;h#w4$p7z8{G)XEE6T40fj?0~(EqhO@GHQt z$(cU^c<_D$_%l`WtLd)`!aq%)!Q}~XPq_WMJp2{mS8@3#!WGG{eekbR^H;!Mwc4M6 zH>AG-{-V_WRk{5N`gZ~FCnNxHLkhU(ElA^hkkikD{ Mup2A - \ No newline at end of file diff --git a/src/main/resources/sql/data.sql b/src/main/resources/sql/data.sql new file mode 100644 index 0000000..f40c053 --- /dev/null +++ b/src/main/resources/sql/data.sql @@ -0,0 +1,81 @@ +/* +Navicat MySQL Data Transfer + +Source Server : localhost +Source Server Version : 80020 +Source Host : localhost:3306 +Source Database : msdw_tms + +Target Server Type : MYSQL +Target Server Version : 80020 +File Encoding : 65001 + +Date: 2020-08-26 18:02:57 +*/ + +SET FOREIGN_KEY_CHECKS=0; + +-- ---------------------------- +-- Table structure for tms_evaluation_rules +-- ---------------------------- +DROP TABLE IF EXISTS `tms_evaluation_rules`; +CREATE TABLE `tms_evaluation_rules` ( + `id` int NOT NULL AUTO_INCREMENT COMMENT '主键', + `evaluation_type` int DEFAULT NULL COMMENT '测评类型:1:随机类型,0:自定义类型', + `duration` int DEFAULT NULL COMMENT '测评时长,单位:分钟', + `question_num` int DEFAULT NULL COMMENT '测评总题数', + `single_num` int DEFAULT NULL COMMENT '单选题数', + `is_single_enable` int DEFAULT '1' COMMENT '只在类型为自定义类型时才启用:1:启用,0:不启用,默认1启用', + `multiple_num` int DEFAULT NULL COMMENT '多选题数', + `is_multiple_enable` int DEFAULT '1' COMMENT '只在类型为自定义类型时才启用:1:启用,0:不启用,默认1启用', + `judgment_num` int DEFAULT NULL COMMENT '判断题数', + `is_judgment_enable` int DEFAULT '1' COMMENT '只在类型为自定义类型时才启用:1:启用,0:不启用,默认1启用', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='测评规则信息记录,只记录一条信息'; + +-- ---------------------------- +-- Records of tms_evaluation_rules +-- ---------------------------- +INSERT INTO `tms_evaluation_rules` VALUES ('1', '1', '10', '0', '0', '1', '0', '1', '0', '1'); + +-- ---------------------------- +-- Table structure for tms_questions +-- ---------------------------- +DROP TABLE IF EXISTS `tms_questions`; +CREATE TABLE `tms_questions` ( + `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键', + `question_type` int DEFAULT NULL COMMENT '题型:1、单选题,2、多选题,3、判断题', + `question_stem` text COMMENT '题干信息', + `option_a` text COMMENT 'A选项内容', + `option_b` text COMMENT 'B选项内容', + `option_c` text COMMENT 'C选项内容', + `option_d` text COMMENT 'D选项内容', + `option_e` text COMMENT 'E选项内容', + `option_f` text COMMENT 'F选项内容', + `answer` varchar(32) DEFAULT NULL COMMENT '正确答案', + `answer_analysis` text COMMENT '答案解析', + `is_enable` int DEFAULT '1' COMMENT '是否禁用:1:启用,0:禁用,默认是1启用', + `is_del` int DEFAULT '0' COMMENT '是否删除:0未删除,1删除,默认0未删除', + `create_user` varchar(32) DEFAULT NULL COMMENT '创建人', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `modify_user` varchar(32) DEFAULT NULL COMMENT '修改人', + `modify_time` datetime DEFAULT NULL COMMENT '修改时间,用于排序,创建时,修改时间等于创建时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='记录试题信息'; + +-- ---------------------------- +-- Table structure for tms_xlsx_template +-- ---------------------------- +DROP TABLE IF EXISTS `tms_xlsx_template`; +CREATE TABLE `tms_xlsx_template` ( + `id` int NOT NULL AUTO_INCREMENT COMMENT '主键', + `file_name` varchar(300) DEFAULT NULL COMMENT '文件名', + `file_url` varchar(500) DEFAULT NULL COMMENT '文件全路径', + `status` int DEFAULT NULL COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='模板文件信息记录'; + +-- ---------------------------- +-- Records of tms_xlsx_template +-- ---------------------------- +INSERT INTO `tms_xlsx_template` VALUES ('1', 'xlsx/20200826/1598430904075.xlsx', 'http://liuwanr.oss-cn-shenzhen.aliyuncs.com/xlsx/20200826/1598430904075.xlsx', null); \ No newline at end of file diff --git a/src/test/java/com/msdw/tms/TmsApplicationTests.java b/src/test/java/com/msdw/tms/TmsApplicationTests.java index f91b814..9876fca 100644 --- a/src/test/java/com/msdw/tms/TmsApplicationTests.java +++ b/src/test/java/com/msdw/tms/TmsApplicationTests.java @@ -278,4 +278,13 @@ class TmsApplicationTests { System.out.println(s); } + @Test + void t7() throws ParseException { + + String f = "hahdhfasdf.xlsx"; + + System.out.println(f.substring(f.lastIndexOf("."))); + + } + }