feat:完善项目信息

This commit is contained in:
henry
2022-01-21 14:16:48 +08:00
parent 1c027dd2d1
commit adb5bd7283
9 changed files with 158 additions and 8 deletions

View File

@ -195,6 +195,20 @@ func (*Technology) ProductDetail(c *gin.Context) {
api.APIResponse(err, data)(c) api.APIResponse(err, data)(c)
} }
func (*Technology) ProductExamine(c *gin.Context) {
form := &struct {
api.TenantIDStringForm
Status int `json:"status" form:"status"`
Remark string `json:"remark" form:"remark"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology.NewProduct()(api.GetSession()(c).(*session.Admin)).Examine(form.Convert(), form.Status, form.Remark)
api.APIResponse(err)(c)
}
func (*Technology) ProductDelete(c *gin.Context) { func (*Technology) ProductDelete(c *gin.Context) {
form := new(api.IDStringForm) form := new(api.IDStringForm)
@ -220,6 +234,20 @@ func (*Technology) Achievement(c *gin.Context) {
api.APIResponse(err, data)(c) api.APIResponse(err, data)(c)
} }
func (*Technology) AchievementExamine(c *gin.Context) {
form := &struct {
api.TenantIDStringForm
Status int `json:"status" form:"status"`
Remark string `json:"remark" form:"remark"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology.NewAchievement()(api.GetSession()(c).(*session.Admin)).Examine(form.Convert(), form.Status, form.Remark)
api.APIResponse(err)(c)
}
func (*Technology) AchievementDetail(c *gin.Context) { func (*Technology) AchievementDetail(c *gin.Context) {
form := new(api.IDStringForm) form := new(api.IDStringForm)
@ -269,6 +297,20 @@ func (*Technology) DemandDetail(c *gin.Context) {
api.APIResponse(err, data)(c) api.APIResponse(err, data)(c)
} }
func (*Technology) DemandExamine(c *gin.Context) {
form := &struct {
api.TenantIDStringForm
Status int `json:"status" form:"status"`
Remark string `json:"remark" form:"remark"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology.NewDemand()(api.GetSession()(c).(*session.Admin)).Examine(form.Convert(), form.Status, form.Remark)
api.APIResponse(err)(c)
}
func (*Technology) DemandDelete(c *gin.Context) { func (*Technology) DemandDelete(c *gin.Context) {
form := new(api.IDStringForm) form := new(api.IDStringForm)

View File

@ -82,6 +82,27 @@ func (c *Achievement) Detail(id uint64) (*AchievementDetailInfo, error) {
}, nil }, nil
} }
// Examine 审核操作
func (c *Achievement) Examine(id uint64, status int, remark string) error {
mTechnologyAchievement := model.NewTechnologyAchievement()
mTechnologyAchievement.ID = id
isExist, err := model2.FirstField(mTechnologyAchievement.TechnologyAchievement, []string{"id", "tenant_id", "status"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,成果品信息不存在或已被删除")
}
if c.TenantID > 0 && mTechnologyAchievement.TenantID != c.TenantID {
return errors.New("操作错误,无权限操作")
}
if mTechnologyAchievement.Status != model2.TechnologyStatusKindForExamining {
return errors.New("操作错误,当前成果状态不允许审核")
}
return handleExamine(mTechnologyAchievement.TechnologyAchievement, c.UID, model2.SysUserExamineLogKindForAchievement, status, remark)
}
func (c *Achievement) Delete(id uint64) error { func (c *Achievement) Delete(id uint64) error {
mTechnologyAchievement := model.NewTechnologyAchievement() mTechnologyAchievement := model.NewTechnologyAchievement()
mTechnologyAchievement.ID = id mTechnologyAchievement.ID = id

View File

@ -1,7 +1,28 @@
package technology package technology
import model2 "SciencesServer/app/common/model" import (
"SciencesServer/app/api/admin/model"
func handleExamine(iModel model2.IModel, status int) { model2 "SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"gorm.io/gorm"
"time"
)
func handleExamine(iModel model2.IModel, uid uint64, kind model2.SysUserExamineLogKind, status int, remark string) error {
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
err := model2.Updates(iModel, map[string]interface{}{
"status": status, "updated_at": time.Now(),
}, tx)
if err != nil {
return err
}
// 保存审核日志
mSysUserExamineLog := model.NewSysUserExamineLog()
mSysUserExamineLog.UID = uid
mSysUserExamineLog.Kind = kind
mSysUserExamineLog.ObjectID = iModel.GetID()
mSysUserExamineLog.Status = status
mSysUserExamineLog.Remark = remark
return model2.Create(mSysUserExamineLog.SysUserExamineLog, tx)
})
} }

View File

@ -85,6 +85,27 @@ func (c *Demand) Detail(id uint64) (*DemandDetailInfo, error) {
}, err }, err
} }
// Examine 审核操作
func (c *Demand) Examine(id uint64, status int, remark string) error {
mTechnologyDemand := model.NewTechnologyDemand()
mTechnologyDemand.ID = id
isExist, err := model2.FirstField(mTechnologyDemand.TechnologyDemand, []string{"id", "tenant_id", "status"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,需求信息不存在或已被删除")
}
if c.TenantID > 0 && mTechnologyDemand.TenantID != c.TenantID {
return errors.New("操作错误,无权限操作")
}
if mTechnologyDemand.Status != model2.TechnologyStatusKindForExamining {
return errors.New("操作错误,当前需求状态不允许审核")
}
return handleExamine(mTechnologyDemand.TechnologyDemand, c.UID, model2.SysUserExamineLogKindForDemandTechnology, status, remark)
}
// Delete 删除操作 // Delete 删除操作
func (c *Demand) Delete(id uint64) error { func (c *Demand) Delete(id uint64) error {
mTechnologyDemand := model.NewTechnologyDemand() mTechnologyDemand := model.NewTechnologyDemand()

View File

@ -101,9 +101,7 @@ func (c *Product) Examine(id uint64, status int, remark string) error {
if mTechnologyProduct.Status != model2.TechnologyStatusKindForExamining { if mTechnologyProduct.Status != model2.TechnologyStatusKindForExamining {
return errors.New("操作错误,当前产品状态不允许审核") return errors.New("操作错误,当前产品状态不允许审核")
} }
return model2.Updates(mTechnologyProduct.TechnologyProduct, map[string]interface{}{ return handleExamine(mTechnologyProduct.TechnologyProduct, c.UID, model2.SysUserExamineLogKindForProduct, status, remark)
"status": status,
})
} }
// Delete 删除操作 // Delete 删除操作

View File

@ -0,0 +1,12 @@
package model
import "SciencesServer/app/common/model"
// SysUserExamineLog 用户审核数据
type SysUserExamineLog struct {
*model.SysUserExamineLog
}
func NewSysUserExamineLog() *SysUserExamineLog {
return &SysUserExamineLog{model.NewSysUserExamineLog()}
}

View File

@ -124,6 +124,7 @@ func (this *Instance) Handle() {
&synchronized{iModel: model.NewSysBanner()}, &synchronized{iModel: model.NewSysAgreement()}, &synchronized{iModel: model.NewSysBanner()}, &synchronized{iModel: model.NewSysAgreement()},
// 日志管理 // 日志管理
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()}, &synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
&synchronized{iModel: model.NewSysUserExamineLog()},
// 用户管理 // 用户管理
&synchronized{iModel: model.NewUserInstance()}, &synchronized{iModel: model.NewUserIdentity()}, &synchronized{iModel: model.NewUserInstance()}, &synchronized{iModel: model.NewUserIdentity()},
&synchronized{iModel: model.NewUserAssets()}, &synchronized{iModel: model.NewUserAssets()},
@ -131,8 +132,7 @@ func (this *Instance) Handle() {
&synchronized{iModel: model.NewUserCompany()}, &synchronized{iModel: model.NewUserExpert()}, &synchronized{iModel: model.NewUserCompany()}, &synchronized{iModel: model.NewUserExpert()},
&synchronized{iModel: model.NewUserLaboratory()}, &synchronized{iModel: model.NewUserResearch()}, &synchronized{iModel: model.NewUserLaboratory()}, &synchronized{iModel: model.NewUserResearch()},
&synchronized{iModel: model.NewUserAgent()}, &synchronized{iModel: model.NewUserAgent()},
&synchronized{iModel: model.NewUserVisit()}, &synchronized{iModel: model.NewUserVisit()}, &synchronized{iModel: model.NewUserCollect()},
&synchronized{iModel: model.NewUserCollect()},
// 数据管理 // 数据管理
&synchronized{iModel: model.NewManageCompany()}, &synchronized{iModel: model.NewManageExpert()}, &synchronized{iModel: model.NewManageCompany()}, &synchronized{iModel: model.NewManageExpert()},
&synchronized{iModel: model.NewManageLaboratory()}, &synchronized{iModel: model.NewManageResearch()}, &synchronized{iModel: model.NewManageLaboratory()}, &synchronized{iModel: model.NewManageResearch()},

View File

@ -0,0 +1,32 @@
package model
// SysUserExamineLog 用户审核数据模型
type SysUserExamineLog struct {
Model
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
Kind SysUserExamineLogKind `gorm:"column:kind;type:tinyint(3);default:0;comment:审核对象类型" json:"kind"`
ObjectID uint64 `gorm:"column:object_id;type:int(11);default:0;comment:对象ID" json:"-"`
Status int `gorm:"column:status;type:tinyint(1);default:0;comment:状态" json:"status"`
Remark string `gorm:"column:remark;type:varchar(255);default:'';comment:备注" json:"-"`
ModelDeleted
ModelAt
}
type SysUserExamineLogKind int
const (
// SysUserExamineLogKindForProduct 产品信息审核
SysUserExamineLogKindForProduct SysUserExamineLogKind = iota + 1
// SysUserExamineLogKindForAchievement 成果信息
SysUserExamineLogKindForAchievement
// SysUserExamineLogKindForDemandTechnology 技术需求
SysUserExamineLogKindForDemandTechnology
)
func (m *SysUserExamineLog) TableName() string {
return "sys_user_examine_log"
}
func NewSysUserExamineLog() *SysUserExamineLog {
return &SysUserExamineLog{}
}

View File

@ -358,12 +358,15 @@ func registerAdminAPI(app *gin.Engine) {
technology.POST("/paper/detail", _api.PaperDetail) technology.POST("/paper/detail", _api.PaperDetail)
technology.POST("/paper/delete", _api.PaperDelete) technology.POST("/paper/delete", _api.PaperDelete)
technology.POST("/product", _api.Product) technology.POST("/product", _api.Product)
technology.POST("/product/examine", _api.ProductExamine)
technology.POST("/product/detail", _api.ProductDetail) technology.POST("/product/detail", _api.ProductDetail)
technology.POST("/product/delete", _api.ProductDelete) technology.POST("/product/delete", _api.ProductDelete)
technology.POST("/achievement", _api.Achievement) technology.POST("/achievement", _api.Achievement)
technology.POST("/achievement/examine", _api.AchievementExamine)
technology.POST("/achievement/detail", _api.AchievementDetail) technology.POST("/achievement/detail", _api.AchievementDetail)
technology.POST("/achievement/delete", _api.AchievementDelete) technology.POST("/achievement/delete", _api.AchievementDelete)
technology.POST("/demand", _api.Demand) technology.POST("/demand", _api.Demand)
technology.POST("/demand/examine", _api.DemandExamine)
technology.POST("/demand/detail", _api.DemandDetail) technology.POST("/demand/detail", _api.DemandDetail)
technology.POST("/demand/delete", _api.DemandDelete) technology.POST("/demand/delete", _api.DemandDelete)
} }