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/Dic_NationManager.go

92 lines
1.9 KiB
Go

4 weeks ago
package DAL
import (
"flx/Model"
"fmt"
"strconv"
log "github.com/sirupsen/logrus"
)
func GetAllDic_Nation() []Model.T_Dic_Nation {
defer func() {
if r := recover(); r != nil {
log.Error("GetAllDic_Nation:", r)
}
}()
rows, err := ConntectDB().Query("SELECT * FROM dbcongress.T_Dic_Nation")
if err != nil {
fmt.Println(err.Error())
}
defer rows.Close()
var AllDic_Nation []Model.T_Dic_Nation
for rows.Next() {
var CDic_Nation Model.T_Dic_Nation
err := rows.Scan(&CDic_Nation.DN_NationID, &CDic_Nation.DN_NationName, &CDic_Nation.DN_NationName)
if err != nil {
fmt.Println(err.Error())
// break
}
AllDic_Nation = append(AllDic_Nation, CDic_Nation)
}
return AllDic_Nation
}
func InsertDic_Nation(para *Model.T_Dic_Nation) bool {
defer func() {
if r := recover(); r != nil {
log.Error("InsertDic_Nation:", r)
}
}()
_, err := ConntectDB().Exec("INSERT INTO dbcongress.T_Dic_Nation (\"DN_NationID\", \"DN_NationName\", \"DN_NationValue\") VALUES('" + para.DN_NationID + "', '" + para.DN_NationName + "', '" + strconv.Itoa(para.DN_NationValue) + "')")
if err != nil {
fmt.Println(err.Error())
return false
}
return true
}
func UpdateDic_Nation(para *Model.T_Dic_Nation) bool {
defer func() {
if r := recover(); r != nil {
log.Error("UpdateDic_Nation:", r)
}
}()
_, err := ConntectDB().Exec("UPDATE dbcongress.T_Dic_Nation SET \"DN_NationName\"='" + para.DN_NationName + "', \"DN_NationValue\"='" + strconv.Itoa(para.DN_NationValue) + "' WHERE \"Ca_ID\"='" + para.DN_NationID + "';")
if err != nil {
fmt.Println(err.Error())
return false
}
return true
}
func DeleteDic_Nation(para *Model.T_Dic_Nation) bool {
defer func() {
if r := recover(); r != nil {
log.Error("DeleteDic_Nation:", r)
}
}()
_, err := ConntectDB().Exec("DELETE FROM dbcongress.T_Dic_Nation WHERE \"DN_NationID\"='" + para.DN_NationID + "'")
if err != nil {
fmt.Println(err.Error())
return false
}
return true
}