You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* @Title:
* @Description:
* @Author: Yuki Wong(iyuki0430@msn.com)
* @Update:
* @Date: 2020/7/20 11:49
* @File: DataerrorDAO.go
* @Software: GoLand
**/
package DataerrorDAO
import (
"dsSupport/MyModel/MySwagger"
"dsSupport/Utils/DbUtil"
"dsSupport/Utils/ErrorConst"
"dsSupport/Utils/LogUtil"
"dsSupport/models"
"fmt"
)
//数据库
var db = DbUtil.Engine
func GetDataerrorResults(query MySwagger.DataerrorQuery) (bool, string, int, []map[string]interface{}, error) {
sql := "SELECT * FROM t_dataex_error WHERE 1 = 1" + query.Conditions + " ORDER BY create_time DESC, change_time DESC"
//接收传入参数
var limit = 100
var offset = (query.Page - 1) * limit
//条件查询语句
conditionSql := fmt.Sprintf("%s", " limit ? offset ? ")
//分页的语句
pageSql := fmt.Sprintf("%s %s", sql, conditionSql)
//数据条数
count, _ := DbUtil.Engine.SQL(sql).Query().Count()
//分页数据
list, err := DbUtil.Engine.SQL(pageSql, limit, offset).Query().List()
if list != nil {
return true, "数据获取成功", count, list, err
} else {
return false, "数据获取失败,数据源不存在", count, nil, nil
}
}
func RemoveDataerror(id string, model *models.TDataexError) (bool, string, error) {
_, err := db.Where(" id = ?", id).Update(model)
if err != nil {
LogUtil.Error(ErrorConst.SqlUpdateError, "接入系统authToken Update数据库操作发生严重错误"+err.Error())
return false, "数据库操作失败", err
}
return true, "删除成功!", nil
}