diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/MyApplicationRunner.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/MyApplicationRunner.java index 9b7ee8d01..07d68a7d6 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/MyApplicationRunner.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/MyApplicationRunner.java @@ -28,8 +28,16 @@ public class MyApplicationRunner implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { - /*System.out.println("项目启动调用方法"); - List phoneList = sysWxUserLogMapper.getAllSysWxUserLogPhone(); + System.out.println("项目启动调用方法"); + } + + + + /** + * 从微信用户表中查询openid更新到用户打卡日志表中 + */ + public void dealWxUserLog(){ + /*List phoneList = sysWxUserLogMapper.getAllSysWxUserLogPhone(); SysWxUserLog sysWxUserLog = new SysWxUserLog(); if(phoneList.size() > 0){ for (String phone : phoneList) { @@ -44,6 +52,5 @@ public class MyApplicationRunner implements ApplicationRunner { } } }*/ - } } diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java index 3ece761f1..e8832cffd 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java @@ -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("文件上传失败"); + } + } } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxUserLog.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxUserLog.java index ab9e62641..40c818cbd 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxUserLog.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxUserLog.java @@ -8,6 +8,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.stdiet.common.annotation.Excel; import com.stdiet.common.core.domain.BaseEntity; +import org.springframework.web.multipart.MultipartFile; /** * 微信用户记录对象 sys_wx_user_log @@ -86,4 +87,36 @@ public class SysWxUserLog extends BaseEntity */ @Excel(name = "营养师") private String nutritionist; + + /** 情绪 */ + @Excel(name = "情绪") + private String emotion; + + /** 食谱之外的食物 */ + @Excel(name = "食谱之外的食物") + private String slyEatFood; + + /** 是否便秘(Y是 N否) */ + @Excel(name = "是否便秘", readConverterExp = "Y=是,N=否") + private String constipation; + + /** 早餐照片 */ + @Excel(name = "早餐照片") + private String breakfastImages; + + /** 午餐照片 */ + @Excel(name = "午餐照片") + private String lunchImages; + + /** 午餐照片 */ + @Excel(name = "午餐照片") + private String dinnerImages; + + /** 加餐照片 */ + @Excel(name = "加餐照片") + private String extraMealImages; + + /** 体型对比照 */ + @Excel(name = "体型对比照") + private String bodyImages; } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserLogService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserLogService.java index 4d0041035..bfa36670c 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserLogService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserLogService.java @@ -5,6 +5,7 @@ import java.util.List; import com.stdiet.custom.domain.SysWxUserInfo; import com.stdiet.custom.domain.SysWxUserLog; import com.stdiet.custom.page.WxLogInfo; +import org.springframework.web.multipart.MultipartFile; /** * 微信用户记录Service接口 @@ -79,4 +80,11 @@ public interface ISysWxUserLogService */ SysWxUserLog selectSysWxUserLogByDateAndOpenId(SysWxUserLog sysWxUserLog); + /** + * 上传打卡日志中照片 + * @param sysWxUserLog + * @return + */ + SysWxUserLog uploadLogImage(SysWxUserLog sysWxUserLog); + } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderNutritionistReplaceRecordServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderNutritionistReplaceRecordServiceImpl.java index d523a3136..64bfe8c55 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderNutritionistReplaceRecordServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderNutritionistReplaceRecordServiceImpl.java @@ -2,6 +2,7 @@ package com.stdiet.custom.service.impl; import java.util.List; import com.stdiet.common.utils.DateUtils; +import com.stdiet.common.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.stdiet.custom.mapper.SysOrderNutritionistReplaceRecordMapper; @@ -54,6 +55,7 @@ public class SysOrderNutritionistReplaceRecordServiceImpl implements ISysOrderNu public int insertSysOrderNutritionistReplaceRecord(SysOrderNutritionistReplaceRecord sysOrderNutritionistReplaceRecord) { sysOrderNutritionistReplaceRecord.setCreateTime(DateUtils.getNowDate()); + sysOrderNutritionistReplaceRecord.setCreateBy(SecurityUtils.getLoginUser().getUser().getUserId()+""); return sysOrderNutritionistReplaceRecordMapper.insertSysOrderNutritionistReplaceRecord(sysOrderNutritionistReplaceRecord); } @@ -67,6 +69,7 @@ public class SysOrderNutritionistReplaceRecordServiceImpl implements ISysOrderNu public int updateSysOrderNutritionistReplaceRecord(SysOrderNutritionistReplaceRecord sysOrderNutritionistReplaceRecord) { sysOrderNutritionistReplaceRecord.setUpdateTime(DateUtils.getNowDate()); + sysOrderNutritionistReplaceRecord.setUpdateBy(SecurityUtils.getLoginUser().getUser().getUserId()+""); return sysOrderNutritionistReplaceRecordMapper.updateSysOrderNutritionistReplaceRecord(sysOrderNutritionistReplaceRecord); } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserLogServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserLogServiceImpl.java index 00fb9602d..d4db23f59 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserLogServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserLogServiceImpl.java @@ -2,7 +2,12 @@ package com.stdiet.custom.service.impl; import java.util.List; +import com.stdiet.common.config.AliyunOSSConfig; +import com.stdiet.common.exception.file.FileNameLengthLimitExceededException; import com.stdiet.common.utils.DateUtils; +import com.stdiet.common.utils.file.FileUploadUtils; +import com.stdiet.common.utils.file.MimeTypeUtils; +import com.stdiet.common.utils.oss.AliyunOSSUtils; import com.stdiet.custom.domain.SysWxUserInfo; import com.stdiet.custom.page.WxLogInfo; import org.springframework.beans.factory.annotation.Autowired; @@ -10,6 +15,7 @@ import org.springframework.stereotype.Service; import com.stdiet.custom.mapper.SysWxUserLogMapper; import com.stdiet.custom.domain.SysWxUserLog; import com.stdiet.custom.service.ISysWxUserLogService; +import org.springframework.web.multipart.MultipartFile; /** * 微信用户记录Service业务层处理 diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserLogMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserLogMapper.xml index 86a1f4a4d..50ee15f59 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserLogMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserLogMapper.xml @@ -25,6 +25,14 @@ + + + + + + + + @@ -41,10 +49,20 @@ + + + + + + + + - select id,openid, weight, appid, phone, log_time, sleep_time, wakeup_time, sport, avatar_url, diet, insomnia, defecation, water, create_by, create_time, update_by, update_time, remark from sys_wx_user_log + select id,openid, weight, appid, phone, log_time, sleep_time, wakeup_time, sport, avatar_url, diet, insomnia, defecation, water, create_by, create_time, update_by, update_time, remark, + emotion,sly_eat_food,constipation,breakfast_images,lunch_images,dinner_images,extra_meal_images,body_images + from sys_wx_user_log - SELECT wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.water, wxlog.insomnia,wxlog.sport,wxlog.diet + SELECT wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.water, wxlog.insomnia,wxlog.sport,wxlog.diet, + wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid where wxinfo.openid = #{openid} or wxinfo.phone = #{phone} order by wxlog.log_time desc