package com.njcn.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.system.mapper.MxGraphMapper;
import com.njcn.system.pojo.param.MxGraphParam;
import com.njcn.system.pojo.po.MxGraph;
import com.njcn.system.service.IMxGraphService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * pqs
 *
 * @author cdf
 * @date 2022/1/26
 */
@Service
@RequiredArgsConstructor
public class MxGraphServiceImpl extends ServiceImpl<MxGraphMapper, MxGraph> implements IMxGraphService {

    private final MxGraphMapper mxGraphMapper;

    @Override
    public boolean addKingView(MxGraphParam mxGraphParam) {
        MxGraph mxGraph = new MxGraph();
        BeanUtils.copyProperties(mxGraphParam,mxGraph);
        mxGraph.setState(DataStateEnum.ENABLE.getCode());
        return this.save(mxGraph);
    }

    @Override
    public List<MxGraph> getKingViewList() {
        LambdaQueryWrapper<MxGraph> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.orderByAsc(MxGraph::getSort);
        return this.list(lambdaQueryWrapper);
    }

    @Override
    public MxGraph getKingViewById(String id) {
        return this.getById(id);
    }
}
