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

92 lines
2.2 KiB
Go

4 weeks ago
package DAL
import (
"flx/Model"
"fmt"
"strconv"
log "github.com/sirupsen/logrus"
)
func GetAllDictionary() []Model.T_Dictionary {
defer func() {
if r := recover(); r != nil {
log.Error("GetAllDictionary:", r)
}
}()
rows, err := ConntectDB().Query("SELECT * FROM dbcongress.T_Dictionary")
if err != nil {
fmt.Println(err.Error())
}
defer rows.Close()
var AllDictionary []Model.T_Dictionary
for rows.Next() {
var CDictionary Model.T_Dictionary
err := rows.Scan(&CDictionary.Dic_ID, &CDictionary.Dic_Sort, &CDictionary.Dic_Name, &CDictionary.Dic_ParentID, &CDictionary.Dic_Serial, &CDictionary.Dic_Describe)
if err != nil {
fmt.Println(err.Error())
// break
}
AllDictionary = append(AllDictionary, CDictionary)
}
return AllDictionary
}
func InsertDictionary(para *Model.T_Dictionary) bool {
defer func() {
if r := recover(); r != nil {
log.Error("InsertDictionary:", r)
}
}()
_, err := ConntectDB().Exec("INSERT INTO dbcongress.T_Dictionary (\"Dic_ID\", \"Dic_Sort\", \"Dic_Name\", \"Dic_ParentID\", \"Dic_Serial\", \"Dic_Describe\") VALUES('" + para.Dic_ID + "', '" + para.Dic_Sort + "', '" + para.Dic_Name + "', '" + para.Dic_ParentID + "', " + strconv.Itoa(para.Dic_Serial) + ", '" + para.Dic_Describe + "')")
if err != nil {
fmt.Println(err.Error())
return false
}
return true
}
func UpdateDictionary(para *Model.T_Dictionary) bool {
defer func() {
if r := recover(); r != nil {
log.Error("UpdateDictionary:", r)
}
}()
_, err := ConntectDB().Exec("UPDATE dbcongress.T_Dictionary SET \"Dic_Sort\"='" + para.Dic_Sort + "', \"Dic_Name\"='" + para.Dic_Name + "', \"Dic_ParentID\"='" + para.Dic_ParentID + "', \"Dic_Serial\"=" + strconv.Itoa(para.Dic_Serial) + ", \"Dic_Describe\"='" + para.Dic_Describe + "' WHERE \"Dic_ID\"='" + para.Dic_ID + "';")
if err != nil {
fmt.Println(err.Error())
return false
}
return true
}
func DeleteDictionary(para *Model.T_Dictionary) bool {
defer func() {
if r := recover(); r != nil {
log.Error("DeleteDictionary:", r)
}
}()
_, err := ConntectDB().Exec("DELETE FROM dbcongress.T_Dictionary WHERE \"Dic_ID\"='" + para.Dic_ID + "'")
if err != nil {
fmt.Println(err.Error())
return false
}
return true
}