package org.ta.pddserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.ta.pddserver.entity.AreaEntity;
import org.ta.pddserver.entity.CollectOrderEntity;
import org.ta.pddserver.model.api.request.AreaListRequest;
import org.ta.pddserver.model.api.request.CollectOrderListRequest;
import org.ta.pddserver.model.api.request.LogOrderListRequest;
import org.ta.pddserver.model.api.response.CollectOrderInfoResponse;
import org.ta.pddserver.model.api.response.CollectOrderListResponse;
import org.ta.pddserver.model.api.response.CollectOrderResponse;
import org.ta.pddserver.model.api.response.LogOrderListResponse;

import java.util.List;

@Mapper
public interface AreaMapper extends BaseMapper<AreaEntity> {

    @Select("SELECT count(`uid`) FROM `area` WHERE `state` > 0")
    Integer countUsable(AreaListRequest param);

    @Select("SELECT * FROM `area` WHERE  `state` > 0 ORDER BY uid DESC LIMIT #{offset}, #{size}; ")
    List<AreaEntity> getListByRequest(AreaListRequest param);

    @Select("SELECT * FROM `area` WHERE  `state` > 0 AND `code` = #{code};")
    AreaEntity getInfoByCode(@Param("code") String code);

    @Select("SELECT * FROM `area` WHERE `state` > 0 AND `uid` = #{uid}")
    AreaEntity getInfoByUid(@Param("uid") String uid);

    @Select("SELECT * FROM `area` WHERE `state` > 0 ORDER BY `uid` ASC")
    List<AreaEntity> getList();
}
