package com.persagy.dmp.rwd.define.controller;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.persagy.dmp.basic.dto.DefineRequestData;
import com.persagy.dmp.basic.model.QueryCriteria;
import com.persagy.dmp.basic.utils.QueryCriteriaHelper;
import com.persagy.dmp.common.constant.CommonConstant;
import com.persagy.dmp.common.constant.ResponseCode;
import com.persagy.dmp.common.exception.BusinessException;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.common.utils.ParamCheckUtil;
import com.persagy.dmp.common.utils.ResultHelper;
import com.persagy.dmp.define.entity.DigitalEquipClassRel;
import com.persagy.dmp.define.entity.RelationDefine;
import com.persagy.dmp.mybatis.utils.ConditionUtil;
import com.persagy.dmp.rwd.define.service.DigitalEquipClassRelService;
import com.persagy.dmp.rwd.define.service.IRelationDefineService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/***
 * Description:项目对象类型关系 Controller
 * @author : lijie
 * @date :2021/9/14 22:50
 * Update By lijie 2021/9/14 22:50
 */
@RestController
@RequestMapping("/rwd/def/equipClassRel")
@RequiredArgsConstructor
public class DigitalEquipClassRelController {

    private final DigitalEquipClassRelService service;

    /***
     * Description: 查询项目对象类型关系
     * @param criteria : 查询条件
     * @return : com.persagy.dmp.common.model.response.CommonResult<java.util.List<com.persagy.dmp.define.entity.DigitalEquipClassRel>>
     * @author : lijie
     * @date :2021/9/14 22:51
     * Update By lijie 2021/9/14 22:51
     */
    @PostMapping("/query")
    public CommonResult<List<DigitalEquipClassRel>> query(@RequestBody QueryCriteria criteria) {
        if(criteria == null) {
            throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
        }
        //基础参数校验
        ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE);
        return service.query(criteria);
    }
    /***
     * Description: 批量创建项目对象类型关系
     * @param vo :
     * @return : com.persagy.dmp.common.model.response.CommonResult<java.util.List<com.persagy.dmp.define.entity.DigitalEquipClassRel>>
     * @author : lijie
     * @date :2021/9/14 22:49
     * Update By lijie 2021/9/14 22:49
     */
    @PostMapping("/create")
    public CommonResult<List<DigitalEquipClassRel>> create(@RequestBody List<DigitalEquipClassRel> vo){
        //基础参数校验
        ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE,CommonConstant.QUERY_PROJECTID);
        return ResultHelper.single(service.create(vo));
    }
    /***
     * Description: 根据边关系名称查询项目对象类型关系列表
     * @param defineRequestData : 请求参数
     * @return : com.persagy.dmp.common.model.response.CommonResult<java.util.List<com.persagy.dmp.define.entity.DigitalEquipClassRel>>
     * @author : lijie
     * @date :2021/9/14 22:51
     * Update By lijie 2021/9/14 22:51
     */
    @PostMapping("/queryListByRelNames")
    public CommonResult<List<DigitalEquipClassRel>> queryListByRelNames(@RequestBody DefineRequestData defineRequestData) {
        //基础参数校验
        ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE);
        return service.queryListByRelNames(defineRequestData);
    }

}
