package com.tduck.cloud.form.service.impl;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tduck.cloud.form.entity.UserFormEntity;
import com.tduck.cloud.form.mapper.UserFormMapper;
import com.tduck.cloud.form.service.UserFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 表单主表(Form)表服务实现类
 *
 * @author smalljop
 * @since 2020-11-18 18:16:18
 */
@Service
public class UserFormServiceImpl extends ServiceImpl<UserFormMapper, UserFormEntity> implements UserFormService {

    @Autowired
    UserFormMapper userFormMapper;
    @Override
    public UserFormEntity getByKey(final String key) {
        if (StrUtil.isBlank(key)) {
            return null;
        }
        UserFormEntity entity = this.getOne(Wrappers.<UserFormEntity>lambdaQuery().eq(UserFormEntity::getKey, key));
        return entity;
    }

    @Override
    public void executeSql(String sql) {
        userFormMapper.executeSql(sql);
    }

    @Override
    public String checkTable(String sql) {
        return userFormMapper.checkTable(sql);
    }

    @Override
    public List<JSONObject> getColumns(String sql) {
        return userFormMapper.getColumns(sql);
    }
}