package shop.alien.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 shop.alien.entity.store.StorePersonnel;
import shop.alien.entity.store.vo.StorePersonnelVo;

import java.util.List;

/**
 * 店铺人员 Mapper 接口
 *
 * @author system
 * @since 2025-01-15
 */
@Mapper
public interface StorePersonnelMapper extends BaseMapper<StorePersonnel> {

    /**
     * 获取店铺人员列表
     *
     * @param storeId 门店id
     * @return List<StorePersonnelVo>
     */
    @Select("select a.*, b.img_url, b.img_sort, b.img_description from store_personnel a " +
            "left join store_img b on a.img_id = b.id where a.delete_flag = 0 and b.delete_flag = 0 " +
            "and a.store_id = #{storeId} " +
            "order by a.sort asc")
    List<StorePersonnelVo> getStorePersonnelList(@Param("storeId") Integer storeId);

    /**
     * 获取人员详情
     *
     * @param id 人员id
     * @return StorePersonnelVo
     */
    @Select("select a.*, b.img_url, b.img_sort, b.img_description from store_personnel a " +
            "left join store_img b on a.img_id = b.id where a.delete_flag = 0 and b.delete_flag = 0 " +
            "and a.id = #{id}")
    StorePersonnelVo getPersonnelInfo(@Param("id") Integer id);
}

