diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxClockLogMapper.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxClockLogMapper.java index 5b290d5..8806fab 100644 --- a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxClockLogMapper.java +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxClockLogMapper.java @@ -1,6 +1,7 @@ package com.flossom.common.core.mapper; import com.flossom.common.core.domain.entity.WxClockLog; +import com.flossom.common.core.domain.ret.WxClockLogRet; import java.util.List; @@ -60,4 +61,6 @@ public interface WxClockLogMapper { public int deleteWxClockLogByIds(Long[] ids); Integer selectCountByUserId(WxClockLog queryClockLog); + + List selectWxClockImgRetList(WxClockLog queryClockLog); } diff --git a/flossom-common/flossom-common-core/src/main/resources/mapper/WxClockLogMapper.xml b/flossom-common/flossom-common-core/src/main/resources/mapper/WxClockLogMapper.xml index 1477ce2..9bcb998 100644 --- a/flossom-common/flossom-common-core/src/main/resources/mapper/WxClockLogMapper.xml +++ b/flossom-common/flossom-common-core/src/main/resources/mapper/WxClockLogMapper.xml @@ -15,6 +15,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + select id, user_id, instrument_id, instrument_name, clock_content, status, create_by, create_time from wx_clock_log @@ -49,7 +59,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + + + + SELECT LAST_INSERT_ID() diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxClockLogController.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxClockLogController.java index e68f45a..4f3ff30 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxClockLogController.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxClockLogController.java @@ -3,9 +3,13 @@ package com.flossom.miniProgram.controller; import com.flossom.common.core.constant.Constants; import com.flossom.common.core.domain.R; import com.flossom.common.core.domain.SysFile; +import com.flossom.common.core.domain.entity.WxClockLog; +import com.flossom.common.core.domain.entity.WxNursingLog; import com.flossom.common.core.domain.req.WxClockLogReq; +import com.flossom.common.core.domain.ret.WxClockLogRet; import com.flossom.common.core.exception.ServiceException; import com.flossom.common.core.web.controller.BaseController; +import com.flossom.common.core.web.page.TableDataInfo; import com.flossom.miniProgram.service.IWxClockLogService; import com.flossom.system.api.RemoteFileService; import org.apache.commons.lang3.StringUtils; @@ -16,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.validation.constraints.NotNull; import java.util.ArrayList; +import java.util.List; /** * 用户打卡Controller @@ -43,11 +48,21 @@ public class WxClockLogController extends BaseController { } /** - * 获取用户打卡 + * 获取用户当天最新的一条打卡记录 */ - @GetMapping("/getClockByUserId") - public R getClockByUserId() { - return R.ok(wxClockLogService.getClockByUserId()); + @GetMapping("/latestClockRecord") + public R latestClockRecord() { + return R.ok(wxClockLogService.latestClockRecord()); + } + + /** + * 分页查询用户的打卡记录 + */ + @GetMapping("/list") + public TableDataInfo list() { + startPage(); + List list = wxClockLogService.selectWxClockLogList(); + return getDataTable(list); } /** diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxClockLogService.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxClockLogService.java index 6af23a4..b006e01 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxClockLogService.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxClockLogService.java @@ -1,14 +1,19 @@ package com.flossom.miniProgram.service; +import com.flossom.common.core.domain.entity.WxClockLog; import com.flossom.common.core.domain.req.WxClockLogReq; import com.flossom.common.core.domain.ret.WxClockLogRet; +import java.util.List; + public interface IWxClockLogService { public void insertWxClockLog(WxClockLogReq wxClockLogReq); void addClockInstrument(Long instrumentId); - WxClockLogRet getClockByUserId(); + WxClockLogRet latestClockRecord(); + + List selectWxClockLogList(); } diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxClockLogServiceImpl.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxClockLogServiceImpl.java index b38fb80..d3e99f0 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxClockLogServiceImpl.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxClockLogServiceImpl.java @@ -148,8 +148,7 @@ public class WxClockLogServiceImpl implements IWxClockLogService { } @Override - public WxClockLogRet getClockByUserId() { - // 查询今天是否有打卡,存在打卡,则将仪器添加到最近一条打卡记录上 + public WxClockLogRet latestClockRecord() { WxClockLog queryClockLog = new WxClockLog(); queryClockLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId()); LocalDateTime now = LocalDateTime.now(); @@ -172,4 +171,23 @@ public class WxClockLogServiceImpl implements IWxClockLogService { } return wxClockLogRet; } + + @Override + public List selectWxClockLogList() { + WxClockLog queryClockLog = new WxClockLog(); + queryClockLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId()); + List list = wxClockLogMapper.selectWxClockImgRetList(queryClockLog); + if (list != null && list.size() > 0) { + for (WxClockLogRet wxClockLogRet : list) { + WxClockImg wxClockImg = new WxClockImg(); + wxClockImg.setUserClockId(wxClockLogRet.getId()); + List wxClockImgs = wxClockImgMapper.selectWxClockImgList(wxClockImg); + if (wxClockImgs!=null && wxClockImgs.size()>0) { + List collect = wxClockImgs.stream().map(WxClockImg::getClockImg).collect(Collectors.toList()); + wxClockLogRet.setClockImg(collect); + } + } + } + return list; + } }