package com.crunii.micro.service.sysmgr.jdbc;

import com.crunii.micro.domain.common.jdbc.BaseJdbcTemplate;
import com.crunii.micro.domain.entity.main.YcqDynamicFormConfig;
import com.crunii.micro.domain.entity.main.YcqDynamicFormContent;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Repository
public class YcqDynamicFormContentDao {

    @Resource(name = "mainJT")
    protected BaseJdbcTemplate JT;


    public List<YcqDynamicFormContent> listByBusinessIdList(List<Long> ids){
        String sql = "select * from ycq_dynamic_form_content where business_id in(";
        String collect = ids.stream().map(item -> item + "").collect(Collectors.joining(","));
        sql += collect + ") order by create_time desc";
        return JT.queryForBeans(YcqDynamicFormContent.class, sql);
    }

    public List<YcqDynamicFormContent> listByIdList(List<Long> ids){
        String sql = "select * from ycq_dynamic_form_content where id in(";
        String collect = ids.stream().map(item -> item + "").collect(Collectors.joining(","));
        sql += collect + ") order by create_time desc";
        return JT.queryForBeans(YcqDynamicFormContent.class, sql);
    }
}
