查询用户打卡记录

master
382696293@qq.com 2 years ago
parent 7198277d9e
commit ead2a0cc88

@ -0,0 +1,98 @@
package com.flossom.common.core.domain.ret;
import com.flossom.common.core.annotation.Excel;
import com.flossom.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.ArrayList;
import java.util.List;
/**
* wx_clock_log
*
* @author flossom
* @date 2024-01-29
*/
public class WxClockLogRet extends BaseEntity {
/**
* $column.columnComment
*/
private Long id;
/**
*
*/
@Excel(name = "微信用户")
private Long userId;
/**
* 使
*/
@Excel(name = "当天使用过的仪器")
private String instrumentId;
/**
* 使
*/
@Excel(name = "当天使用过的仪器")
private String instrumentName;
/**
*
*/
@Excel(name = "打卡心得")
private String clockContent;
private List<String> clockImg = new ArrayList<>();
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getUserId() {
return userId;
}
public void setInstrumentId(String instrumentId) {
this.instrumentId = instrumentId;
}
public String getInstrumentId() {
return instrumentId;
}
public void setInstrumentName(String instrumentName) {
this.instrumentName = instrumentName;
}
public String getInstrumentName() {
return instrumentName;
}
public void setClockContent(String clockContent) {
this.clockContent = clockContent;
}
public String getClockContent() {
return clockContent;
}
public List<String> getClockImg() {
return clockImg;
}
public void setClockImg(List<String> clockImg) {
this.clockImg = clockImg;
}
}

@ -58,4 +58,6 @@ public interface WxClockLogMapper {
* @return
*/
public int deleteWxClockLogByIds(Long[] ids);
Integer selectCountByUserId(WxClockLog queryClockLog);
}

@ -19,6 +19,14 @@ 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
</sql>
<select id="selectCountByUserId" parameterType="WxClockLog" resultType="Long">
select count(1) from wx_clock_log
where
user_id = #{userId}
and create_time &gt;= #{params.beginTime}
and create_time &lt;= #{params.endTime}
</select>
<select id="selectWxClockLogList" parameterType="WxClockLog" resultMap="WxClockLogResult">
<include refid="selectWxClockLogVo"/>
<where>

@ -41,6 +41,14 @@ public class WxClockLogController extends BaseController {
return R.ok();
}
/**
*
*/
@GetMapping("/getClockByUserId")
public R getClockByUserId() {
return R.ok(wxClockLogService.getClockByUserId());
}
/**
*
* 使
@ -48,8 +56,8 @@ public class WxClockLogController extends BaseController {
*/
@PostMapping("/insertClockLog")
public R insertClockLog(@RequestParam(value = "firstClockImg") MultipartFile firstClockImg,
@RequestParam(value = "secondClockImg", required = false) MultipartFile secondClockImg,
@RequestParam(value = "thirdClockImg", required = false) MultipartFile thirdClockImg,
@RequestParam(value = "secondClockImg") MultipartFile secondClockImg,
@RequestParam(value = "thirdClockImg") MultipartFile thirdClockImg,
@Validated WxClockLogReq wxClockLogReq) {
wxClockLogReq.setClockImageList(new ArrayList<>());
if (firstClockImg != null) {

@ -1,10 +1,14 @@
package com.flossom.miniProgram.service;
import com.flossom.common.core.domain.req.WxClockLogReq;
import com.flossom.common.core.domain.ret.WxClockLogRet;
public interface IWxClockLogService {
public void insertWxClockLog(WxClockLogReq wxClockLogReq);
void addClockInstrument(Long instrumentId);
WxClockLogRet getClockByUserId();
}

@ -2,6 +2,7 @@ package com.flossom.miniProgram.service.impl;
import com.flossom.common.core.domain.entity.*;
import com.flossom.common.core.domain.req.WxClockLogReq;
import com.flossom.common.core.domain.ret.WxClockLogRet;
import com.flossom.common.core.enums.Status;
import com.flossom.common.core.mapper.WxClockImgMapper;
import com.flossom.common.core.mapper.WxClockInstrumentLogMapper;
@ -45,12 +46,13 @@ public class WxClockLogServiceImpl implements IWxClockLogService {
WxUserMember wxUserMember = SecurityUtils.getLoginUser().getWxUserMember();
LocalDateTime now = LocalDateTime.now();
// 首次打卡奖励
WxClockLog queryClockLog = new WxClockLog();
queryClockLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
queryClockLog.getParams().put("beginTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MIN));
queryClockLog.getParams().put("endTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MAX));
List<WxClockLog> wxClockLogList = wxClockLogMapper.selectWxClockLogList(queryClockLog);
if (wxClockLogList == null || wxClockLogList.size() == 0) {
Integer count = wxClockLogMapper.selectCountByUserId(queryClockLog);
if (count == null || count == 0) {
/**
* TODO
*/
@ -138,4 +140,30 @@ public class WxClockLogServiceImpl implements IWxClockLogService {
}
}
}
@Override
public WxClockLogRet getClockByUserId() {
// 查询今天是否有打卡,存在打卡,则将仪器添加到最近一条打卡记录上
WxClockLog queryClockLog = new WxClockLog();
queryClockLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
LocalDateTime now = LocalDateTime.now();
queryClockLog.getParams().put("beginTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MIN));
queryClockLog.getParams().put("endTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MAX));
List<WxClockLog> wxClockLogList = wxClockLogMapper.selectWxClockLogList(queryClockLog);
if (wxClockLogList == null && wxClockLogList.size() == 0) {
return null;
}
WxClockLogRet wxClockLogRet = new WxClockLogRet();
BeanUtils.copyProperties(wxClockLogList.get(0), wxClockLogRet);
WxClockImg queryClockImg = new WxClockImg();
queryClockImg.setUserClockId(wxClockLogRet.getId());
List<WxClockImg> wxClockImgList = wxClockImgMapper.selectWxClockImgList(queryClockImg);
if (wxClockImgList != null && wxClockImgList.size() > 0) {
wxClockImgList.forEach(wxClockImg -> {
wxClockLogRet.getClockImg().add(wxClockImg.getClockImg());
});
}
return wxClockLogRet;
}
}

Loading…
Cancel
Save