feat:注释不用的代码

This commit is contained in:
henry
2021-11-24 11:12:46 +08:00
parent 0862142ef0
commit 5475320171
19 changed files with 74 additions and 71 deletions

View File

@ -119,7 +119,7 @@ func (c *Demand) Form(params *DemandParams) error {
return err
} else if !isExist {
return errors.New("操作错误,数据不存在")
} else if mTechnologyDemand.UID != c.ManageUID {
} else if mTechnologyDemand.MUid != c.ManageUID {
return errors.New("无权限操作")
} else if mTechnologyDemand.Status != model2.TechnologyDemandStatusForRefuse &&
mTechnologyDemand.Status != model2.TechnologyDemandStatusForDraft {
@ -156,7 +156,7 @@ func (c *Demand) Form(params *DemandParams) error {
return model2.Updates(mTechnologyDemand.TechnologyDemand, mTechnologyDemand.TechnologyDemand)
}
mTechnologyDemand.TenantID = c.TenantID
mTechnologyDemand.UID = c.ManageUID
mTechnologyDemand.MUid = c.ManageUID
mTechnologyDemand.Local.Local = c.local
return model2.Create(mTechnologyDemand.TechnologyDemand)
}
@ -172,7 +172,7 @@ func (c *Demand) Delete(id uint64) error {
return err
} else if !isExist {
return errors.New("操作错误,数据不存在")
} else if mTechnologyDemand.UID != c.ManageUID {
} else if mTechnologyDemand.MUid != c.ManageUID {
return errors.New("无权限操作")
}
if err = model2.Delete(mTechnologyDemand.TechnologyDemand); err != nil {

View File

@ -73,7 +73,7 @@ func (c *Instance) Form(params *InstanceParams) error {
return err
} else if !isExist {
return errors.New("信息不存在")
} else if c.ManageUID != mTechnologyInstance.UID {
} else if c.ManageUID != mTechnologyInstance.MUid {
return errors.New("操作错误,无权限操作")
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForDraft &&
mTechnologyInstance.Status != model2.TechnologyInstanceStatusForRefuse {
@ -105,7 +105,7 @@ func (c *Instance) Form(params *InstanceParams) error {
mTechnologyInstance.UpdatedAt = time.Now()
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
}
mTechnologyInstance.UID = c.ManageUID
mTechnologyInstance.MUid = c.ManageUID
mTechnologyInstance.Local.Local = c.local
mTechnologyInstance.TenantID = c.TenantID
@ -122,7 +122,7 @@ func (c *Instance) Shelf(id uint64, status int) error {
return err
} else if !isExist {
return errors.New("信息不存在")
} else if c.ManageUID != mTechnologyInstance.UID {
} else if c.ManageUID != mTechnologyInstance.MUid {
return errors.New("操作错误,无权限操作")
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForAgree {
return errors.New("操作错误,当前状态不允许处理上下架")
@ -147,7 +147,7 @@ func (c *Instance) Delete(id uint64) error {
return err
} else if !isExist {
return errors.New("信息不存在")
} else if c.ManageUID != mTechnologyInstance.UID {
} else if c.ManageUID != mTechnologyInstance.MUid {
return errors.New("操作错误,无权限操作")
}
if err = model2.Delete(mTechnologyInstance.TechnologyInstance); err != nil {

View File

@ -70,7 +70,7 @@ func (c *Paper) Form(params *PaperParams) error {
return err
} else if !isExist {
return errors.New("当前论文信息不存在")
} else if mTechnologyPaper.UID != c.ManageUID {
} else if mTechnologyPaper.MUid != c.ManageUID {
return errors.New("无权限操作")
}
}
@ -84,7 +84,7 @@ func (c *Paper) Form(params *PaperParams) error {
if params.ID <= 0 {
mTechnologyPaper.TenantID = c.TenantID
mTechnologyPaper.UID = c.ManageUID
mTechnologyPaper.MUid = c.ManageUID
mTechnologyPaper.Local.Local = c.local
return model2.Create(mTechnologyPaper.TechnologyPaper)
}

View File

@ -103,7 +103,7 @@ func (c *Patent) Form(params *PatentParams) error {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在")
} else if mTechnologyPatent.UID != c.ManageUID {
} else if mTechnologyPatent.MUid != c.ManageUID {
return errors.New("无权限操作")
}
}
@ -126,7 +126,7 @@ func (c *Patent) Form(params *PatentParams) error {
}
mTechnologyPatent.TenantID = c.TenantID
mTechnologyPatent.Local.Local = c.local
mTechnologyPatent.UID = c.ManageUID
mTechnologyPatent.MUid = c.ManageUID
return model2.Create(mTechnologyPatent.TechnologyPatent)
}
@ -141,7 +141,7 @@ func (c *Patent) Delete(id uint64) error {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在")
} else if mTechnologyPatent.UID != c.ManageUID {
} else if mTechnologyPatent.MUid != c.ManageUID {
return errors.New("无权限操作")
}
return model2.Delete(mTechnologyPatent.TechnologyPatent)

View File

@ -100,7 +100,7 @@ func (c *Topic) Form(params *TopicParams) error {
return err
} else if !isExist {
return errors.New("操作错误,课题信息不存在")
} else if mTechnologyTopic.UID != c.ManageUID {
} else if mTechnologyTopic.MUid != c.ManageUID {
return errors.New("无权限操作")
} else if mTechnologyTopic.Status != model2.TechnologyTopicStatusForDraft &&
mTechnologyTopic.Status != model2.TechnologyTopicStatusForRefuse {
@ -124,7 +124,7 @@ func (c *Topic) Form(params *TopicParams) error {
}
mTechnologyTopic.TenantID = c.TenantID
mTechnologyTopic.Local.Local = c.local
mTechnologyTopic.UID = c.ManageUID
mTechnologyTopic.MUid = c.ManageUID
return model2.Create(mTechnologyTopic.TechnologyTopic)
}
@ -139,7 +139,7 @@ func (c *Topic) Delete(id uint64) error {
return err
} else if !isExist {
return errors.New("操作错误,课题信息不存在")
} else if mTechnologyTopic.UID != c.ManageUID {
} else if mTechnologyTopic.MUid != c.ManageUID {
return errors.New("无权限操作")
}
return model2.Delete(mTechnologyTopic.TechnologyTopic)

View File

@ -84,7 +84,7 @@ func (c *Bank) Bind(params *BankParams, captcha string) error {
} else if count > 0 {
return errors.New("当前银行卡已被注册")
}
mUserManageBank.UID = c.ManageUID
mUserManageBank.MUid = c.ManageUID
mUserManageBank.Name = params.Name
mUserManageBank.IDCard = params.IDCard
mUserManageBank.BankCard = params.BankCard
@ -109,7 +109,7 @@ func (c *Bank) Unbind(id uint64) error {
return err
} else if !isExist {
return errors.New("操作错误,绑定信息不存在")
} else if mUserManageBank.UID != c.ManageUID {
} else if mUserManageBank.MUid != c.ManageUID {
return errors.New("无权限操作")
}
return model2.Delete(mUserManageBank)

View File

@ -6,7 +6,6 @@ import (
model3 "SciencesServer/app/api/manage/model"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/serve/logger"
"SciencesServer/serve/orm"
"SciencesServer/utils"
@ -64,18 +63,18 @@ func (c *Auth) Bind(roleID uint64, authIDs []uint64) error {
return err
}
go utils.TryCatch(func() {
permission := service.NewPermission([]string{utils.UintToString(roleID)}, authRequests...)(c.TenantKey, "")
// 删除角色权限
if _, err = permission.RemoveRolePolicy(); err != nil {
logger.ErrorF("删除角色【%d】规则信息错误%v", roleID, err)
return
}
if len(authRequests) > 0 {
if _, err = permission.AddPolicies(); err != nil {
logger.ErrorF("创建角色【%d】规则信息错误%v", roleID, err)
return
}
}
//permission := service.NewPermission([]string{utils.UintToString(roleID)}, authRequests...)(c.TenantKey, "")
//// 删除角色权限
//if _, err = permission.RemoveRolePolicy(); err != nil {
// logger.ErrorF("删除角色【%d】规则信息错误%v", roleID, err)
// return
//}
//if len(authRequests) > 0 {
// if _, err = permission.AddPolicies(); err != nil {
// logger.ErrorF("创建角色【%d】规则信息错误%v", roleID, err)
// return
// }
//}
})
return nil
})

View File

@ -5,7 +5,6 @@ import (
"SciencesServer/app/api/manage/model"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/serve/logger"
"SciencesServer/utils"
"errors"
"time"
@ -157,12 +156,12 @@ func (c *Instance) Delete(id uint64) error {
return err
}
go utils.TryCatch(func() {
permission := service.NewPermission([]string{utils.UintToString(id)})(c.TenantKey, "")
// 删除角色权限
if _, err = permission.RemoveRolePolicy(); err != nil {
logger.ErrorF("删除租户【%s】下角色【%d】权限信息错误%v", c.TenantKey, id, err)
return
}
//permission := service.NewPermission([]string{utils.UintToString(id)})(c.TenantKey, "")
//// 删除角色权限
//if _, err = permission.RemoveRolePolicy(); err != nil {
// logger.ErrorF("删除租户【%s】下角色【%d】权限信息错误%v", c.TenantKey, id, err)
// return
//}
})
return nil
}

View File

@ -4,8 +4,6 @@ import (
"SciencesServer/app/api/manage/controller"
model3 "SciencesServer/app/api/manage/model"
model2 "SciencesServer/app/common/model"
"SciencesServer/serve/logger"
"SciencesServer/app/service"
"SciencesServer/serve/orm"
"SciencesServer/utils"
@ -59,16 +57,16 @@ func (c *User) Bind(uid uint64, roleIDs []uint64) error {
return err
}
go utils.TryCatch(func() {
permission := service.NewPermission(obj)(c.TenantKey, utils.UintToString(uid))
if _, err = permission.DeleteRolesForUser(false); err != nil {
logger.ErrorF("删除用户【%d】角色权限错误%v", uid, err)
return
}
if _, err = permission.AddRoleForUser(); err != nil {
logger.ErrorF("添加用户【%d】角色权限错误%v", uid, err)
return
}
//permission := service.NewPermission(obj)(c.TenantKey, utils.UintToString(uid))
//
//if _, err = permission.DeleteRolesForUser(false); err != nil {
// logger.ErrorF("删除用户【%d】角色权限错误%v", uid, err)
// return
//}
//if _, err = permission.AddRoleForUser(); err != nil {
// logger.ErrorF("添加用户【%d】角色权限错误%v", uid, err)
// return
//}
})
return nil
})

View File

@ -64,12 +64,12 @@ func (c *Auth) revoke(tenantID uint64, tenantKey string, authIDs []uint64, tx *g
return err
}
go utils.TryCatch(func() {
permission := service.NewPermission(roleIDs, auths...)(c.TenantKey, "")
// 删除角色权限
if _, err = permission.RemoveNamedGroupingPolicies(); err != nil {
logger.ErrorF("删除租户【%s】下角色权限错误%v", tenantKey, err)
return
}
//permission := service.NewPermission(roleIDs, auths...)(c.TenantKey, "")
//// 删除角色权限
//if _, err = permission.RemoveNamedGroupingPolicies(); err != nil {
// logger.ErrorF("删除租户【%s】下角色权限错误%v", tenantKey, err)
// return
//}
})
return nil
}

View File

@ -10,7 +10,7 @@ type TechnologyDemand struct {
Model
ModelTenant
Local
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
Title string `gorm:"column:title;type:varchar(50);default:null;comment:需求名称" json:"title"`
Kind string `gorm:"column:kind;type:varchar(50);default:null;comment:需求类别" json:"-"`
Area

View File

@ -7,7 +7,7 @@ type TechnologyInstance struct {
Model
ModelTenant
Local
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
PatentID uint64 `gorm:"column:patent_id;type:int;default:0;comment:代表专利" json:"patent_id"`
Title string `gorm:"column:title;type:varchar(30);default:null;comment:名称" json:"title"`
Company string `gorm:"column:company;type:varchar(30);default:null;comment:单位" json:"company"`

View File

@ -10,7 +10,7 @@ type TechnologyPaper struct {
Model
ModelTenant
Local
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
Title string `gorm:"column:title;type:varchar(100);default:null;comment:题目" json:"title"`
Ext string `gorm:"column:ext;type:varchar(30);default:null;comment:引用格式" json:"ext"`
Author string `gorm:"column:author;type:varchar(100);default:null;comment:作者" json:"author"`

View File

@ -7,7 +7,7 @@ type TechnologyPatent struct {
Model
ModelTenant
Local
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户管理uuid" json:"-"`
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
Title string `gorm:"column:title;type:varchar(50);default:null;comment:专利名称" json:"title"`
IPCCode string `gorm:"column:ipc_code;type:varchar(30);default:null;comment:IPC分类号" json:"ipc_code"`
CPCCode string `gorm:"column:cpc_code;type:varchar(30);default:null;comment:CPC分类号" json:"cpc_code"`

View File

@ -10,7 +10,7 @@ type TechnologyTopic struct {
Model
ModelTenant
Local
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
Title string `gorm:"column:title;type:varchar(100);default:null;comment:名称" json:"title"`
Code string `gorm:"column:code;type:varchar(30);default:null;comment:编号" json:"code"`
Emcee string `gorm:"column:emcee;type:varchar(30);default:null;comment:主持人" json:"emcee"`

View File

@ -4,7 +4,7 @@ package model
type UserManageBank struct {
Model
ModelTenant
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户管理uuid" json:"-"`
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
Name string `gorm:"column:name;type:varchar(30);default:null;comment:姓名" json:"name"`
IDCard string `gorm:"column:id_card;type:varchar(18);default:null;comment:身份证号" json:"id_card"`
BankCard string `gorm:"column:bank_card;type:varchar(18);default:null;comment:银行卡号" json:"bank_card"`

View File

@ -4,16 +4,22 @@ import (
api2 "SciencesServer/app/api/enterprise/api"
"SciencesServer/app/api/manage/api"
api3 "SciencesServer/app/basic/api"
"SciencesServer/app/session"
"github.com/gin-gonic/gin"
)
// registerAPI 注册API
func registerAPI(app *gin.Engine) {
apiPrefix := "/api"
}
// registerManageAPI 注册API
func registerManageAPI(app *gin.Engine) {
apiPrefix := "/manage"
g := app.Group(apiPrefix)
// 登录验证
g.Use(NeedLogin(AddSkipperURL([]string{
g.Use(NeedLogin(session.NewManage(), AddSkipperURL([]string{
apiPrefix + "/captcha",
apiPrefix + "/account/login",
apiPrefix + "/account/logout",

View File

@ -1,9 +1,9 @@
package router
import (
"SciencesServer/app/logic"
"SciencesServer/app/service"
"SciencesServer/config"
"SciencesServer/serve/cache"
"SciencesServer/utils"
"github.com/gin-gonic/gin"
"net/http"
@ -24,7 +24,7 @@ func AddSkipperURL(url ...string) SkipperURL {
}
// NeedLogin 需要登录
func NeedLogin(skipperURL ...SkipperURL) gin.HandlerFunc {
func NeedLogin(session logic.ISession, skipperURL ...SkipperURL) gin.HandlerFunc {
return func(c *gin.Context) {
if len(skipperURL) > 0 && skipperURL[0](c) {
c.Next()
@ -37,7 +37,7 @@ func NeedLogin(skipperURL ...SkipperURL) gin.HandlerFunc {
c.Abort()
return
}
session, err := service.NewAuthToken(token).Auth()
err := service.NewAuthToken(token).Auth(session)
if err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"message": err.Error()})
@ -62,11 +62,11 @@ func NeedPermission(skipperURL ...SkipperURL) PermissionHandle {
if !_session.IsAdmin {
if _session.TenantID > 0 {
if isExist, _ := cache.Cache.SIsMember(config.RedisKeyForTenant, _session.TenantKey); !isExist {
c.JSON(http.StatusForbidden, gin.H{"message": "租户/公司信息协议已到期或已被禁用,无权限访问!"})
c.Abort()
return
}
//if isExist, _ := cache.Cache.SIsMember(config.RedisKeyForTenant, _session.TenantKey); !isExist {
// c.JSON(http.StatusForbidden, gin.H{"message": "租户/公司信息协议已到期或已被禁用,无权限访问!"})
// c.Abort()
// return
//}
}
//if pass, _ := service.NewPermission(nil, &service.AuthRequest{
// Url: key,

View File

@ -57,6 +57,7 @@ func (this *Router) Init() *gin.Engine {
app.StaticFS("/upload", http.Dir("./upload"))
// 注册路由
registerAPI(app)
registerManageAPI(app)
registerEnterpriseAPI(app)
app.MaxMultipartMemory = 4 << 20