代码拉取完成,页面将自动刷新
package dplog
import (
"gitee.com/yysf_xin/dplog/pkg/push"
"gitee.com/yysf_xin/go-common/db"
"gitee.com/yysf_xin/go-notifier"
"strings"
"testing"
"text/template"
"time"
)
func TestTpl2(t *testing.T) {
tpl := template.New("aa")
notifier.Init(tpl)
var demoTmpl = "{\"msg\": \"{{ . | SafeTruncate 500 | json}}\"}"
tp, _ := tpl.Parse(demoTmpl)
data := "\norg.springframework.jdbc.BadSqlGrammarException: \n### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and data_flag = 1' at line 6\n### The error may exist in class path resource [mybatis/mapper/order/GroupOrderExtendMapper.xml]\n### The error may involve defaultParameterMap\n### The error occurred while setting parameters\n### SQL: select order_id, `account`, extend, sub_order_status, stock_up_time, sync_third_order_status, status_time, sale_type, pre_delivery_date from sf_group_order_extend where and data_flag = 1\n### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and data_flag = 1' at line 6\n; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and data_flag = 1' at line 6\n\tat org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:239)\n\tat org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)\n hidden 1 elements\n\tat com.feng1.mybatis.SmartSqlSessionTemplate$SqlSessionInterceptor.invoke(SmartSqlSessionTemplate.java:138)"
buff := strings.Builder{}
err := tp.Execute(&buff, data)
if err != nil {
panic(err)
}
println(buff.String())
println("{\"msg\": \"\\norg.springframework.jdbc.BadSqlGrammarException: \\n### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and data_flag = 1' at line 6\\n### The error may exist in class path resource [mybatis/mapper/order/GroupOrderExtendMapper.xml]\\n### The error may involve defaultParameterMap\\n### The error occurred while setting parameters\\n### SQL: select order_id, `account`, extend, sub_order_status, stock_up_time, sync_third_order_status, status_time, sale_type, pre_delivery_date from sf_group_order_extend where and data_flag = 1\\n### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and data_flag = 1' at line 6\\n; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and data_flag = 1' at line 6\\n\\tat org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:239)\\n\\tat org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)\\n hidden 1 elements\\n\\tat com.feng1.mybatis.SmartSqlSessionTemplate$SqlSessionInterceptor.invoke(SmartSqlSessionTemplate.java:138)\",\n")
//println(template.JSEscapeString(data))
}
func TestTplDate(t *testing.T) {
tpl := template.New("aa")
notifier.Init(tpl)
msg := push.Msg{}
msg.Last = db.Time(time.Now())
msg.Msg.Time = time.Now()
tp, _ := tpl.Parse("{{.Msg.Time.Format \"01-02 15:04\"}} ")
buff := strings.Builder{}
err := tp.Execute(&buff, &msg)
if err != nil {
panic(err)
}
println(buff.String())
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。