package com.bjtdba.merchant.service.impl;

import com.bjtdba.entity.merchant.MerchantYx;
import com.bjtdba.merchant.dao.MerchantYxDao;
import com.bjtdba.merchant.service.MerchantYxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * @author 何海强
 * @since 2022-08-09 11:55:46
 */
@Service("merchantYxService")
public class MerchantYxServiceImpl implements MerchantYxService {
    @Autowired
    private MerchantYxDao merchantYxDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public MerchantYx queryById(Integer id) {
        return this.merchantYxDao.queryById(id);
    }

    public MerchantYx queryBySn(String sn){
        return this.merchantYxDao.queryBySn(sn);
    }

    public MerchantYx qeryByMerid(Integer merId){
        return  this.merchantYxDao.qeryByMerid(merId);
    }

    /**
     * 通过用户id查询音响绑定信息
     * @param uid
     * @return
     */
    @Override
    public MerchantYx queryByUid(Integer uid) {
        return this.merchantYxDao.queryByUid(uid);
    }


    /**
     * 分页查询
     *
     * @param rrxMerchantYx 筛选条件
     * @return 查询结果
     */
    @Override
    public List<MerchantYx> queryByPage(MerchantYx rrxMerchantYx) {
        long total = this.merchantYxDao.count(rrxMerchantYx);
        return   this.merchantYxDao.queryAllByLimit(rrxMerchantYx);
    }

    /**
     * 新增数据
     *
     * @param rrxMerchantYx 实例对象
     * @return 实例对象
     */
    @Override
    public MerchantYx insert(MerchantYx rrxMerchantYx) {

        this.merchantYxDao.insert(rrxMerchantYx);
        return rrxMerchantYx;
    }

    /**
     * 修改数据
     *
     * @param rrxMerchantYx 实例对象
     * @return 实例对象
     */
    @Override
    public MerchantYx update(MerchantYx rrxMerchantYx) {
        this.merchantYxDao.update(rrxMerchantYx);
        return this.queryById(rrxMerchantYx.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.merchantYxDao.deleteById(id) > 0;
    }
}
