小程序打卡
This commit is contained in:
		| @@ -28,8 +28,16 @@ public class MyApplicationRunner implements ApplicationRunner { | ||||
|  | ||||
|     @Override | ||||
|     public void run(ApplicationArguments args) throws Exception { | ||||
|         /*System.out.println("项目启动调用方法"); | ||||
|         List<String> phoneList = sysWxUserLogMapper.getAllSysWxUserLogPhone(); | ||||
|         System.out.println("项目启动调用方法"); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 从微信用户表中查询openid更新到用户打卡日志表中 | ||||
|      */ | ||||
|     public void dealWxUserLog(){ | ||||
|         /*List<String> phoneList = sysWxUserLogMapper.getAllSysWxUserLogPhone(); | ||||
|         SysWxUserLog sysWxUserLog = new SysWxUserLog(); | ||||
|         if(phoneList.size() > 0){ | ||||
|             for (String phone : phoneList) { | ||||
| @@ -44,6 +52,5 @@ public class MyApplicationRunner implements ApplicationRunner { | ||||
|                 } | ||||
|             } | ||||
|         }*/ | ||||
|  | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -4,8 +4,11 @@ import com.itextpdf.io.util.DateTimeUtil; | ||||
| import com.stdiet.common.core.controller.BaseController; | ||||
| import com.stdiet.common.core.domain.AjaxResult; | ||||
| import com.stdiet.common.core.page.TableDataInfo; | ||||
| import com.stdiet.common.exception.file.FileNameLengthLimitExceededException; | ||||
| import com.stdiet.common.utils.DateUtils; | ||||
| import com.stdiet.common.utils.StringUtils; | ||||
| import com.stdiet.common.utils.file.FileUploadUtils; | ||||
| import com.stdiet.common.utils.file.MimeTypeUtils; | ||||
| import com.stdiet.common.utils.oss.AliyunOSSUtils; | ||||
| import com.stdiet.common.utils.sign.AesUtils; | ||||
| import com.stdiet.custom.domain.*; | ||||
| @@ -16,7 +19,9 @@ import com.stdiet.custom.service.ISysOrderService; | ||||
| import com.stdiet.custom.service.ISysWxUserInfoService; | ||||
| import com.stdiet.custom.service.ISysWxUserLogService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
|  | ||||
| import java.time.LocalDate; | ||||
| import java.time.temporal.ChronoUnit; | ||||
| @@ -178,4 +183,34 @@ public class WechatAppletController extends BaseController { | ||||
|             cus.setId(AesUtils.encrypt(cus.getId()+"", null)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 上传文件到OSS返回URL | ||||
|      */ | ||||
|     @PostMapping(value = "/uploadFile/{prefix}") | ||||
|     public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @PathVariable String prefix) throws Exception { | ||||
|         try { | ||||
|             if (file == null) { | ||||
|                 return AjaxResult.error("文件不存在"); | ||||
|             } | ||||
|             int fileNameLength = file.getOriginalFilename().length(); | ||||
|             if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { | ||||
|                 throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); | ||||
|             } | ||||
|             FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); | ||||
|  | ||||
|             String fileUrl = AliyunOSSUtils.uploadFileInputSteam(prefix + '/', DateUtils.getDate() + "/" + file.getOriginalFilename(), file); | ||||
|  | ||||
|             AjaxResult ajax = null; | ||||
|             if (StringUtils.isNotEmpty(fileUrl)) { | ||||
|                 ajax = AjaxResult.success(); | ||||
|                 ajax.put("fileUrl", fileUrl); | ||||
|             } else { | ||||
|                 ajax = AjaxResult.error("文件上传失败"); | ||||
|             } | ||||
|             return ajax; | ||||
|         } catch (Exception e) { | ||||
|             return AjaxResult.error("文件上传失败"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user