package com.sdtool.business.dao;

import com.sdtool.common.entity.doc.BusinessScript;
import com.sdtool.common.entity.system.CompanyInfo;
import com.dySweetFishPlugin.sql.dao.*;
import com.sweetfish.source.PageFlipper;
import org.rex.RMap;

import java.util.List;

@SuppressWarnings({"rawtypes", "unused"})
public interface DocDao extends DaoRepository {


    //region 业务脚本

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
    @SqlId(clazz = DocDao.class, sql = "selectBusinessScript", table = "tbBusinessScript", params = {1})
    List<BusinessScript> selectBusinessScript(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode,
                                              PageFlipper pageFlipper);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = DocDao.class, sql = "addBusinessScript", table = "tbBusinessScript", params = {1})
    void addBusinessScript(BusinessScript businessScript, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = DocDao.class, sql = "updateBusinessScript", table = "tbBusinessScript", params = {1})
    void updateBusinessScript(BusinessScript businessScript, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = DocDao.class, sql = "voidBusinessScript", table = "tbBusinessScript", params = {1})
    void voidBusinessScript(BusinessScript businessScript, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    //endregion

    //region分厂档案
    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
    @SqlId(clazz = DocDao.class, sql = "selectCompanyInfo", table = "tbCompanyInfo", params = {1})
    List<CompanyInfo> selectCompanyInfo(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode, PageFlipper pageFlipper);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = DocDao.class, sql = "addCompanyInfo", table = "tbCompanyInfo", params = {1})
    int addCompanyInfo(CompanyInfo companyInfo, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = DocDao.class, sql = "updateCompanyInfo", table = "tbCompanyInfo", params = {1})
    int updateCompanyInfo(CompanyInfo companyInfo, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = DocDao.class, sql = "voidCompanyInfo", table = "tbCompanyInfo", params = {1})
    int voidCompanyInfo(CompanyInfo companyInfo, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
    //endregion
}
