package com.jy.business.corporation.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jy.business.corporation.dao.CorporationShopDao;
import com.jy.business.corporation.model.dto.CorporationShopDto;
import com.jy.business.corporation.model.dto.CorporationShopSelectDto;
import com.jy.business.corporation.model.vo.CorporationShopVo;
import com.jy.business.corporation.service.CorporationShopService;
import com.jy.framework.utils.AssertUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 商铺信息 服务实现类
 * </p>
 *
 * @author 
 * @since 2025-08-11
 */
@Service
public class CorporationShopServiceImpl implements CorporationShopService {

    @Resource
    private CorporationShopDao corporationShopDao;

    @Override
    public Page<CorporationShopVo> getPage(CorporationShopSelectDto dto) {
        return corporationShopDao.getPage(dto);
    }

    @Override
    public CorporationShopVo getDetail(Long id) {
        CorporationShopVo vo = corporationShopDao.getDetail(id);
        AssertUtil.notNull(vo, "未知数据");
        return vo;
    }

    @Override
    public Long add(CorporationShopDto dto) {
        corporationShopDao.save(dto);
        return dto.getId();
    }

    @Override
    public void edit(CorporationShopDto dto) {
        corporationShopDao.updateById(dto);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delete(List<Long> idList) {
        corporationShopDao.removeBatchByIds(idList);
    }

}
