PunchInServiceImpl.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.punchsettle.server.atomic.service.impl;
  2. import java.util.List;
  3. import java.util.Objects;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.stereotype.Service;
  6. import org.springframework.util.CollectionUtils;
  7. import com.punchsettle.server.atomic.entity.PunchIn;
  8. import com.punchsettle.server.atomic.mapper.PunchInMapper;
  9. import com.punchsettle.server.atomic.service.IPunchInService;
  10. import com.punchsettle.server.common.utils.Assert;
  11. import com.punchsettle.server.pojo.punchinV1.PunchInQuery;
  12. import tk.mybatis.mapper.weekend.Weekend;
  13. import tk.mybatis.mapper.weekend.WeekendCriteria;
  14. /**
  15. * @author tyuio
  16. * @version 1.0.0
  17. * @description 打卡任务表 service
  18. * @date 2024/11/25 15:07
  19. */
  20. @Service
  21. public class PunchInServiceImpl implements IPunchInService {
  22. @Autowired
  23. private PunchInMapper punchInMapper;
  24. @Override
  25. public PunchIn getById(Long id) {
  26. if (Objects.isNull(id)) {
  27. return null;
  28. }
  29. return punchInMapper.selectByPrimaryKey(id);
  30. }
  31. @Override
  32. public List<PunchIn> listByCondition(PunchInQuery query) {
  33. if (Objects.isNull(query)) {
  34. return List.of();
  35. }
  36. Weekend<PunchIn> punchInWeekend = Weekend.of(PunchIn.class);
  37. WeekendCriteria<PunchIn, Object> criteria = punchInWeekend.weekendCriteria();
  38. if (!CollectionUtils.isEmpty(query.getUserIds())) {
  39. criteria.andIn(PunchIn::getCreatedBy, query.getUserIds());
  40. }
  41. if (!CollectionUtils.isEmpty(query.getPunchInIds())) {
  42. criteria.andIn(PunchIn::getId, query.getPunchInIds());
  43. }
  44. if (!Objects.isNull(query.getArchiveFlag())) {
  45. criteria.andEqualTo(PunchIn::getArchiveFlag, query.getArchiveFlag());
  46. }
  47. punchInWeekend.orderBy(PunchIn::getRewardNum).desc();
  48. punchInWeekend.orderBy(PunchIn::getCreationTime).desc();
  49. return punchInMapper.selectByExample(punchInWeekend);
  50. }
  51. @Override
  52. public void insert(PunchIn punchIn) {
  53. Assert.isNull(punchIn);
  54. punchInMapper.insertSelective(punchIn);
  55. }
  56. @Override
  57. public void delete(Long punchInId) {
  58. Assert.isNull(punchInId);
  59. punchInMapper.deleteByPrimaryKey(punchInId);
  60. }
  61. @Override
  62. public void update(PunchIn punchIn) {
  63. Assert.isNull(punchIn);
  64. punchInMapper.updateByPrimaryKeySelective(punchIn);
  65. }
  66. }