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.
97 lines
2.4 KiB
Go
97 lines
2.4 KiB
Go
package DAL
|
|
|
|
import (
|
|
"flx/Model"
|
|
"fmt"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func GetAllStaffGroup() []Model.T_StaffGroup {
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
log.Error("GetAllStaffGroup:", r)
|
|
}
|
|
}()
|
|
|
|
rows, err := ConntectDB().Query("SELECT \"Gr_ID\",\"Gr_Name\",\"Gr_Num\",\"Gr_Remarks\" FROM dbcongress.t_staffgroup")
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
}
|
|
defer rows.Close()
|
|
|
|
var AllStaffGroup []Model.T_StaffGroup
|
|
for rows.Next() {
|
|
var CStaffGroup Model.SQLT_StaffGroup
|
|
err := rows.Scan(&CStaffGroup.Gr_ID, &CStaffGroup.Gr_Name, &CStaffGroup.Gr_Num, &CStaffGroup.Gr_Remarks)
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
// break
|
|
}
|
|
var CCStaffGroup Model.T_StaffGroup
|
|
CCStaffGroup.Gr_ID = ChangeT(CStaffGroup.Gr_ID.Valid, CStaffGroup.Gr_ID.String).(string)
|
|
CCStaffGroup.Gr_Name = ChangeT(CStaffGroup.Gr_Name.Valid, CStaffGroup.Gr_Name.String).(string)
|
|
CCStaffGroup.Gr_Num = ChangeT(CStaffGroup.Gr_Num.Valid, CStaffGroup.Gr_Num.String).(string)
|
|
CCStaffGroup.Gr_Remarks = ChangeT(CStaffGroup.Gr_Remarks.Valid, CStaffGroup.Gr_Remarks.String).(string)
|
|
|
|
AllStaffGroup = append(AllStaffGroup, CCStaffGroup)
|
|
}
|
|
return AllStaffGroup
|
|
|
|
}
|
|
|
|
func InsertStaffGroup(para *Model.T_StaffGroup) bool {
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
log.Error("InsertStaffGroup:", r)
|
|
}
|
|
}()
|
|
|
|
_, err := ConntectDB().Exec("INSERT INTO dbcongress.t_staffgroup (\"Gr_ID\", \"Gr_Name\", \"Gr_Num\", \"Gr_Remarks\") VALUES('" + para.Gr_ID + "', '" + para.Gr_Name + "', '" + para.Gr_Num + "', '" + para.Gr_Remarks + "')")
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
return false
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
func UpdateStaffGroup(para *Model.T_StaffGroup) bool {
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
log.Error("UpdateStaffGroup:", r)
|
|
}
|
|
}()
|
|
|
|
_, err := ConntectDB().Exec("UPDATE dbcongress.t_staffgroup SET \"Gr_Name\"='" + para.Gr_Name + "', \"Gr_Num\"='" + para.Gr_Num + "', \"Gr_Remarks\"='" + para.Gr_Remarks + "' WHERE \"Gr_ID\"='" + para.Gr_ID + "';")
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
return false
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
func DeleteStaffGroup(para *Model.T_StaffGroup) bool {
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
log.Error("DeleteStaffGroup:", r)
|
|
}
|
|
}()
|
|
|
|
_, err := ConntectDB().Exec("DELETE FROM dbcongress.t_staffgroup WHERE \"Gr_ID\"='" + para.Gr_ID + "'")
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
return false
|
|
}
|
|
|
|
return true
|
|
|
|
}
|