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.ta.pddserver.entity.AreaEntity;
import org.ta.pddserver.entity.UserEntity;
import org.ta.pddserver.model.api.request.AreaListRequest;
import org.ta.pddserver.model.api.request.UserRequest;
import org.ta.pddserver.model.api.response.LogOrderListResponse;
import org.ta.pddserver.model.api.response.UserListResponse;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<UserEntity> {

    @Select("SELECT * FROM `user` WHERE  `account` = #{account}")
    UserEntity getInfoByAccount(String account);

    @Select("SELECT `uid` , `name` ,`status`, `account`, `created` FROM `user` WHERE `state` > 0 AND `account` LIKE '%${account}%' AND `status` LIKE '%${status}%' ORDER BY uid DESC LIMIT #{offset}, #{size};")
    List<UserListResponse> getListByRequest(UserRequest param);

    @Select("SELECT COUNT(`uid`) FROM `user` WHERE `state` > 0 AND `account` LIKE '%${account}%' AND `status` LIKE '%${status}%' ")
    Integer countUsable(UserRequest param);
}
