package com.njcn.rdms.module.project.dal.mysql.status;

import com.njcn.rdms.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.rdms.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.njcn.rdms.module.project.dal.dataobject.status.ObjectStatusTransitionDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface ObjectStatusTransitionMapper extends BaseMapperX<ObjectStatusTransitionDO> {

    default ObjectStatusTransitionDO selectByObjectTypeAndFromStatusAndAction(String objectType,
                                                                              String fromStatusCode,
                                                                              String actionCode) {
        return selectOne(new LambdaQueryWrapperX<ObjectStatusTransitionDO>()
                .eq(ObjectStatusTransitionDO::getObjectType, objectType)
                .eq(ObjectStatusTransitionDO::getFromStatusCode, fromStatusCode)
                .eq(ObjectStatusTransitionDO::getActionCode, actionCode)
                .eq(ObjectStatusTransitionDO::getStatus, 0));
    }

    default List<ObjectStatusTransitionDO> selectListByObjectTypeAndFromStatus(String objectType, String fromStatusCode) {
        return selectList(new LambdaQueryWrapperX<ObjectStatusTransitionDO>()
                .eq(ObjectStatusTransitionDO::getObjectType, objectType)
                .eq(ObjectStatusTransitionDO::getFromStatusCode, fromStatusCode)
                .eq(ObjectStatusTransitionDO::getStatus, 0));
    }

}
