feat:update userinfo

This commit is contained in:
zhangwenjian committed 2020-08-31 21:18:14 +08:00
1 parent cb06f596e9
commit b98997a69f
11 files changed
+42 -110

No files matched your search

+1
View File
@@ -14,6 +14,7 @@ import (
// CreateAction 通用新增动作
func CreateAction(m model.ActiveRecord) gin.HandlerFunc {
return func(c *gin.Context) {
m.SetCreateBy(tools.GetUserIdStr(c))
object := m.Generate()
var err error
idb, exist := c.Get("db")
+1
View File
@@ -14,6 +14,7 @@ import (
// DeleteAction 通用删除动作
func DeleteAction(m model.ActiveRecord) gin.HandlerFunc {
return func(c *gin.Context) {
m.SetUpdateBy(tools.GetUserIdStr(c))
object := m.Generate()
var err error
idb, exist := c.Get("db")
+5 -2
View File
@@ -33,8 +33,11 @@ func IndexAction(m model.ActiveRecord, d dto.Dtor) gin.HandlerFunc {
tools.HasError(err, "参数验证失败", 422)
err = req.Validate()
tools.HasError(err, "参数验证失败", 422)
p, err := newDataPermission(db, tools.GetUserId(c))
tools.HasError(err, "权限范围鉴定错误", 500)
var p = new(dataPermission)
if userId := tools.GetUserIdStr(c); userId != "" {
p, err = newDataPermission(db, userId)
tools.HasError(err, "权限范围鉴定错误", 500)
}
err = db.WithContext(c).Model(object).
Scopes(
tools.MakeCondition(req.GetNeedSearch()),
+1
View File
@@ -14,6 +14,7 @@ import (
// UpdateAction 通用更新动作
func UpdateAction(m model.ActiveRecord) gin.HandlerFunc {
return func(c *gin.Context) {
m.SetUpdateBy(tools.GetUserIdStr(c))
object := m.Generate()
var err error
idb, exist := c.Get("db")