package com.ssm.manage.service.impl;

import com.ssm.core.service.impl.BaseServiceImpl;
import com.ssm.core.utils.SnowflakeUtil;
import com.ssm.manage.dao.SsmStoreAllinpayinfoDao;
import com.ssm.manage.entity.StoreAllinpayInfo;
import com.ssm.manage.query.StoreAllinpayInfoRequest;
import com.ssm.manage.service.SsmStoreAllinpayinfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Random;

@Service
@Slf4j
public class SsmStoreAllinpayinfoServiceImpl extends BaseServiceImpl<StoreAllinpayInfo> implements SsmStoreAllinpayinfoService {
    @Autowired
    private SsmStoreAllinpayinfoDao dao;

    @Override
    public SsmStoreAllinpayinfoDao getDao() {
        return dao;
    }


    @Override
    public List<StoreAllinpayInfo> selectList(StoreAllinpayInfoRequest storeAllinpayInfoRequest) {
        StoreAllinpayInfo storeAllinpayInfo = new StoreAllinpayInfo();
        BeanUtils.copyProperties(storeAllinpayInfoRequest, storeAllinpayInfo);
        return dao.select(storeAllinpayInfo);
    }

    @Override
    public int add(StoreAllinpayInfoRequest storeAllinpayInfoRequest) {
        StoreAllinpayInfo storeAllinpayInfo = new StoreAllinpayInfo();
        BeanUtils.copyProperties(storeAllinpayInfoRequest, storeAllinpayInfo);
        storeAllinpayInfo.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
        return dao.saveNotNull(storeAllinpayInfo);
    }

    @Override
    public int update(StoreAllinpayInfoRequest storeAllinpayInfoRequest) {
        StoreAllinpayInfo storeAllinpayInfo = new StoreAllinpayInfo();
        BeanUtils.copyProperties(storeAllinpayInfoRequest, storeAllinpayInfo);
        return dao.updateByPrimaryKeySelective(storeAllinpayInfo);
    }
}
