package com.yonge.cooleshow.biz.dal.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.BeanUtils;
import lombok.extern.slf4j.Slf4j;
import com.yonge.cooleshow.biz.dal.entity.SysGoodsPrice;
import com.yonge.cooleshow.biz.dal.wrapper.SysGoodsPriceWrapper;
import com.yonge.cooleshow.biz.dal.mapper.SysGoodsPriceMapper;
import com.yonge.cooleshow.biz.dal.service.SysGoodsPriceService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 商品价格设置
 * 2023-07-21 17:32:49
 */
@Slf4j
@Service
public class SysGoodsPriceServiceImpl extends ServiceImpl<SysGoodsPriceMapper, SysGoodsPrice> implements SysGoodsPriceService {

	/**
     * 查询详情
     * @param id 详情ID
     * @return SysGoodsPrice
     */
	@Override
    public SysGoodsPrice detail(Long id) {
        
        return baseMapper.selectById(id);
    }
    
    /**
     * 分页查询
     * @param page IPage<SysGoodsPrice>
     * @param query SysGoodsPriceWrapper.SysGoodsPriceQuery
     * @return IPage<SysGoodsPrice>
     */
    @Override
    public IPage<SysGoodsPrice> selectPage(IPage<SysGoodsPrice> page, SysGoodsPriceWrapper.SysGoodsPriceQuery query) {
        
        return page.setRecords(baseMapper.selectPage(page, query));
    }
	
    /**
     * 添加
     * @param sysGoodsPrice SysGoodsPriceWrapper.SysGoodsPrice
     * @return Boolean
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Boolean add(SysGoodsPriceWrapper.SysGoodsPrice sysGoodsPrice) {    	
        
        return this.save(JSON.parseObject(sysGoodsPrice.jsonString(), SysGoodsPrice.class));
    }

    /**
     * 更新
     * @param sysGoodsPrice SysGoodsPriceWrapper.SysGoodsPrice
     * @return Boolean
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Boolean update(SysGoodsPriceWrapper.SysGoodsPrice sysGoodsPrice){

        return this.updateById(JSON.parseObject(sysGoodsPrice.jsonString(), SysGoodsPrice.class));       
    }
}