feat:update tpl

This commit is contained in:
zhangwenjian committed 2020-09-29 12:23:16 +08:00
1 parent bc648c3f2f
commit ca8d1e7e33
9 files changed
+24 -42

No files matched your search

+1 -8
View File
@@ -56,7 +56,6 @@ func (e *Scol) GetScolList(c *gin.Context) {
func (e *Scol) GetScol(c *gin.Context) {
control := new(dto.ScolById)
db, err := tools.GetOrm(c)
if err != nil {
log.Error(err)
return
@@ -70,12 +69,7 @@ func (e *Scol) GetScol(c *gin.Context) {
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
return
}
var object common.ActiveRecord
object, err = control.GenerateM()
if err != nil {
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
return
}
var object models.Scol
//数据权限检查
p := actions.GetPermissionFromContext(c)
@@ -201,7 +195,6 @@ func (e *Scol) DeleteScol(c *gin.Context) {
serviceScol := service.Scol{}
serviceScol.Orm = db
serviceScol.MsgID = msgID
err = serviceScol.RemoveScol(req, object, p)
if err != nil {
log.Error(err)
+9 -9
View File
@@ -21,7 +21,7 @@ func (e *Scol) GetScolPage(c cDto.Index, p *actions.DataPermission, list *[]mode
var data models.Scol
msgID := e.MsgID
err = e.Orm.Table(data.TableName()).
err = e.Orm.Model(&data).
Scopes(
cDto.MakeCondition(c.GetNeedSearch()),
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
@@ -37,17 +37,17 @@ func (e *Scol) GetScolPage(c cDto.Index, p *actions.DataPermission, list *[]mode
}
// GetScol 获取Scol对象
func (e *Scol) GetScol(c cDto.Control, p *actions.DataPermission, m *common.ActiveRecord) error {
func (e *Scol) GetScol(d cDto.Control, p *actions.DataPermission, model *models.Scol) error {
var err error
var data models.Scol
msgID := e.MsgID
db := e.Orm.Table(data.TableName()).
db := e.Orm.Model(&data).
Scopes(
actions.Permission(data.TableName(), p),
).Where(c.GetId()).First(m)
).
First(model, d.GetId())
err = db.Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
log.Errorf("msgID[%s] db error:%s", msgID, err)
@@ -66,7 +66,7 @@ func (e *Scol) InsertScol(model common.ActiveRecord) error {
var data models.Scol
msgID := e.MsgID
err = e.Orm.Table(data.TableName()).
err = e.Orm.Model(&data).
Create(model).Error
if err != nil {
log.Errorf("msgID[%s] db error:%s", msgID, err)
@@ -81,7 +81,7 @@ func (e *Scol) UpdateScol(c common.ActiveRecord, p *actions.DataPermission) erro
var data models.Scol
msgID := e.MsgID
db := e.Orm.Table(data.TableName()).
db := e.Orm.Model(&data).
Scopes(
actions.Permission(data.TableName(), p),
).Where(c.GetId()).Updates(c)
@@ -102,7 +102,7 @@ func (e *Scol) RemoveScol(d cDto.Control, c common.ActiveRecord, p *actions.Data
var data models.Scol
msgID := e.MsgID
db := e.Orm.Table(data.TableName()).
db := e.Orm.Model(&data).
Scopes(
actions.Permission(data.TableName(), p),
).Where(d.GetId()).Delete(c)
@@ -116,4 +116,4 @@ func (e *Scol) RemoveScol(d cDto.Control, c common.ActiveRecord, p *actions.Data
return err
}
return nil
}
}