package com.punchsettle.server.atomic.service.impl; import java.util.List; import java.util.Objects; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import com.punchsettle.server.atomic.entity.PunchIn; import com.punchsettle.server.atomic.mapper.PunchInMapper; import com.punchsettle.server.atomic.service.IPunchInService; import com.punchsettle.server.common.utils.Assert; import com.punchsettle.server.pojo.punchinV1.PunchInQuery; import tk.mybatis.mapper.weekend.Weekend; import tk.mybatis.mapper.weekend.WeekendCriteria; /** * @author tyuio * @version 1.0.0 * @description 打卡任务表 service * @date 2024/11/25 15:07 */ @Service public class PunchInServiceImpl implements IPunchInService { @Autowired private PunchInMapper punchInMapper; @Override public PunchIn getById(Long id) { if (Objects.isNull(id)) { return null; } return punchInMapper.selectByPrimaryKey(id); } @Override public List listByCondition(PunchInQuery query) { if (Objects.isNull(query)) { return List.of(); } Weekend punchInWeekend = Weekend.of(PunchIn.class); WeekendCriteria criteria = punchInWeekend.weekendCriteria(); if (!CollectionUtils.isEmpty(query.getUserIds())) { criteria.andIn(PunchIn::getCreatedBy, query.getUserIds()); } if (!CollectionUtils.isEmpty(query.getPunchInIds())) { criteria.andIn(PunchIn::getId, query.getPunchInIds()); } if (!Objects.isNull(query.getArchiveFlag())) { criteria.andEqualTo(PunchIn::getArchiveFlag, query.getArchiveFlag()); } punchInWeekend.orderBy(PunchIn::getRewardNum).desc(); punchInWeekend.orderBy(PunchIn::getCreationTime).desc(); return punchInMapper.selectByExample(punchInWeekend); } @Override public void insert(PunchIn punchIn) { Assert.isNull(punchIn); punchInMapper.insertSelective(punchIn); } @Override public void delete(Long punchInId) { Assert.isNull(punchInId); punchInMapper.deleteByPrimaryKey(punchInId); } @Override public void update(PunchIn punchIn) { Assert.isNull(punchIn); punchInMapper.updateByPrimaryKeySelective(punchIn); } }