提交 db2c9dce authored 作者: 李秋林's avatar 李秋林

暂存代码,查询全部记录-分布配置

上级 3fb1c1ba
package com.wangxiaolu.promotion.config.mysql;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author : liqiulin
* @date : 2024-04-25 13
* @describe :
*/
@Configuration
@EnableTransactionManagement
//@MapperScan( { "com.wangxiaolu.promotion.domain" })
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return mybatisPlusInterceptor;
}
}
package com.wangxiaolu.promotion.controller.activity.temporary;
import com.wangxiaolu.promotion.pojo.user.dto.TemporaryClockDto;
import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityClockQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull;
/**
* @author : liqiulin
* @date : 2024-04-23 18
* @describe : 打卡信息查询
*/
@Slf4j
@RestController
@RequestMapping("/temporary/clock/query")
public class TemporaryActivityClockQueryController {
@Autowired
TemporaryActivityClockQueryService temporaryActivityClockQueryService;
/**
* 根据促销员id查询今日打卡信息
*/
@GetMapping("/{temporary_id}")
public TemporaryClockDto findTodayTemporaryClockByTemId(@PathVariable("temporary_id") @NotNull Integer temporaryId){
return temporaryActivityClockQueryService.findTodayTemporaryClockByTemId(temporaryId);
}
}
...@@ -8,7 +8,6 @@ import com.wangxiaolu.promotion.pojo.user.dto.TemporaryClockDto; ...@@ -8,7 +8,6 @@ import com.wangxiaolu.promotion.pojo.user.dto.TemporaryClockDto;
import com.wangxiaolu.promotion.pojo.user.vo.TemporaryClockVo; import com.wangxiaolu.promotion.pojo.user.vo.TemporaryClockVo;
import com.wangxiaolu.promotion.result.basedata.RCode; import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityCoreService; import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityCoreService;
import com.wangxiaolu.promotion.utils.DateUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -47,12 +46,12 @@ public class TemporaryActivityCoreController { ...@@ -47,12 +46,12 @@ public class TemporaryActivityCoreController {
throw new ParamException(RCode.CLOCK_DETAIL_ERROR, null); throw new ParamException(RCode.CLOCK_DETAIL_ERROR, null);
} }
// 非上班卡必需有打卡记录ID // 非上班卡必需有打卡记录ID
if (!isClockIn && Objects.isNull((clockVo.getTemporaryClockId()))) { if (!isClockIn && Objects.isNull((clockVo.getId()))) {
throw new ParamException(RCode.CLOCK_DETAIL_ERROR, null); throw new ParamException(RCode.CLOCK_DETAIL_ERROR, null);
} }
Date clockTime = new Date(); Date clockTime = new Date();
TemporaryClockDto dto = new TemporaryClockDto(clockVo.getClockType(), clockVo.getTemporaryClockId(), clockVo.getTemporaryId(), clockVo.getTemporaryName()); TemporaryClockDto dto = new TemporaryClockDto(clockVo.getClockType(), clockVo.getId(), clockVo.getTemporaryId(), clockVo.getTemporaryName());
// 上班卡、午休下班卡、午休上班卡、下班卡 // 上班卡、午休下班卡、午休上班卡、下班卡
if (isClockIn) { if (isClockIn) {
builderClockInData(clockVo, dto, clockTime); builderClockInData(clockVo, dto, clockTime);
...@@ -88,7 +87,7 @@ public class TemporaryActivityCoreController { ...@@ -88,7 +87,7 @@ public class TemporaryActivityCoreController {
// todo if (!DateUtils.parseTime(new Date(), ClockType.TEMPORARY_NOON_CLOCK_OUT_BEGIN_TIME, ClockType.TEMPORARY_NOON_CLOCK_OUT_END_TIME)) { // todo if (!DateUtils.parseTime(new Date(), ClockType.TEMPORARY_NOON_CLOCK_OUT_BEGIN_TIME, ClockType.TEMPORARY_NOON_CLOCK_OUT_END_TIME)) {
// throw new ParamException(RCode.CLOCK_DETAIL_TIME_ERROR, null); // throw new ParamException(RCode.CLOCK_DETAIL_TIME_ERROR, null);
// } // }
clockDto.setTemporaryClockId(clockVo.getTemporaryClockId()) clockDto.setId(clockVo.getId())
.setNoonClockOutAddress(clockVo.getClockAddress()) .setNoonClockOutAddress(clockVo.getClockAddress())
.setNoonClockOutCoordinates(clockVo.getClockCoordinates()) .setNoonClockOutCoordinates(clockVo.getClockCoordinates())
.setNoonClockOutPhoto(clockVo.getClockPhoto()) .setNoonClockOutPhoto(clockVo.getClockPhoto())
...@@ -99,10 +98,10 @@ public class TemporaryActivityCoreController { ...@@ -99,10 +98,10 @@ public class TemporaryActivityCoreController {
// 午休上班卡 // 午休上班卡
private void builderNoonClockInData(TemporaryClockVo clockVo, TemporaryClockDto clockDto, Date dateTime) { private void builderNoonClockInData(TemporaryClockVo clockVo, TemporaryClockDto clockDto, Date dateTime) {
if (!DateUtils.parseTime(new Date(), ClockType.TEMPORARY_NOON_CLOCK_IN_BEGIN_TIME, ClockType.TEMPORARY_NOON_CLOCK_IN_END_TIME)) { // todo if (!DateUtils.parseTime(new Date(), ClockType.TEMPORARY_NOON_CLOCK_IN_BEGIN_TIME, ClockType.TEMPORARY_NOON_CLOCK_IN_END_TIME)) {
throw new ParamException(RCode.CLOCK_DETAIL_TIME_ERROR, null); // throw new ParamException(RCode.CLOCK_DETAIL_TIME_ERROR, null);
} // }
clockDto.setTemporaryClockId(clockVo.getTemporaryClockId()) clockDto.setId(clockVo.getId())
.setNoonClockInAddress(clockVo.getClockAddress()) .setNoonClockInAddress(clockVo.getClockAddress())
.setNoonClockInCoordinates(clockVo.getClockCoordinates()) .setNoonClockInCoordinates(clockVo.getClockCoordinates())
.setNoonClockInPhoto(clockVo.getClockPhoto()) .setNoonClockInPhoto(clockVo.getClockPhoto())
...@@ -112,10 +111,10 @@ public class TemporaryActivityCoreController { ...@@ -112,10 +111,10 @@ public class TemporaryActivityCoreController {
// 下班卡 // 下班卡
private void builderClockOutData(TemporaryClockVo clockVo, TemporaryClockDto clockDto, Date dateTime) { private void builderClockOutData(TemporaryClockVo clockVo, TemporaryClockDto clockDto, Date dateTime) {
if (!DateUtils.parseTime(new Date(), ClockType.TEMPORARY_CLOCK_OUT_BEGIN_TIME, ClockType.TEMPORARY_CLOCK_OUT_END_TIME)) { // todo if (!DateUtils.parseTime(new Date(), ClockType.TEMPORARY_CLOCK_OUT_BEGIN_TIME, ClockType.TEMPORARY_CLOCK_OUT_END_TIME)) {
throw new ParamException(RCode.CLOCK_DETAIL_TIME_ERROR, null); // throw new ParamException(RCode.CLOCK_DETAIL_TIME_ERROR, null);
} // }
clockDto.setTemporaryClockId(clockVo.getTemporaryClockId()) clockDto.setId(clockVo.getId())
.setClockOutAddress(clockVo.getClockAddress()) .setClockOutAddress(clockVo.getClockAddress())
.setClockOutCoordinates(clockVo.getClockCoordinates()) .setClockOutCoordinates(clockVo.getClockCoordinates())
.setClockOutPhoto(clockVo.getClockPhoto()) .setClockOutPhoto(clockVo.getClockPhoto())
......
package com.wangxiaolu.promotion.controller.activity.temporary; package com.wangxiaolu.promotion.controller.activity.temporary;
import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityQueryService; import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityQueryService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
...@@ -27,12 +26,13 @@ public class TemporaryActivityQueryController { ...@@ -27,12 +26,13 @@ public class TemporaryActivityQueryController {
/** /**
* 根据促销员id查询所有任务 * 根据促销员id查询所有任务
* @return 所有任务 todo 之后改为分页 *
* @return 所有任务(分页查询)
*/ */
@GetMapping("/all/{id}") @PostMapping("/all/{id}")
public List<TemporaryActivityReportedDto> findtemporaryIdActivityDataList(@PathVariable("id") @NotNull Long temporaryId) { public PageInfo findtemporaryIdActivityDataList(@PathVariable("id") @NotNull Long temporaryId, @RequestBody PageInfo pageInfo) {
List<TemporaryActivityReportedDto> dtos = temporaryActivityQueryService.findtemporaryIdActivityDataList(temporaryId); temporaryActivityQueryService.findtemporaryIdActivityDataList(temporaryId, pageInfo);
return dtos; return pageInfo;
} }
/** /**
...@@ -48,7 +48,7 @@ public class TemporaryActivityQueryController { ...@@ -48,7 +48,7 @@ public class TemporaryActivityQueryController {
* 根据任务id查询 * 根据任务id查询
*/ */
@GetMapping("/{id}") @GetMapping("/{id}")
public TemporaryActivityReportedDto findTemporaryActivityById(@PathVariable("id") @NotNull Long activityId){ public TemporaryActivityReportedDto findTemporaryActivityById(@PathVariable("id") @NotNull Long activityId) {
TemporaryActivityReportedDto dto = temporaryActivityQueryService.findTemporaryActivityById(activityId); TemporaryActivityReportedDto dto = temporaryActivityQueryService.findTemporaryActivityById(activityId);
return dto; return dto;
} }
......
package com.wangxiaolu.promotion.domain.activity.dao; package com.wangxiaolu.promotion.domain.activity.dao;
import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryClockWrapper;
import com.wangxiaolu.promotion.pojo.user.dto.TemporaryClockDto; import com.wangxiaolu.promotion.pojo.user.dto.TemporaryClockDto;
/** /**
...@@ -19,4 +20,10 @@ public interface TemporaryActivityClockDao { ...@@ -19,4 +20,10 @@ public interface TemporaryActivityClockDao {
* @param dto 信息 * @param dto 信息
*/ */
void updateById(TemporaryClockDto dto); void updateById(TemporaryClockDto dto);
/**
* @param tcw 查询条件
* @return 上述条件只能满足一条记录
*/
TemporaryClockDto selectOne(TemporaryClockWrapper tcw);
} }
package com.wangxiaolu.promotion.domain.activity.dao; package com.wangxiaolu.promotion.domain.activity.dao;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import java.util.List; import java.util.List;
...@@ -12,7 +13,7 @@ import java.util.List; ...@@ -12,7 +13,7 @@ import java.util.List;
public interface TemporaryActivityReportedDao { public interface TemporaryActivityReportedDao {
long activityDataSave(TemporaryActivityReportedDto temActDto); long activityDataSave(TemporaryActivityReportedDto temActDto);
List<TemporaryActivityReportedDto> findListByTemporaryId(Long temporaryId); void findListByTemporaryId(Long temporaryId, PageInfo pageInfo);
TemporaryActivityReportedDto findOneByCurrentDate(Long temporaryId); TemporaryActivityReportedDto findOneByCurrentDate(Long temporaryId);
......
package com.wangxiaolu.promotion.domain.activity.dao.impl; package com.wangxiaolu.promotion.domain.activity.dao.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityClockDao; import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityClockDao;
import com.wangxiaolu.promotion.domain.activity.mapper.TemporaryActivityClockMapper; import com.wangxiaolu.promotion.domain.activity.mapper.TemporaryActivityClockMapper;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityClockDO; import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityClockDO;
import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryClockWrapper;
import com.wangxiaolu.promotion.pojo.user.dto.TemporaryClockDto; import com.wangxiaolu.promotion.pojo.user.dto.TemporaryClockDto;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Objects;
/** /**
* @author : liqiulin * @author : liqiulin
* @date : 2024-04-23 17 * @date : 2024-04-23 17
...@@ -23,8 +28,18 @@ public class TemporaryActivityClockDaoImpl implements TemporaryActivityClockDao ...@@ -23,8 +28,18 @@ public class TemporaryActivityClockDaoImpl implements TemporaryActivityClockDao
@Override @Override
public void save(TemporaryClockDto dto) { public void save(TemporaryClockDto dto) {
// 避免重复打卡
TemporaryClockWrapper tcw = new TemporaryClockWrapper()
.setTemporaryId(dto.getTemporaryId())
.setCreateDate(DateUtil.today());
LambdaQueryWrapper<TemporaryActivityClockDO> qw = buildWrapper(tcw);
Integer count = temporaryActivityClockMapper.selectCount(qw);
if (count > 0){
return;
}
TemporaryActivityClockDO clockDo = new TemporaryActivityClockDO(); TemporaryActivityClockDO clockDo = new TemporaryActivityClockDO();
BeanUtils.copyProperties(dto,clockDo); BeanUtils.copyProperties(dto, clockDo);
clockDo.setCreateDate(DateUtil.today()); clockDo.setCreateDate(DateUtil.today());
temporaryActivityClockMapper.insert(clockDo); temporaryActivityClockMapper.insert(clockDo);
} }
...@@ -32,8 +47,45 @@ public class TemporaryActivityClockDaoImpl implements TemporaryActivityClockDao ...@@ -32,8 +47,45 @@ public class TemporaryActivityClockDaoImpl implements TemporaryActivityClockDao
@Override @Override
public void updateById(TemporaryClockDto dto) { public void updateById(TemporaryClockDto dto) {
TemporaryActivityClockDO clockDo = new TemporaryActivityClockDO(); TemporaryActivityClockDO clockDo = new TemporaryActivityClockDO();
BeanUtils.copyProperties(dto,clockDo); BeanUtils.copyProperties(dto, clockDo);
clockDo.setId(dto.getTemporaryClockId());
temporaryActivityClockMapper.updateById(clockDo); temporaryActivityClockMapper.updateById(clockDo);
} }
/**
* @param tcw 查询条件
* @return 上述条件只能满足一条记录
*/
@Override
public TemporaryClockDto selectOne(TemporaryClockWrapper tcw) {
LambdaQueryWrapper<TemporaryActivityClockDO> qw = buildWrapper(tcw);
TemporaryActivityClockDO clockDO = temporaryActivityClockMapper.selectOne(qw);
return transitionDto(clockDO);
}
private LambdaQueryWrapper<TemporaryActivityClockDO> buildWrapper(TemporaryClockWrapper tcw) {
LambdaQueryWrapper<TemporaryActivityClockDO> qw = new LambdaQueryWrapper<>();
if (Objects.nonNull(tcw.getId())) {
qw.eq(TemporaryActivityClockDO::getId, tcw.getId());
return qw;
}
if (Objects.nonNull(tcw.getTemporaryId())) {
qw.eq(TemporaryActivityClockDO::getTemporaryId, tcw.getTemporaryId());
}
if (StringUtils.isNotBlank(tcw.getCreateDate())) {
qw.eq(TemporaryActivityClockDO::getCreateDate, tcw.getCreateDate());
}
return qw;
}
private TemporaryClockDto transitionDto(TemporaryActivityClockDO clockDO) {
TemporaryClockDto dto = null;
if (Objects.isNull(clockDO)) {
return dto;
}
dto = new TemporaryClockDto();
BeanUtils.copyProperties(clockDO, dto);
return dto;
}
} }
...@@ -2,12 +2,15 @@ package com.wangxiaolu.promotion.domain.activity.dao.impl; ...@@ -2,12 +2,15 @@ package com.wangxiaolu.promotion.domain.activity.dao.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.druid.util.StringUtils; import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao; import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao;
import com.wangxiaolu.promotion.domain.activity.mapper.TemporaryActivityReportedMapper; import com.wangxiaolu.promotion.domain.activity.mapper.TemporaryActivityReportedMapper;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityReportedDO; import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityReportedDO;
import com.wangxiaolu.promotion.domain.activity.mapper.wrapperQo.TemporaryActivityWrapper; import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryActivityWrapper;
import com.wangxiaolu.promotion.enums.activity.TemActApproveStatus; import com.wangxiaolu.promotion.enums.activity.TemActApproveStatus;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -52,12 +55,15 @@ public class TemporaryActivityReportedDaoImpl implements TemporaryActivityReport ...@@ -52,12 +55,15 @@ public class TemporaryActivityReportedDaoImpl implements TemporaryActivityReport
* 根据促销员id查询所有任务 * 根据促销员id查询所有任务
*/ */
@Override @Override
public List<TemporaryActivityReportedDto> findListByTemporaryId(Long temporaryId) { public void findListByTemporaryId(Long temporaryId, PageInfo pageInfo) {
TemporaryActivityWrapper taw = new TemporaryActivityWrapper() TemporaryActivityWrapper taw = new TemporaryActivityWrapper()
.setTemporaryId(temporaryId); .setTemporaryId(temporaryId);
LambdaQueryWrapper<TemporaryActivityReportedDO> temQw = buildQueryList(taw); LambdaQueryWrapper<TemporaryActivityReportedDO> temQw = buildQueryList(taw);
List<TemporaryActivityReportedDO> temDOS = temporaryActivityReportedMapper.selectList(temQw);
return transitionDtos(temDOS); Page<TemporaryActivityReportedDO> page = new Page<>(pageInfo.getPageNum(), pageInfo.getPageSize());
Page<TemporaryActivityReportedDO> temDoPage = temporaryActivityReportedMapper.selectPage(page, temQw);
pageInfo.pageCovert(temDoPage);
pageInfo.setRecords(transitionDtos(temDoPage.getRecords()));
} }
/** /**
...@@ -88,6 +94,9 @@ public class TemporaryActivityReportedDaoImpl implements TemporaryActivityReport ...@@ -88,6 +94,9 @@ public class TemporaryActivityReportedDaoImpl implements TemporaryActivityReport
if (!StringUtils.isEmpty(tw.getCreateDate())) { if (!StringUtils.isEmpty(tw.getCreateDate())) {
queryWrapper.eq(TemporaryActivityReportedDO::getCreateDate, tw.getCreateDate()); queryWrapper.eq(TemporaryActivityReportedDO::getCreateDate, tw.getCreateDate());
} }
// 默认创建日期倒序排列
queryWrapper.orderByDesc(TemporaryActivityReportedDO::getCreateDate);
return queryWrapper; return queryWrapper;
} }
......
package com.wangxiaolu.promotion.domain.activity.mapper.wrapperQo; package com.wangxiaolu.promotion.domain.activity.wrapperQo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
......
package com.wangxiaolu.promotion.domain.activity.wrapperQo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* @author : liqiulin
* @date : 2024-04-23 19
* @describe :
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class TemporaryClockWrapper {
/**
* 主键id
*/
private Long id;
/**
* temporary_info表id
*/
private Integer temporaryId;
/**
* 创建日期YYYY-MM-DD
*/
private String createDate;
}
package com.wangxiaolu.promotion.pojo;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wangxiaolu.promotion.exception.APIException;
import com.wangxiaolu.promotion.result.basedata.RCode;
import lombok.Data;
import org.springframework.util.CollectionUtils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @author : liqiulin
* @date : 2024-04-19 13
* @describe : 分页配置,默认每页10条记录
*/
@Data
public class PageInfo<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 当前页数,第1页开始
*/
private int pageNum = 1;
/**
* 每页条数
*/
private int pageSize = 1;
/**
* 总条数
*/
private int totalRecord;
/**
* 总页数
*/
private int totalPage;
List<T> records;
/**
*
* current:当前页数,必须大于等于 1,默认值为 1。
* size:每页条数,默认值为 10。
* total:总条数,默认值为 0。
* records:当前页数据集合,默认值为空集合。
* searchCount:是否进行 count 查询,默认值为 true,表示会统计总条数。
* pages:总页数,通过计算得出。
* optimizeCountSql:是否优化 count 查询,默认值为 true。
* hitCount:是否对 count 进行 limit 优化,默认值为 false。
* countId:count 查询的列名,默认为 null,表示所有列。
* maxLimit:设置最大的 limit 查询限制,默认值为 -1,表示不限制。
* @param iPage 查询出的分页对象
* @param t 需要转换的对象(用于返回前端,不能直接返回DO)
* @param <P> 分页对象中的类型
*/
public <P> void pageCovert(IPage<P> iPage, Class<T> t) {
this.totalRecord = (int) iPage.getTotal();
this.totalPage = (int) iPage.getPages();
List<P> iPageRecords = iPage.getRecords();
if (CollectionUtils.isEmpty(iPageRecords)) {
this.records = new ArrayList<>();
return;
}
try {
List<T> tList = new ArrayList<>(iPageRecords.size() * 2);
for (P pr : iPageRecords) {
T newT = t.newInstance();
// 把原对象数据拷贝到新的对象
BeanUtil.copyProperties(pr, newT);
tList.add(newT);
}
this.records = tList;
} catch (Exception e) {
throw new APIException(RCode.FAILED, e.getMessage());
}
}
public <P> void pageCovert(IPage<P> iPage) {
this.totalRecord = (int) iPage.getTotal();
this.totalPage = (int) iPage.getPages();
}
}
package com.wangxiaolu.promotion.pojo;
/**
* @author : liqiulin
* @date : 2024-04-19 13
* @describe : 分页配置,默认每页10条记录
*/
public class PageVo {
/**
* 当前页数,从0开始
*/
private Integer pageNum;
/**
* 每页条数
*/
private Integer pageSize;
/**
* 总条数
*/
private Integer totalRecord;
/**
* 总页数
*/
private Integer totalPage;
}
...@@ -22,7 +22,7 @@ public class TemporaryClockDto { ...@@ -22,7 +22,7 @@ public class TemporaryClockDto {
* 打卡记录id * 打卡记录id
* 上班打卡无记录id * 上班打卡无记录id
*/ */
Long temporaryClockId; Long id;
/** /**
* temporaryId * temporaryId
...@@ -90,9 +90,9 @@ public class TemporaryClockDto { ...@@ -90,9 +90,9 @@ public class TemporaryClockDto {
// 下班打卡时间 // 下班打卡时间
Date clockOutTime; Date clockOutTime;
public TemporaryClockDto(Integer clockType, Long temporaryClockId, Integer temporaryId, String temporaryName) { public TemporaryClockDto(Integer clockType, Long id, Integer temporaryId, String temporaryName) {
if (!ClockType.TEMPORARY_CLOCK_IN.equals(clockType)) { if (!ClockType.TEMPORARY_CLOCK_IN.equals(clockType)) {
this.temporaryClockId = temporaryClockId; this.id = id;
} }
this.temporaryId = temporaryId; this.temporaryId = temporaryId;
this.temporaryName = temporaryName; this.temporaryName = temporaryName;
......
...@@ -22,7 +22,7 @@ public class TemporaryClockVo { ...@@ -22,7 +22,7 @@ public class TemporaryClockVo {
/** /**
* 打卡记录id * 打卡记录id
*/ */
Long temporaryClockId; Long id;
/** /**
* 打卡类型:1、上班卡;2、午休下班卡;3、午休上班卡;4、下班卡 * 打卡类型:1、上班卡;2、午休下班卡;3、午休上班卡;4、下班卡
......
package com.wangxiaolu.promotion.service.activity.temporary;
import com.wangxiaolu.promotion.pojo.user.dto.TemporaryClockDto;
/**
* @author : liqiulin
* @date : 2024-04-23 19
* @describe :
*/
public interface TemporaryActivityClockQueryService {
TemporaryClockDto findTodayTemporaryClockByTemId(Integer temporaryId);
}
package com.wangxiaolu.promotion.service.activity.temporary; package com.wangxiaolu.promotion.service.activity.temporary;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import java.util.List; import java.util.List;
...@@ -14,7 +15,7 @@ public interface TemporaryActivityQueryService { ...@@ -14,7 +15,7 @@ public interface TemporaryActivityQueryService {
/** /**
* 根据促销员id查询所有任务 * 根据促销员id查询所有任务
*/ */
List<TemporaryActivityReportedDto> findtemporaryIdActivityDataList(Long temporaryId); void findtemporaryIdActivityDataList(Long temporaryId, PageInfo pageInfo);
/** /**
* 根据促销员id查询今日任务 * 根据促销员id查询今日任务
......
package com.wangxiaolu.promotion.service.activity.temporary.impl;
import cn.hutool.core.date.DateUtil;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityClockDao;
import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryClockWrapper;
import com.wangxiaolu.promotion.pojo.user.dto.TemporaryClockDto;
import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityClockQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author : liqiulin
* @date : 2024-04-23 19
* @describe :
*/
@Slf4j
@Service
public class TemporaryActivityClockQueryServiceImpl implements TemporaryActivityClockQueryService {
@Autowired
TemporaryActivityClockDao temporaryActivityClockDao;
@Override
public TemporaryClockDto findTodayTemporaryClockByTemId(Integer temporaryId) {
String today = DateUtil.today();
TemporaryClockWrapper tcw = new TemporaryClockWrapper()
.setTemporaryId(temporaryId)
.setCreateDate(today);
return temporaryActivityClockDao.selectOne(tcw);
}
}
...@@ -43,7 +43,7 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -43,7 +43,7 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
*/ */
@Override @Override
public void clockInTodayActivity(TemporaryClockDto dto) { public void clockInTodayActivity(TemporaryClockDto dto) {
if (Objects.isNull(dto.getTemporaryClockId())){ if (Objects.isNull(dto.getId())){
temporaryActivityClockDao.save(dto); temporaryActivityClockDao.save(dto);
return; return;
} }
......
package com.wangxiaolu.promotion.service.activity.temporary.impl; package com.wangxiaolu.promotion.service.activity.temporary.impl;
import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao; import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityQueryService; import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityQueryService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -25,9 +27,8 @@ public class TemporaryActivityQueryServiceImpl implements TemporaryActivityQuery ...@@ -25,9 +27,8 @@ public class TemporaryActivityQueryServiceImpl implements TemporaryActivityQuery
* 根据促销员id查询所有任务 * 根据促销员id查询所有任务
*/ */
@Override @Override
public List<TemporaryActivityReportedDto> findtemporaryIdActivityDataList(Long temporaryId) { public void findtemporaryIdActivityDataList(Long temporaryId, PageInfo pageInfo) {
List<TemporaryActivityReportedDto> dtos = temporaryActivityReportedDao.findListByTemporaryId(temporaryId); temporaryActivityReportedDao.findListByTemporaryId(temporaryId,pageInfo);
return dtos;
} }
......
...@@ -52,4 +52,9 @@ tengxunyun: ...@@ -52,4 +52,9 @@ tengxunyun:
#模板ID-手机验证码 #模板ID-手机验证码
template_id_a: 2127434 template_id_a: 2127434
#验证码过期时间(分钟) #验证码过期时间(分钟)
overdue_long: 5 overdue_long: 5
\ No newline at end of file
# mybatis-plus 打印sql日志
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论