package com.cm.common.plugin.service.dynamic;

import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.exception.UpdateException;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormFormShowFieldDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormListShowFieldDTO;
import com.cm.common.plugin.pojo.vos.dynamic.DynamicFormVO;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: IDynamicFormService
 * @Description: 动态表单
 * @Author: WangGeng
 * @Date: 2019/12/2 4:04 下午
 * @Version: 1.0
 **/
public interface IDynamicFormService {
    /**
     * 保存动态表单
     *
     * @param dynamicFormVO
     * @return
     * @throws SaveException
     */
    void saveDynamicForm(DynamicFormVO dynamicFormVO) throws SaveException;

    /**
     * 更新动态表单
     *
     * @param dynamicFormVO
     * @throws UpdateException
     */
    void updateDynamicForm(DynamicFormVO dynamicFormVO) throws Exception;

    /**
     * 动态表单详情
     *
     * @param tableName
     * @return
     * @throws SearchException
     */
    List<DynamicFormDTO> listDynamicForm(String tableName) throws SearchException;

    /**
     * 获取列表显示的字段
     *
     * @param tableName
     * @return
     * @throws SearchException
     */
    List<Map<String, Object>> listListShowField(String tableName) throws SearchException;

    /**
     * 获取列表显示的字段
     *
     * @param dynamicFormDTOs
     * @return
     * @throws SearchException
     */
    List<Map<String, Object>> listListShowField(List<DynamicFormDTO> dynamicFormDTOs) throws SearchException;

    /**
     * 获取表单显示的字段
     *
     * @param tableName
     * @return
     * @throws SearchException
     */
    List<String> listFormShowField(String tableName) throws SearchException;

    /**
     * 列表显示的字段
     *
     * @param tableName
     * @param change
     * @return
     * @throws SearchException
     */
    List<DynamicFormListShowFieldDTO> listListShowFieldOfPage(String tableName) throws SearchException;

    /**
     * 表单显示的字段
     *
     * @param tableName
     * @param change
     * @return
     * @throws SearchException
     */
    List<DynamicFormFormShowFieldDTO> listFormShowFieldOfPage(String tableName) throws SearchException;

    /**
     * 连表字段列表
     *
     * @param dynamicFormDTOs
     * @return
     * @throws SearchException
     */
    List<Map<String, Object>> listJoinTableField(List<DynamicFormDTO> dynamicFormDTOs) throws SearchException;

    /**
     * 设置动态表单字段
     *
     * @param mv
     * @param dynamicFormFormShowFieldDTOs
     */
    void setDynamicFieldData(ModelAndView mv, List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs);

    /**
     * 从字段列表中获取字典字段
     *
     * @param dynamicFormDTOs
     * @return
     * @throws SearchException
     */
    List<String> listDataDictionaryField(List<DynamicFormDTO> dynamicFormDTOs) throws SearchException;
}
