package com.boman.web.core.service.submit;

import com.alibaba.fastjson.JSONObject;
import com.boman.web.core.mapper.StandardlyMapper;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;

import static com.boman.common.core.utils.obj.ObjectUtils.requireNonNull;


/**
 * @author shiqian
 * @date 2021年04月01日 14:56
 **/
@Service
public class BaseSubmitServiceImpl implements IBaseSubmitService {


    @Autowired
    private StandardlyMapper mapper;

    /**
     * 功能描述: 处理提交流程
     *
     * @param tableName tableName
     * @param pkName    pkName
     * @param model     model
     * @param id        主键
     * @return int
     */
    @Override
    public int handlerSubmit(String tableName, String pkName, JSONObject model, Long id) {
        requireNonNull(model, "提交的数据为空");
        return mapper.updateByIdList(tableName, pkName, Lists.newArrayList(id), model);
    }
}
