package com.greenorange.promotion.service.project.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.greenorange.promotion.constant.CommonConstant;
import com.greenorange.promotion.model.dto.promoCodeApply.PromoCodeApplyQueryRequest;
import com.greenorange.promotion.model.entity.Project;
import com.greenorange.promotion.model.entity.PromoCodeApply;
import com.greenorange.promotion.service.project.PromoCodeApplyService;
import com.greenorange.promotion.mapper.PromoCodeApplyMapper;
import com.greenorange.promotion.utils.SqlUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
* @author 35880
* @description 针对表【promo_code_apply(推广码申请记录表)】的数据库操作Service实现
* @createDate 2025-05-10 19:53:05
*/
@Service
public class PromoCodeApplyServiceImpl extends ServiceImpl<PromoCodeApplyMapper, PromoCodeApply>
    implements PromoCodeApplyService{

    /**
     * 获取查询条件
     */
    @Override
    public QueryWrapper<PromoCodeApply> getQueryWrapper(PromoCodeApplyQueryRequest promoCodeApplyQueryRequest) {
        String salespersonPhone = promoCodeApplyQueryRequest.getSalespersonPhone();
        String sortField = promoCodeApplyQueryRequest.getSortField();
        String sortOrder = promoCodeApplyQueryRequest.getSortOrder();
        QueryWrapper<PromoCodeApply> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(salespersonPhone), "salespersonPhone", salespersonPhone);
        queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField);
        return queryWrapper;
    }
}




