feat:完善入驻信息管理
This commit is contained in:
23
app/api/enterprise/api/settled.go
Normal file
23
app/api/enterprise/api/settled.go
Normal file
@ -0,0 +1,23 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/controller/settled"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/session"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Settled struct{}
|
||||
|
||||
func (*Settled) Index(c *gin.Context) {
|
||||
settled.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).Index()
|
||||
}
|
||||
|
||||
func (*Settled) Company(c *gin.Context) {
|
||||
settled.NewCompany()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||
Launch(nil, 0, nil)
|
||||
}
|
||||
|
||||
func (*Settled) Expert(c *gin.Context) {
|
||||
|
||||
}
|
@ -49,85 +49,85 @@ func (*User) BindMobile(c *gin.Context) {
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*User) SettledCompany(c *gin.Context) {
|
||||
form := &struct {
|
||||
InviteCode string `json:"invite_code" form:"invite_code"`
|
||||
userSettledForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Company(&user.SettledParams{
|
||||
Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
Area: form.Area, Introduce: form.Introduce, Industrys: form.Industrys, Keywords: form.Keywords,
|
||||
}, (&api.IDStringForm{ID: form.InviteCode}).Convert(), nil)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*User) SettledExpert(c *gin.Context) {
|
||||
form := &struct {
|
||||
userSettledForm
|
||||
config.IdentityForExpert
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Expert(&user.SettledParams{
|
||||
Area: form.Area, Introduce: form.Introduce, Industrys: form.Industrys,
|
||||
Keywords: form.Keywords,
|
||||
}, &form.IdentityForExpert)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*User) SettledResearch(c *gin.Context) {
|
||||
form := &struct {
|
||||
userSettledForm
|
||||
config.IdentityForResearch
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Research(&user.SettledParams{
|
||||
Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
Area: form.Area, Introduce: form.Introduce, Industrys: form.Industrys, Keywords: form.Keywords,
|
||||
}, &form.IdentityForResearch)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*User) SettledLaboratory(c *gin.Context) {
|
||||
form := &struct {
|
||||
userSettledForm
|
||||
config.IdentityForLaboratory
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Laboratory(&user.SettledParams{
|
||||
Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
Area: form.Area, Introduce: form.Introduce, Industrys: form.Industrys, Keywords: form.Keywords,
|
||||
}, &form.IdentityForLaboratory)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*User) SettledAgent(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
userSettledForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Agent(&user.SettledParams{
|
||||
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
Area: form.Area, Introduce: form.Introduce, Industrys: form.Industrys, Keywords: form.Keywords,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
//func (*User) SettledCompany(c *gin.Context) {
|
||||
// form := &struct {
|
||||
// InviteCode string `json:"invite_code" form:"invite_code"`
|
||||
// userSettledForm
|
||||
// }{}
|
||||
// if err := api.Bind(form)(c); err != nil {
|
||||
// api.APIFailure(err.(error))(c)
|
||||
// return
|
||||
// }
|
||||
// err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Company(&user.SettledParams{
|
||||
// Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
// Area: form.Area, Introduce: form.Introduce, Industrys: form.Industrys, Keywords: form.Keywords,
|
||||
// }, (&api.IDStringForm{ID: form.InviteCode}).Convert(), nil)
|
||||
// api.APIResponse(err)(c)
|
||||
//}
|
||||
//
|
||||
//func (*User) SettledExpert(c *gin.Context) {
|
||||
// form := &struct {
|
||||
// userSettledForm
|
||||
// config.IdentityForExpert
|
||||
// }{}
|
||||
// if err := api.Bind(form)(c); err != nil {
|
||||
// api.APIFailure(err.(error))(c)
|
||||
// return
|
||||
// }
|
||||
// err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Expert(&user.SettledParams{
|
||||
// Area: form.Area, Introduce: form.Introduce, Industrys: form.Industrys,
|
||||
// Keywords: form.Keywords,
|
||||
// }, &form.IdentityForExpert)
|
||||
// api.APIResponse(err)(c)
|
||||
//}
|
||||
//
|
||||
//func (*User) SettledResearch(c *gin.Context) {
|
||||
// form := &struct {
|
||||
// userSettledForm
|
||||
// config.IdentityForResearch
|
||||
// }{}
|
||||
// if err := api.Bind(form)(c); err != nil {
|
||||
// api.APIFailure(err.(error))(c)
|
||||
// return
|
||||
// }
|
||||
// err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Research(&user.SettledParams{
|
||||
// Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
// Area: form.Area, Introduce: form.Introduce, Industrys: form.Industrys, Keywords: form.Keywords,
|
||||
// }, &form.IdentityForResearch)
|
||||
// api.APIResponse(err)(c)
|
||||
//}
|
||||
//
|
||||
//func (*User) SettledLaboratory(c *gin.Context) {
|
||||
// form := &struct {
|
||||
// userSettledForm
|
||||
// config.IdentityForLaboratory
|
||||
// }{}
|
||||
// if err := api.Bind(form)(c); err != nil {
|
||||
// api.APIFailure(err.(error))(c)
|
||||
// return
|
||||
// }
|
||||
// err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Laboratory(&user.SettledParams{
|
||||
// Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
// Area: form.Area, Introduce: form.Introduce, Industrys: form.Industrys, Keywords: form.Keywords,
|
||||
// }, &form.IdentityForLaboratory)
|
||||
// api.APIResponse(err)(c)
|
||||
//}
|
||||
//
|
||||
//func (*User) SettledAgent(c *gin.Context) {
|
||||
// form := &struct {
|
||||
// api.IDStringForm
|
||||
// userSettledForm
|
||||
// }{}
|
||||
// if err := api.Bind(form)(c); err != nil {
|
||||
// api.APIFailure(err.(error))(c)
|
||||
// return
|
||||
// }
|
||||
// err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Agent(&user.SettledParams{
|
||||
// ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
// Area: form.Area, Introduce: form.Introduce, Industrys: form.Industrys, Keywords: form.Keywords,
|
||||
// })
|
||||
// api.APIResponse(err)(c)
|
||||
//}
|
||||
|
||||
func (*User) IdentityBasic(c *gin.Context) {
|
||||
data, err := user.NewIdentity()(api.GetSession()(c).(*session.Enterprise)).Basic()
|
||||
|
@ -4,23 +4,31 @@ import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TODO:入驻流程
|
||||
// 2021-12-02
|
||||
// 一:
|
||||
|
||||
// BasicParams 基本信息
|
||||
type BasicParams struct {
|
||||
ID uint64
|
||||
Name, Image, Code, Introduce string
|
||||
config.Area
|
||||
Industrys, Keywords []string
|
||||
}
|
||||
|
||||
// filter 筛选信息
|
||||
func (c *BasicParams) filter(identity int, where ...*model2.ModelWhere) (bool, error) {
|
||||
func (c *BasicParams) filter(identity int, where ...*model2.ModelWhere) error {
|
||||
mSysIdentity := model.NewSysIdentity()
|
||||
_, err := model2.FirstField(mSysIdentity.SysIdentity, []string{"id", "register_count", "is_examine"}, model2.NewWhere("identity", identity))
|
||||
_, err := model2.FirstField(mSysIdentity.SysIdentity, []string{"id", "register_count"}, model2.NewWhere("identity", identity))
|
||||
|
||||
if err != nil {
|
||||
return true, err
|
||||
return err
|
||||
}
|
||||
var iModel model2.IModel
|
||||
|
||||
@ -40,10 +48,34 @@ func (c *BasicParams) filter(identity int, where ...*model2.ModelWhere) (bool, e
|
||||
where = append(where, model2.NewWhere("status", model2.InvalidStatusForNot))
|
||||
|
||||
if err = model2.Count(iModel, &count, where...); err != nil {
|
||||
return true, err
|
||||
return err
|
||||
}
|
||||
if count >= int64(mSysIdentity.RegisterCount) {
|
||||
return true, errors.New("操作错误,已超过当前身份最大入驻人数")
|
||||
return errors.New("操作错误,已超过当前身份最大入驻人数")
|
||||
}
|
||||
return mSysIdentity.IsExamine == model2.SysIdentityExamineForYes, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// fillIdentity 填充身份信息
|
||||
func (c *BasicParams) fillIdentity(tx *gorm.DB, session *session.Enterprise, identity int) error {
|
||||
if session.SelectIdentity <= 0 {
|
||||
session.SelectIdentity = identity
|
||||
}
|
||||
session.Identity = session.Identity | identity
|
||||
|
||||
mUserInstance := model.NewUserInstance()
|
||||
|
||||
err := model2.UpdatesWhere(mUserInstance.UserInstance, map[string]interface{}{
|
||||
"identity": session.Identity, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uuid", session.UID)}, tx)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
mUserIdentity.UID = session.UID
|
||||
mUserIdentity.Name = session.Name
|
||||
mUserIdentity.Identity = identity
|
||||
|
||||
return model2.Create(mUserIdentity.UserIdentity)
|
||||
}
|
||||
|
@ -6,10 +6,12 @@ import (
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Company 公司企业入驻信息
|
||||
type Company struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
@ -17,24 +19,33 @@ type Company struct {
|
||||
|
||||
type CompanyHandle func(session *session.Enterprise, local string) *Company
|
||||
|
||||
func (c *Company) Launch() {
|
||||
// Launch 发起入驻
|
||||
func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.IdentityForCompany) error {
|
||||
if c.Identity&config.TenantUserIdentityForCompany > 0 {
|
||||
return errors.New("操作错误,不可重复申请入驻")
|
||||
}
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
// 查询相应的企业入驻信息
|
||||
isExist, err := model2.FirstField(mManageCompany.ManageCompany, []string{"id", "status"},
|
||||
model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local),
|
||||
model2.NewWhere("status", model2.ExamineStatusForRefuse))
|
||||
model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local))
|
||||
|
||||
isExamine := true
|
||||
// 过滤用户其他公司入驻信息
|
||||
mUserCompany := model.NewUserCompany()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
// 审核中
|
||||
if mManageCompany.Status == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前企业信息审核中,不可入驻")
|
||||
return errors.New("操作错误,当前该企业信息审核中,不可入驻")
|
||||
}
|
||||
// 筛选企业条件
|
||||
if isExamine, err = c.filter(config.TenantUserIdentityForCompany, model2.NewWhere("company_id", mManageCompany.ID)); err != nil {
|
||||
return err
|
||||
// 审核通过
|
||||
if mManageCompany.Status == model2.ExamineStatusForAgree {
|
||||
// 筛选企业条件
|
||||
if err = params.filter(config.TenantUserIdentityForCompany,
|
||||
model2.NewWhere("company_id", mManageCompany.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
mManageCompany.Local.Local = c.local
|
||||
@ -50,18 +61,17 @@ func (c *Company) Launch() {
|
||||
mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
mManageCompany.Introduce = params.Introduce
|
||||
|
||||
if isExamine {
|
||||
mManageCompany.Status = model2.ExamineStatusForAgree
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// 删除区域相同编码公司信息
|
||||
if err = model2.DeleteWhere(mManageCompany.ManageCompany, []*model2.ModelWhere{
|
||||
model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if mManageCompany.ID <= 0 {
|
||||
if err = model2.Create(mManageCompany.ManageCompany, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// 过滤用户其他公司入驻信息
|
||||
mUserCompany := model.NewUserCompany()
|
||||
|
||||
if err := model2.UpdatesWhere(mUserCompany.UserCompany, map[string]interface{}{
|
||||
"status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
|
3
app/api/enterprise/controller/settled/expert.go
Normal file
3
app/api/enterprise/controller/settled/expert.go
Normal file
@ -0,0 +1,3 @@
|
||||
package settled
|
||||
|
||||
type Expert struct{}
|
20
app/api/enterprise/controller/settled/instance.go
Normal file
20
app/api/enterprise/controller/settled/instance.go
Normal file
@ -0,0 +1,20 @@
|
||||
package settled
|
||||
|
||||
import "SciencesServer/app/session"
|
||||
|
||||
type Instance struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type InstanceHandle func(session *session.Enterprise, local string) *Instance
|
||||
|
||||
func (c *Instance) Index() {
|
||||
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *session.Enterprise, local string) *Instance {
|
||||
return &Instance{Enterprise: session, local: local}
|
||||
}
|
||||
}
|
@ -2,12 +2,10 @@ package user
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
model3 "SciencesServer/app/api/manage/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
@ -139,104 +137,105 @@ func (c *Settled) Company(params *SettledParams, inviterID uint64, other *config
|
||||
})
|
||||
}
|
||||
|
||||
// Expert 专家
|
||||
func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert) error {
|
||||
mManageExpert := model3.NewManageExpert()
|
||||
|
||||
err := params.effect(c.UID, mManageExpert.ManageExpert)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mManageExpert.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageExpert.SetIndustryAttribute(params.Industrys)
|
||||
mManageExpert.SetKeywordAttribute(params.Keywords)
|
||||
mManageExpert.Introduce = params.Introduce
|
||||
mManageExpert.Position = utils.AnyToJSON(model2.Position{Longitude: other.Longitude, Latitude: other.Latitude})
|
||||
mManageExpert.School = other.School
|
||||
mManageExpert.Major = other.Major
|
||||
mManageExpert.Job = other.Job
|
||||
mManageExpert.Title = other.Title
|
||||
mManageExpert.WorkAt = utils.DataTimeToDate(other.WorkAt)
|
||||
mManageExpert.Research = utils.AnyToJSON(other.Research)
|
||||
|
||||
if mManageExpert.ID <= 0 {
|
||||
mManageExpert.UID = c.UID
|
||||
return model2.Create(mManageExpert.ManageExpert)
|
||||
}
|
||||
if !params.pass(c.UID, mManageExpert.UID, mManageExpert.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageExpert.Status = model2.ExamineStatusForOngoing
|
||||
return model2.Updates(mManageExpert.ManageExpert, mManageExpert.ManageExpert)
|
||||
}
|
||||
|
||||
// Research 研究机构
|
||||
func (c *Settled) Research(params *SettledParams, other *config.IdentityForResearch) error {
|
||||
mManageResearch := model3.NewManageResearch()
|
||||
|
||||
err := params.effect(c.UID, mManageResearch.ManageResearch)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mManageResearch.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageResearch.Industry = params.Industrys
|
||||
mManageResearch.SetKeywordAttribute(params.Keywords)
|
||||
mManageResearch.Introduce = params.Introduce
|
||||
mManageResearch.Position = utils.AnyToJSON(model2.Position{Longitude: other.Longitude, Latitude: other.Latitude})
|
||||
mManageResearch.Research = other.Research
|
||||
|
||||
if mManageResearch.ID <= 0 {
|
||||
mManageResearch.UID = c.UID
|
||||
return model2.Create(mManageResearch.ManageResearch)
|
||||
}
|
||||
if !params.pass(c.UID, mManageResearch.UID, mManageResearch.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageResearch.Status = model2.ExamineStatusForOngoing
|
||||
return model2.Updates(mManageResearch.ManageResearch, mManageResearch.ManageResearch)
|
||||
}
|
||||
|
||||
// Laboratory 实验室
|
||||
func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLaboratory) error {
|
||||
mManageLaboratory := model3.NewManageLaboratory()
|
||||
|
||||
err := params.effect(c.UID, mManageLaboratory.ManageLaboratory)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mManageLaboratory.Name = params.Name
|
||||
mManageLaboratory.Code = params.Code
|
||||
mManageLaboratory.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageLaboratory.Industry = params.Industrys
|
||||
mManageLaboratory.SetKeywordAttribute(params.Keywords)
|
||||
mManageLaboratory.Introduce = params.Introduce
|
||||
mManageLaboratory.Position = utils.AnyToJSON(model2.Position{Longitude: other.Longitude, Latitude: other.Latitude})
|
||||
mManageLaboratory.Research = utils.AnyToJSON(other.Research)
|
||||
|
||||
if mManageLaboratory.ID <= 0 {
|
||||
mManageLaboratory.UID = c.UID
|
||||
return model2.Create(mManageLaboratory.ManageLaboratory)
|
||||
}
|
||||
if !params.pass(c.UID, mManageLaboratory.UID, mManageLaboratory.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageLaboratory.Status = model2.ExamineStatusForOngoing
|
||||
return model2.Updates(mManageLaboratory.ManageLaboratory, mManageLaboratory.ManageLaboratory)
|
||||
}
|
||||
|
||||
// Agent 经纪人
|
||||
func (c *Settled) Agent(params *SettledParams) error {
|
||||
return nil
|
||||
}
|
||||
//
|
||||
//// Expert 专家
|
||||
//func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert) error {
|
||||
// mManageExpert := model3.NewManageExpert()
|
||||
//
|
||||
// err := params.effect(c.UID, mManageExpert.ManageExpert)
|
||||
//
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// mManageExpert.Area = model2.Area{
|
||||
// Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
// }
|
||||
// mManageExpert.SetIndustryAttribute(params.Industrys)
|
||||
// mManageExpert.SetKeywordAttribute(params.Keywords)
|
||||
// mManageExpert.Introduce = params.Introduce
|
||||
// mManageExpert.Position = utils.AnyToJSON(model2.Position{Longitude: other.Longitude, Latitude: other.Latitude})
|
||||
// mManageExpert.School = other.School
|
||||
// mManageExpert.Major = other.Major
|
||||
// mManageExpert.Job = other.Job
|
||||
// mManageExpert.Title = other.Title
|
||||
// mManageExpert.WorkAt = utils.DataTimeToDate(other.WorkAt)
|
||||
// mManageExpert.Research = utils.AnyToJSON(other.Research)
|
||||
//
|
||||
// if mManageExpert.ID <= 0 {
|
||||
// mManageExpert.UID = c.UID
|
||||
// return model2.Create(mManageExpert.ManageExpert)
|
||||
// }
|
||||
// if !params.pass(c.UID, mManageExpert.UID, mManageExpert.Status) {
|
||||
// return errors.New("操作错误,无权限操作")
|
||||
// }
|
||||
// mManageExpert.Status = model2.ExamineStatusForOngoing
|
||||
// return model2.Updates(mManageExpert.ManageExpert, mManageExpert.ManageExpert)
|
||||
//}
|
||||
//
|
||||
//// Research 研究机构
|
||||
//func (c *Settled) Research(params *SettledParams, other *config.IdentityForResearch) error {
|
||||
// mManageResearch := model3.NewManageResearch()
|
||||
//
|
||||
// err := params.effect(c.UID, mManageResearch.ManageResearch)
|
||||
//
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// mManageResearch.Area = model2.Area{
|
||||
// Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
// }
|
||||
// mManageResearch.Industry = params.Industrys
|
||||
// mManageResearch.SetKeywordAttribute(params.Keywords)
|
||||
// mManageResearch.Introduce = params.Introduce
|
||||
// mManageResearch.Position = utils.AnyToJSON(model2.Position{Longitude: other.Longitude, Latitude: other.Latitude})
|
||||
// mManageResearch.Research = other.Research
|
||||
//
|
||||
// if mManageResearch.ID <= 0 {
|
||||
// mManageResearch.UID = c.UID
|
||||
// return model2.Create(mManageResearch.ManageResearch)
|
||||
// }
|
||||
// if !params.pass(c.UID, mManageResearch.UID, mManageResearch.Status) {
|
||||
// return errors.New("操作错误,无权限操作")
|
||||
// }
|
||||
// mManageResearch.Status = model2.ExamineStatusForOngoing
|
||||
// return model2.Updates(mManageResearch.ManageResearch, mManageResearch.ManageResearch)
|
||||
//}
|
||||
//
|
||||
//// Laboratory 实验室
|
||||
//func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLaboratory) error {
|
||||
// mManageLaboratory := model3.NewManageLaboratory()
|
||||
//
|
||||
// err := params.effect(c.UID, mManageLaboratory.ManageLaboratory)
|
||||
//
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// mManageLaboratory.Name = params.Name
|
||||
// mManageLaboratory.Code = params.Code
|
||||
// mManageLaboratory.Area = model2.Area{
|
||||
// Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
// }
|
||||
// mManageLaboratory.Industry = params.Industrys
|
||||
// mManageLaboratory.SetKeywordAttribute(params.Keywords)
|
||||
// mManageLaboratory.Introduce = params.Introduce
|
||||
// mManageLaboratory.Position = utils.AnyToJSON(model2.Position{Longitude: other.Longitude, Latitude: other.Latitude})
|
||||
// mManageLaboratory.Research = utils.AnyToJSON(other.Research)
|
||||
//
|
||||
// if mManageLaboratory.ID <= 0 {
|
||||
// mManageLaboratory.UID = c.UID
|
||||
// return model2.Create(mManageLaboratory.ManageLaboratory)
|
||||
// }
|
||||
// if !params.pass(c.UID, mManageLaboratory.UID, mManageLaboratory.Status) {
|
||||
// return errors.New("操作错误,无权限操作")
|
||||
// }
|
||||
// mManageLaboratory.Status = model2.ExamineStatusForOngoing
|
||||
// return model2.Updates(mManageLaboratory.ManageLaboratory, mManageLaboratory.ManageLaboratory)
|
||||
//}
|
||||
//
|
||||
//// Agent 经纪人
|
||||
//func (c *Settled) Agent(params *SettledParams) error {
|
||||
// return nil
|
||||
//}
|
||||
|
||||
func NewSettled() SettledHandle {
|
||||
return func(session *session.Enterprise, local string) *Settled {
|
||||
|
@ -88,7 +88,8 @@ const (
|
||||
|
||||
// ExamineStatus 审核状态
|
||||
type ExamineStatus struct {
|
||||
Status ExamineStatusKind `gorm:"column:status;type:tinyint(1);default:0;comment:审核状态(0:审核中,1:审核通过,2:审核拒绝)" json:"status"`
|
||||
Status ExamineStatusKind `gorm:"column:status;type:tinyint(1);default:0;comment:审核状态(0:审核中,1:审核通过,2:审核拒绝)" json:"status"`
|
||||
ExamineRemark string `gorm:"column:examine_remark;type:varchar(255);default:null;comment:审核备注" json:"examine_remark"`
|
||||
}
|
||||
|
||||
// ExamineStatusKind 审核状态
|
||||
|
@ -154,6 +154,14 @@ func registerEnterpriseAPI(app *gin.Engine) {
|
||||
_api := new(api2.Sys)
|
||||
sysV1.POST("/patent", _api.Patent)
|
||||
}
|
||||
// Settled 入驻管理
|
||||
settledV1 := v1.Group("/settled")
|
||||
{
|
||||
_api := new(api2.Settled)
|
||||
settledV1.GET("", _api.Index)
|
||||
settledV1.POST("/company", _api.Company)
|
||||
settledV1.POST("/expert", _api.Expert)
|
||||
}
|
||||
// Technology 技术管理
|
||||
technologyV1 := g.Group("/technology")
|
||||
{
|
||||
|
109
utils/code_test.go
Normal file
109
utils/code_test.go
Normal file
@ -0,0 +1,109 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var rank = []string{
|
||||
"Gold Medal", "Silver Medal", "Bronze Medal",
|
||||
}
|
||||
|
||||
type Score struct {
|
||||
Score int
|
||||
Index int
|
||||
}
|
||||
|
||||
func findRelativeRanks(score []int) []string {
|
||||
length := len(score)
|
||||
scores := make([]*Score, length)
|
||||
|
||||
for k, v := range score {
|
||||
scores[k] = &Score{
|
||||
Score: v,
|
||||
Index: k,
|
||||
}
|
||||
}
|
||||
sort.Slice(scores, func(i, j int) bool {
|
||||
return scores[i].Score > scores[j].Score
|
||||
})
|
||||
out := make([]string, length)
|
||||
|
||||
for k, v := range scores {
|
||||
if k < 3 {
|
||||
out[v.Index] = rank[k]
|
||||
continue
|
||||
}
|
||||
out[v.Index] = fmt.Sprintf("%d", k+1)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func twoSum(nums []int, target int) []int {
|
||||
length := len(nums)
|
||||
|
||||
for i := 0; i < length; i++ {
|
||||
for j := i + 1; j < length; j++ {
|
||||
if nums[i]+nums[j] == target {
|
||||
return []int{i, j}
|
||||
}
|
||||
}
|
||||
}
|
||||
return []int{}
|
||||
}
|
||||
|
||||
type ListNode struct {
|
||||
Val int
|
||||
Next *ListNode
|
||||
}
|
||||
|
||||
func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
|
||||
out := new(ListNode)
|
||||
|
||||
if l1 != nil || l2 != nil {
|
||||
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func lengthOfLongestSubstring(s string) int {
|
||||
arrs := make([]map[rune]int, 0)
|
||||
_runes := []rune(s)
|
||||
|
||||
_map := make(map[rune]int, 0)
|
||||
|
||||
length := len(_runes)
|
||||
|
||||
for k, v := range _runes {
|
||||
if _, has := _map[v]; !has {
|
||||
_map[v] = 1
|
||||
if k >= length-1 {
|
||||
goto CONTINUE
|
||||
}
|
||||
continue
|
||||
}
|
||||
CONTINUE:
|
||||
arrs = append(arrs, _map)
|
||||
fmt.Println(_map)
|
||||
_map = map[rune]int{v: 1}
|
||||
}
|
||||
out := 0
|
||||
|
||||
for _, v := range arrs {
|
||||
_length := len(v)
|
||||
if out != _length && _length > out {
|
||||
out = _length
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func TestCode(t *testing.T) {
|
||||
//src := []int{5, 4, 3, 2, 1}
|
||||
//t.Log(findRelativeRanks(src))
|
||||
|
||||
//t.Log(twoSum([]int{3, 2, 4}, 6))
|
||||
t.Log(lengthOfLongestSubstring("dvdf"))
|
||||
|
||||
}
|
@ -3,6 +3,8 @@ package utils
|
||||
import "testing"
|
||||
|
||||
func TestToSnake(t *testing.T) {
|
||||
src := "sys_"
|
||||
t.Log(ToSnake(src, "_"))
|
||||
src := []int{1, 2, 3, 4, 5, 6}
|
||||
t.Log(src)
|
||||
ReverseSlice(src)
|
||||
t.Log(src)
|
||||
}
|
||||
|
8
utils/utils.go
Normal file
8
utils/utils.go
Normal file
@ -0,0 +1,8 @@
|
||||
package utils
|
||||
|
||||
func ReverseSlice(src []int) []int {
|
||||
for from, to := 0, len(src)-1; from < to; from, to = from+1, to-1 {
|
||||
src[from], src[to] = src[to], src[from]
|
||||
}
|
||||
return src
|
||||
}
|
Reference in New Issue
Block a user