package com.greenorange.promotion.service.userInfo.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.advancementApply.AdvancementApplyQueryRequest;
import com.greenorange.promotion.model.entity.AdvancementApply;
import com.greenorange.promotion.service.userInfo.AdvancementApplyService;
import com.greenorange.promotion.mapper.AdvancementApplyMapper;
import com.greenorange.promotion.utils.SqlUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
* @author 35880
* @description 针对表【advancement_apply(晋升申请表)】的数据库操作Service实现
* @createDate 2025-06-29 12:39:54
*/
@Service
public class AdvancementApplyServiceImpl extends ServiceImpl<AdvancementApplyMapper, AdvancementApply>
    implements AdvancementApplyService{

    /**
     * 获取查询条件
     */
    @Override
    public QueryWrapper<AdvancementApply> getQueryWrapper(AdvancementApplyQueryRequest advancementApplyQueryRequest) {
        String name = advancementApplyQueryRequest.getName();
        String phone = advancementApplyQueryRequest.getPhone();
        String reviewStatus = advancementApplyQueryRequest.getReviewStatus();
        String sortField = advancementApplyQueryRequest.getSortField();
        String sortOrder = advancementApplyQueryRequest.getSortOrder();
        QueryWrapper<AdvancementApply> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(name), "name", name);
        queryWrapper.eq(StringUtils.isNotBlank(phone), "phone", phone);
        queryWrapper.eq(StringUtils.isNotBlank(reviewStatus), "reviewStatus", reviewStatus);
        queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_DESC), sortField);
        return queryWrapper;
    }
}




