package apigen

import "git.qianqiusoft.com/qianqiusoft/light-apiengine-client/code_gen/utils"

const countTmpl = `
SELECT
    count(*) records
FROM
    {{.data.Name}}
WHERE
    del_flag = 0
`

const selectTmpl = `
SELECT
    {{.data.Name}}.*
FROM
    {{.data.Name}}
WHERE
    del_flag = 0
{{Unescaped "LIMIT {{.rows}} OFFSET {{.offset}}"}}
`

func GenCount(templateData interface{}, params map[string]interface{}) ([]byte, error) {
	return utils.GenTemplate(countTmpl, templateData, params)
}

func GenSelect(templateData interface{}, params map[string]interface{}) ([]byte, error) {
	return utils.GenTemplate(selectTmpl, templateData, params)
}
