package com.yc.ship.module.miniapplet.service.brand;

import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.module.miniapplet.controller.admin.brand.vo.AppletBrandPageReqVO;
import com.yc.ship.module.miniapplet.controller.admin.brand.vo.AppletBrandSaveReqVO;
import com.yc.ship.module.miniapplet.dal.dataobject.brand.AppletBrandDO;
import com.yc.ship.module.miniapplet.dal.mysql.brand.AppletBrandMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import com.yc.ship.framework.common.util.object.BeanUtils;



/**
 * 小程序系统配置 Service 实现类
 *
 * @author 管理员
 */
@Service
@Validated
public class AppletBrandServiceImpl implements AppletBrandService {

    @Resource
    private AppletBrandMapper brandMapper;

    @Override
    public Long createBrand(AppletBrandSaveReqVO createReqVO) {
        // 插入
        AppletBrandDO brand = BeanUtils.toBean(createReqVO, AppletBrandDO.class);
        brandMapper.insert(brand);
        // 返回
        return brand.getId();
    }

    @Override
    public void updateBrand(AppletBrandSaveReqVO updateReqVO) {
        // 更新
        AppletBrandDO updateObj = BeanUtils.toBean(updateReqVO, AppletBrandDO.class);
        brandMapper.insertOrUpdate(updateObj);
    }

    @Override
    public void deleteBrand(Long id) {
        // 删除
        brandMapper.deleteById(id);
    }


    @Override
    public AppletBrandDO getBrand() {
        return brandMapper.selectOne();
    }

    @Override
    public PageResult<AppletBrandDO> getBrandPage(AppletBrandPageReqVO pageReqVO) {
        return brandMapper.selectPage(pageReqVO);
    }

}