✨ account and meta add id
This commit is contained in:
@ -17,6 +17,31 @@ func GetAccounts(c *gin.Context) {
|
||||
SuccessResp(c, accounts)
|
||||
}
|
||||
|
||||
func CreateAccount(c *gin.Context) {
|
||||
var req model.Account
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
driver, ok := drivers.GetDriver(req.Type)
|
||||
if !ok {
|
||||
ErrorResp(c, fmt.Errorf("no [%s] driver", req.Type), 400)
|
||||
return
|
||||
}
|
||||
now := time.Now()
|
||||
req.UpdatedAt = &now
|
||||
if err := model.CreateAccount(req); err != nil {
|
||||
ErrorResp(c, err, 500)
|
||||
} else {
|
||||
err = driver.Save(&req, nil)
|
||||
if err != nil {
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
SuccessResp(c)
|
||||
}
|
||||
}
|
||||
|
||||
func SaveAccount(c *gin.Context) {
|
||||
var req model.Account
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
Reference in New Issue
Block a user