package backend import ( "cron_admin/app/constants/errorcode" "cron_admin/app/http/controllers" "cron_admin/app/http/entities/backend" "cron_admin/app/services/db_service" "cron_admin/app/utils/helper" "cron_admin/app/utils/mapstructure" "github.com/gin-gonic/gin" ) func DbList(c *gin.Context) { request := controllers.GetRequest(c).(*backend.DbListRequest) count, DbListInfo, err := db_service.DbList(request, request.Page, request.Limit) if err != nil { controllers.HandRes(c, nil, errorcode.ParamError) } else { var DbListResponse []backend.DbListResponse _ = mapstructure.DecodeWithTime(DbListInfo, &DbListResponse, helper.DefaultFormatLayout) controllers.HandRes(c, gin.H{"data": DbListResponse, "count": count}, err) } } func DbAdd(c *gin.Context) { request := controllers.GetRequest(c).(*backend.DbAddRequest) err := db_service.DbAdd(request) controllers.HandRes(c, nil, err) } func DbEdit(c *gin.Context) { request := controllers.GetRequest(c).(*backend.DbEditRequest) err := db_service.DbEdit(request) controllers.HandRes(c, nil, err) } func DbDel(c *gin.Context) { request := controllers.GetRequest(c).(*backend.DbDeleteRequest) err := db_service.DbDel(request) controllers.HandRes(c, nil, err) } // 测试连接 func DbTest(c *gin.Context) { request := controllers.GetRequest(c).(*backend.DbTestRequest) err := db_service.DbTest(request) controllers.HandRes(c, nil, err) }