From 6ecda2874afa57ebe7f655fbb75bdf42b20a2750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Sat, 28 Sep 2024 10:23:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B09.28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HitCompetitionStudentInfoController.java | 38 +++++++++++++++++++ .../cms/domain/HitCompetitionStudentInfo.java | 2 + .../src/main/resources/application.yml | 13 +++++-- .../framework/config/SecurityConfig.java | 2 +- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/HitCompetitionStudentInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/HitCompetitionStudentInfoController.java index 1ba1b59..95739d9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/HitCompetitionStudentInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/HitCompetitionStudentInfoController.java @@ -1,17 +1,24 @@ package com.ruoyi.cms.controller; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.cms.domain.vo.HitCompetitionStudentInfoImportVo; import com.ruoyi.common.annotation.Log; import com.ruoyi.cms.domain.HitCompetitionStudentInfo; import com.ruoyi.cms.service.IHitCompetitionStudentInfoService; +import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.common.utils.poi.ExcelUtil; //import com.ruoyi.cms.task.HitTask; +import com.ruoyi.framework.config.ServerConfig; import com.ruoyi.quartz.controller.SysJobController; import com.ruoyi.quartz.domain.SysJob; import org.quartz.SchedulerException; @@ -42,6 +49,8 @@ public class HitCompetitionStudentInfoController extends BaseController { @Autowired private SysJobController sysJobController; + @Autowired + private ServerConfig serverConfig; /** @@ -189,4 +198,33 @@ public class HitCompetitionStudentInfoController extends BaseController { String message = hitCompetitionStudentInfoService.importData(hitList); return success(message); } + + @PostMapping("/uploadDsFile") + public AjaxResult importDsFile(@RequestParam("file")MultipartFile file,String phoneNumber){ + try + { + // 上传文件路径 + String filePath = RuoYiConfig.getUploadPath(); + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String url = serverConfig.getUrl() + fileName; + AjaxResult ajax = AjaxResult.success(); + HitCompetitionStudentInfo hitCompetitionStudentInfo = new HitCompetitionStudentInfo(); + DateTime now = DateUtil.date(); + hitCompetitionStudentInfo.setDsFile(fileName); + hitCompetitionStudentInfo.setUpdateTime(now); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HitCompetitionStudentInfo::getPhoneNumber, phoneNumber); + boolean update = hitCompetitionStudentInfoService.update(hitCompetitionStudentInfo, queryWrapper); + if (update) { + return success("上传成功"); + } + + return success("上传失败"); + } + catch (Exception e) + { + return AjaxResult.error(e.getMessage()); + } + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/HitCompetitionStudentInfo.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/HitCompetitionStudentInfo.java index 02becde..7e0caa3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/HitCompetitionStudentInfo.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/HitCompetitionStudentInfo.java @@ -117,6 +117,8 @@ public class HitCompetitionStudentInfo implements Serializable { @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; + private String dsFile; + @ApiModelProperty(value = "更新人") private String updateBy; @TableField(exist = false) diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index c9a396d..47ebe09 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -75,19 +75,26 @@ spring: database: 9 # 密码 password: Obr1234!@#$ +# password: 123456 # password: # 连接超时时间 - timeout: 10s + timeout: 60s lettuce: + cluster: + refresh: + adaptive: true + period: 10000 pool: # 连接池中的最小空闲连接 min-idle: 0 # 连接池中的最大空闲连接 max-idle: 8 # 连接池的最大数据库连接数 - max-active: 8 + max-active: 20 # #连接池最大阻塞等待时间(使用负值表示没有限制) - max-wait: -1ms + max-wait: 6000ms + time-between-eviction-runs: 1s + shutdown-timeout: 100ms # token配置 token: diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 84e4a35..a283288 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -111,7 +111,7 @@ public class SecurityConfig .authorizeHttpRequests((requests) -> { permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll()); // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - requests.antMatchers("/login", "/register", "/captchaImage").permitAll() + requests.antMatchers("/login", "/register", "/captchaImage","/system/hit_stu_info/uploadDsFile").permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()