/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.manager.mapper;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.manager.dto.WbsTreeDTO2;
import org.springblade.manager.entity.WbsFormElement;
import org.springblade.manager.entity.WbsTree;
import org.springblade.manager.vo.*;

import java.util.List;

/**
 * Mapper 接口
 *
 * @author liuyc
 * @since 2022-04-25
 */
public interface WbsTreeMapper extends BaseMapper<WbsTree> {

    /**
     * 自定义分页
     *
     * @param page
     * @param wbsTree
     * @return
     */
    List<WbsTreeVO> selectWbsTreePage(IPage page, WbsTreeVO wbsTree);


    /**
     * 懒加载获取树形节点
     *
     * @param tenantId
     * @param parentId
     * @return
     */
    List<WbsTreeVO> lazyTree(@Param("wbsId") String wbsId,
                             @Param("tenantId") String tenantId,
                             @Param("parentId") Long parentId);

    /**
     * 获取树形节点
     *
     * @param tenantId
     * @return
     */
    List<WbsTreeVO> tree(@Param("wbsId") String wbsId, @Param("tenantId") String tenantId, @Param("type") String type);


    /**
     * 表单查询（根据节点ID查询当前表单）
     */
    List<WbsNodeTableVO> selectByNodeTable(@Param("id") String id);

    /**
     * 根据Ids查询元素
     */
    List<String> selectByElementsTotal(@Param("ids") List<String> ids);

    /**
     * 表单删除
     */
    Integer removeTableById(@Param("id") String id);

    /**
     * 表单元素
     */
    List<WbsFormElementVO> selectFormElements(@Param("id") String id);


    /**
     * 新增表单
     */
    Integer insertForm(WbsTree wbsTree);

    /**
     * 新增元素
     */
    Integer addFormElement(WbsFormElement wbsFormElement);

    Integer updateById2(@Param("ancestors") String ancestors, @Param("id") Long id);

    Integer updateById3(@Param("id") Long id, @Param("parentId") Long parentId);

    void createWbsTreeTable(@Param("tableName") String tableName);

    Integer insertWbsTreePrivate(@Param("projectId") String projectId, @Param("wbsTree") WbsTree wbsTree);

    Boolean insertWbsTreeContract(@Param("projectId") String projectId, @Param("contractId") String contractId, @Param("wbsTree") WbsTree wbsTree);

    Integer selectRepeatByProjectId(String projectId);

    List<WbsTree> findAllNodeTableList(String wbsId);

    List<WbsTree> selectIsTable(Long tableParentId);

    int deleteBatchProjectNodeId(Long projectNodeId);

    WbsTree selectByWbsId(Long id);

    int updateByCondition(@Param("id") Long id, @Param("wbsName") String wbsName, @Param("status") Integer status);

    List<SaveUserInfoByProjectVO2> selectListByUserId(Long userId);

    List<WbsTreeDTO2> selectWbsTreeListByParentId(String parentId);

    void updateSortById(String id, Integer sort);

    int deleteLogicByWbsId(String ids);

    int updateIsExistFormById(Long id);

    Integer createTable(String tableName);

    void alterTableFiled(String initTableName, String eKey, String eType, Integer eLength);
}
