package com.java110.@@shareName@@.smo.impl;


import com.java110.@@shareName@@.dao.IStoreServiceDao;
import com.java110.intf.store.IStoreInnerServiceSMO;
import com.java110.dto.store.StoreDto;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.user.UserDto;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 商户内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class StoreInnerServiceSMOImpl extends BaseServiceSMO implements IStoreInnerServiceSMO {

    @Autowired
    private IStoreServiceDao storeServiceDaoImpl;


    @Override
    public int saveStore(@RequestBody  StorePo storePo) {
        int saveFlag = 1;
        storeServiceDaoImpl.saveStoreInfo(BeanConvertUtil.beanCovertMap(storePo));
        return saveFlag;
    }

     @Override
    public int updateStore(@RequestBody  StorePo storePo) {
        int saveFlag = 1;
         storeServiceDaoImpl.updateStoreInfo(BeanConvertUtil.beanCovertMap(storePo));
        return saveFlag;
    }

     @Override
    public int deleteStore(@RequestBody  StorePo storePo) {
        int saveFlag = 1;
        storePo.setStatusCd("1");
        storeServiceDaoImpl.updateStoreInfo(BeanConvertUtil.beanCovertMap(storePo));
        return saveFlag;
    }

    @Override
    public List<StoreDto> queryStores(@RequestBody  StoreDto storeDto) {

        //校验是否传了 分页信息

        int page = storeDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            storeDto.setPage((page - 1) * storeDto.getRow());
        }

        List<StoreDto> stores = BeanConvertUtil.covertBeanList(storeServiceDaoImpl.getStoreInfo(BeanConvertUtil.beanCovertMap(storeDto)), StoreDto.class);

        return stores;
    }


    @Override
    public int queryStoresCount(@RequestBody StoreDto storeDto) {
        return storeServiceDaoImpl.queryStoresCount(BeanConvertUtil.beanCovertMap(storeDto));    }

    public IStoreServiceDao getStoreServiceDaoImpl() {
        return storeServiceDaoImpl;
    }

    public void setStoreServiceDaoImpl(IStoreServiceDao storeServiceDaoImpl) {
        this.storeServiceDaoImpl = storeServiceDaoImpl;
    }
}
