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.project.ProjectQueryRequest;
import com.greenorange.promotion.model.entity.Project;
import com.greenorange.promotion.model.entity.UserInfo;
import com.greenorange.promotion.service.project.ProjectService;
import com.greenorange.promotion.mapper.ProjectMapper;
import com.greenorange.promotion.utils.SqlUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
* @author 35880
* @description 针对表【project(项目表)】的数据库操作Service实现
* @createDate 2025-05-06 14:19:08
*/
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project>
    implements ProjectService{

    /**
     * 获取查询条件
     */
    @Override
    public QueryWrapper<Project> getQueryWrapper(ProjectQueryRequest projectQueryRequest) {
        Long id = projectQueryRequest.getId();
        String projectName = projectQueryRequest.getProjectName();
        String sortField = projectQueryRequest.getSortField();
        String sortOrder = projectQueryRequest.getSortOrder();
        QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(id != null, "id", id);
        queryWrapper.eq(StringUtils.isNotBlank(projectName), "projectName", projectName);
        queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField);
        return queryWrapper;
    }
}




