# ItticketOperationLogServiceImpl.java

    package cloud.wconnect.it.service.itrequest.impl;

    import cloud.wconnect.commonlib.util.DateTimeUtils;
    import cloud.wconnect.it.entity.itrequest.ItticketOperationLog;
    import cloud.wconnect.it.mapper.itrequest.ItticketOperationLogMapper;
    import cloud.wconnect.it.service.itrequest.IItticketOperationLogService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.springframework.stereotype.Service;

    /**
     * <p>
     *  服务实现类
     * </p>
     *
     * @author yyt
     * @since 2024-04-13
     */
    @Service
    @DS("it_manage")
    public class ItticketOperationLogServiceImpl extends ServiceImpl<ItticketOperationLogMapper, ItticketOperationLog> implements IItticketOperationLogService {

        /**
         * 新增操作记录
         *
         * @param propertyId 资产 id
         * @param userId     操作人 id
         * @param itId       it 主键 id
         * @param action     动作
         * @param expansion  拓展 json
         * @author yyt
         * @date 2024/4/13
         **/
        @Override
        public void save(int propertyId, int userId, Integer itId, int action, String expansion) {
            save(new ItticketOperationLog().setPropertyId(propertyId).setItId(itId).setAction(action)
                    .setExpansionJson(expansion).setCreatedBy(userId).setCreatedTime(DateTimeUtils.nowTimestamp()));
        }

        /**
         * 获取 it request 某个操作下最新的 log
         *
         * @param id        it request id
         * @param operation 操作
         * @return log
         * @author yyt
         * @date 2024/11/14
         **/
        @Override
        public ItticketOperationLog getLastLog(Integer id, int operation) {
            return getOne(new QueryWrapper<ItticketOperationLog>().lambda()
                    .eq(ItticketOperationLog::getItId, id)
                    .eq(ItticketOperationLog::getAction, operation)
                    .orderByDesc(ItticketOperationLog::getId)
                    .last("limit 1"));
        }

    }