package com.gxwebsoft.pwl.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.service.UserService;
import com.gxwebsoft.pwl.mapper.PwlProjectMapper;
import com.gxwebsoft.pwl.service.PwlProjectService;
import com.gxwebsoft.pwl.entity.PwlProject;
import com.gxwebsoft.pwl.param.PwlProjectParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * 卫兰的项目项目系统Service实现
 *
 * @author 科技小王子
 * @since 2025-03-22 14:34:35
 */
@Service
public class PwlProjectServiceImpl extends ServiceImpl<PwlProjectMapper, PwlProject> implements PwlProjectService {
    @Override
    public PageResult<PwlProject> pageRel(PwlProjectParam param) {
        PageParam<PwlProject, PwlProjectParam> page = new PageParam<>(param);
        page.setDefaultOrder("sort_number asc, create_time desc");
        List<PwlProject> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<PwlProject> listRel(PwlProjectParam param) {
        List<PwlProject> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<PwlProject, PwlProjectParam> page = new PageParam<>();
        page.setDefaultOrder("sort_number asc, create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public PwlProject getByIdRel(Integer id) {
        PwlProjectParam param = new PwlProjectParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

    @Override
    public List<User> listByCount() {
        return baseMapper.listByCount();
    }

}
