package com.sdtool.business.dao;

import com.sdtool.common.entity.mall.*;
import com.sdtool.common.entity.system.SocialUser;
import com.dySweetFishPlugin.sql.dao.*;
import com.sweetfish.source.PageFlipper;
import org.rex.RMap;

import java.util.List;

/**
 * @Author: xl Created on 2024-03-27
 * @Content:
 */
@SuppressWarnings("rawtypes")
public interface MallDao extends DaoRepository {

    //region 商城用户

    //注意mysql select count 返回的是long类型，不能像sql server用int做返回值
    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
    @SqlId(clazz = MallDao.class, sql = "accountExists", table = "maMallUser", params = {1})
    long accountExists(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
    @SqlId(clazz = MallDao.class, sql = "accountId", table = "maMallUser", params = {1})
    long accountId(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "insertMallLoginUser", table = "maMallUser", params = {1})
    int addMallLoginUser(MallUser mallUser, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "editMallUserPassword", table = "maMallUser", params = {1})
    int editMallLoginUserPassword(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "editMallUserUserName", table = "maMallUser", params = {1})
    int editMallLoginUserName(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "voidMallLoginUser", table = "maMallUser", params = {1})
    int voidMallLoginUser(MallUser mallUser, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "verifyMallLoginUser", table = "maMallUser", params = {1})
    int verifyMallLoginUser(MallUser mallUser, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

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

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

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "setMallUserIdLevel", table = "maMallUser", params = {1})
    int setMallUserIdLevel(List<MallUser> userList, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "setMallUserExpire", table = "maMallUser", params = {1})
    int setMallUserExpire(List<MallUser> userList, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

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

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
    @SqlId(clazz = MallDao.class, sql = "getMallSocialUser", table = "maMallSocialUser", params = {1})
    SocialUser getMallSocialUser(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "bindMallSocialUser", table = "maMallSocialUser", params = {1})
    int bindMallSocialUser(SocialUser socialUser, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "insertMallLoginUser", table = "maMallUser", params = {1}, sort = 1)
    @SqlId(clazz = MallDao.class, sql = "bindMallSocialUser", table = "maMallSocialUser", params = {2}, sort = 2)
    int addMallSocialUser(MallUser mallUser, SocialUser socialUser, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "unBindMallSocialUser", table = "maMallSocialUser", params = {1})
    int unBindMallSocialUser(SocialUser socialUser, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    //endregion

    //region 商城用户地址
    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
    @SqlId(clazz = MallDao.class, sql = "getMallUserAddress", table = "maMallUserAddress", params = {1})
    MallUserAddress getMallUserAddress(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "addMallUserAddress", table = "maMallUserAddress", params = {1})
    int addMallUserAddress(MallUserAddress userAddress, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "editMallUserAddress", table = "maMallUserAddress", params = {1})
    int editMallUserAddress(MallUserAddress userAddress, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

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

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

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "cancelDefaultMallUserAddress", table = "maMallUserAddress", params = {1})
    @SqlId(clazz = MallDao.class, sql = "defaultMallUserAddress", table = "maMallUserAddress", params = {1})
    int defaultMallUserAddress(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
    //endregion



    //region 商城广告位
    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "addPosterLocation", table = "maPosterLocation", params = {1})
    int addPosterLocation(PosterLocation posterLocation, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "editPosterLocation", table = "maPosterLocation", params = {1})
    int editPosterLocation(PosterLocation posterLocation, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

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

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
    @SqlId(clazz = MallDao.class, sql = "queryPosterLocation", table = "maPosterLocation", params = {1})
    List<PosterLocation> queryPosterLocation(RMap params, PageFlipper p, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
    //endregion

    //region 用户级别
    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "insertMallUserLevel", table = "maMallUserLevel", params = {1})
    int addMallUserLevel(MallUserLevel mallUserLevel, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "updateMallUserLevel", table = "maMallUserLevel", params = {1})
    int updateMallUserLevel(MallUserLevel mallUserLevel, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "voidMallUserLevel", table = "maMallUserLevel", params = {1})
    int voidMallUserLevel(MallUserLevel mallUserLevel, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
    @SqlId(clazz = MallDao.class, sql = "queryMallUserLevel", table = "maMallUserLevel", params = {1})
    List<MallUserLevel> queryMallUserLevel(RMap params, PageFlipper p, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
    //endregion

    //region 商城自提地址
    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
    @SqlId(clazz = MallDao.class, sql = "getSelfTakeAddress", table = "maSelfTakeAddress", params = {1})
    SelfTakeAddress getSelfTakeAddress(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "addSelfTakeAddress", table = "maSelfTakeAddress", params = {1})
    int addSelfTakeAddress(SelfTakeAddress selfTakeAddress, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "editSelfTakeAddress", table = "maSelfTakeAddress", params = {1})
    int editSelfTakeAddress(SelfTakeAddress selfTakeAddress, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);

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

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

    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
    @SqlId(clazz = MallDao.class, sql = "cancelDefaultSelfTakeAddress", table = "maSelfTakeAddress", params = {1})
    @SqlId(clazz = MallDao.class, sql = "defaultSelfTakeAddress", table = "maSelfTakeAddress", params = {1})
    int defaultSelfTakeAddress(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
    //endregion
}
