package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.sys.dao.RdAccountDao;
import io.renren.modules.sys.dto.RdAccountDTO;
import io.renren.modules.sys.entity.RdAccountEntity;
import io.renren.modules.sys.service.RdAccountService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 用户(广告主)资金账户
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2022-06-03
 */
@Service
public class RdAccountServiceImpl extends CrudServiceImpl<RdAccountDao, RdAccountEntity, RdAccountDTO> implements RdAccountService {

    @Override
    public QueryWrapper<RdAccountEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        String advertiserId = (String)params.get("advertiserId");
        String advertiserName = (String)params.get("advertiserName");

        QueryWrapper<RdAccountEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id).eq("status",1)
                .eq(StringUtils.isNotBlank(advertiserId), "advertiser_id", advertiserId)
                .eq(StringUtils.isNotBlank(advertiserName), "advertiser_name", advertiserName)
                .orderByDesc("id");

        return wrapper;
    }


}