feat:完善信息
This commit is contained in:
@ -11,10 +11,13 @@ type IDForm struct {
|
||||
}
|
||||
|
||||
type IDStringForm struct {
|
||||
ID string `json:"id" form:"id" binding:"required"`
|
||||
ID string `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
func (this *IDStringForm) Convert() uint64 {
|
||||
if this.ID == "" {
|
||||
return 0
|
||||
}
|
||||
return uint64(utils.HASHIDDecode(this.ID))
|
||||
}
|
||||
|
||||
|
@ -2,16 +2,39 @@ package config
|
||||
|
||||
// Area 区域
|
||||
type Area struct {
|
||||
Province uint64 `json:"province"`
|
||||
City uint64 `json:"city"`
|
||||
District uint64 `json:"district"`
|
||||
Address string `json:"address"`
|
||||
Province uint64 `json:"province" form:"province"`
|
||||
City uint64 `json:"city" form:"city"`
|
||||
District uint64 `json:"district" form:"district"`
|
||||
Address string `json:"address" form:"address"`
|
||||
}
|
||||
|
||||
type (
|
||||
// IdentityForCompany 公司附加信息
|
||||
IdentityForCompany struct {
|
||||
Industry uint64 `json:"industry"`
|
||||
Keywords []string `json:"keywords"`
|
||||
IdentityForCompany struct{}
|
||||
// IdentityForExpert 专家附加信息
|
||||
IdentityForExpert struct {
|
||||
TenantID uint64 `json:"tenant_id" form:"tenant_id"`
|
||||
Longitude float64 `json:"longitude" form:"longitude"` // 经度
|
||||
Latitude float64 `json:"latitude" form:"latitude"` // 纬度
|
||||
School string `json:"school" form:"school"`
|
||||
Major string `json:"major" form:"major"`
|
||||
Job string `json:"job" form:"job"`
|
||||
Title string `json:"title" form:"title"`
|
||||
WorkAt string `json:"work_at" form:"work_at"`
|
||||
Keyword string `json:"keyword" form:"keyword"`
|
||||
Research map[int]string `json:"research" form:"research"` // 研究方向
|
||||
}
|
||||
// IdentityForResearch 研究机构
|
||||
IdentityForResearch struct {
|
||||
Longitude float64 `json:"longitude" form:"longitude"` // 经度
|
||||
Latitude float64 `json:"latitude" form:"latitude"` // 纬度
|
||||
Research string `json:"research" form:"research"` // 研究方向
|
||||
}
|
||||
// IdentityForLaboratory 实验室
|
||||
IdentityForLaboratory struct {
|
||||
TenantID uint64 `json:"tenant_id" form:"tenant_id"`
|
||||
Longitude float64 `json:"longitude" form:"longitude"` // 经度
|
||||
Latitude float64 `json:"latitude" form:"latitude"` // 纬度
|
||||
Research map[int]string `json:"research" form:"research"` // 研究方向
|
||||
}
|
||||
)
|
||||
|
45
app/common/model/manage_expert.go
Normal file
45
app/common/model/manage_expert.go
Normal file
@ -0,0 +1,45 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ManageExpert 专家入驻信息管理
|
||||
type ManageExpert struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Area
|
||||
Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"`
|
||||
School string `gorm:"column:school;type:varchar(50);default:null;comment:坐标" json:"school"`
|
||||
Major string `gorm:"column:major;type:varchar(50);default:null;comment:专业" json:"major"`
|
||||
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
||||
Title string `gorm:"column:title;type:varchar(50);default:null;comment:职称" json:"title"`
|
||||
WorkAt time.Time `gorm:"column:work_at;type:date;not null;comment:从业时间" json:"work_at"`
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
ExamineStatus
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageExpert) TableName() string {
|
||||
return "manage_expert"
|
||||
}
|
||||
|
||||
func (m *ManageExpert) GetKeywordAttribute() []string {
|
||||
keywords := make([]string, 0)
|
||||
_ = utils.FromJSON(m.Keyword, &keywords)
|
||||
return keywords
|
||||
}
|
||||
|
||||
func (m *ManageExpert) SetKeywordAttribute(keywords []string) {
|
||||
m.Keyword = utils.AnyToJSON(keywords)
|
||||
}
|
||||
|
||||
func NewManageExpert() *ManageExpert {
|
||||
return &ManageExpert{}
|
||||
}
|
42
app/common/model/manage_laboratory.go
Normal file
42
app/common/model/manage_laboratory.go
Normal file
@ -0,0 +1,42 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
)
|
||||
|
||||
// ManageLaboratory 实验室信息管理
|
||||
type ManageLaboratory struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"`
|
||||
Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"`
|
||||
Image
|
||||
Area
|
||||
Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"`
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
ExamineStatus
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageLaboratory) TableName() string {
|
||||
return "manage_laboratory"
|
||||
}
|
||||
|
||||
func (m *ManageLaboratory) GetKeywordAttribute() []string {
|
||||
keywords := make([]string, 0)
|
||||
_ = utils.FromJSON(m.Keyword, &keywords)
|
||||
return keywords
|
||||
}
|
||||
|
||||
func (m *ManageLaboratory) SetKeywordAttribute(keywords []string) {
|
||||
m.Keyword = utils.AnyToJSON(keywords)
|
||||
}
|
||||
|
||||
func NewManageLaboratory() *ManageLaboratory {
|
||||
return &ManageLaboratory{}
|
||||
}
|
41
app/common/model/manage_research.go
Normal file
41
app/common/model/manage_research.go
Normal file
@ -0,0 +1,41 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
)
|
||||
|
||||
// ManageResearch 科研机构信息管理
|
||||
type ManageResearch struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"`
|
||||
Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"`
|
||||
Image
|
||||
Area
|
||||
Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"`
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
ExamineStatus
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageResearch) TableName() string {
|
||||
return "manage_expert"
|
||||
}
|
||||
|
||||
func (m *ManageResearch) GetKeywordAttribute() []string {
|
||||
keywords := make([]string, 0)
|
||||
_ = utils.FromJSON(m.Keyword, &keywords)
|
||||
return keywords
|
||||
}
|
||||
|
||||
func (m *ManageResearch) SetKeywordAttribute(keywords []string) {
|
||||
m.Keyword = utils.AnyToJSON(keywords)
|
||||
}
|
||||
|
||||
func NewManageResearch() *ManageResearch {
|
||||
return &ManageResearch{}
|
||||
}
|
@ -4,14 +4,14 @@ type UserTenant struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_tenant_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);default:null;comment:头像" json:"avatar"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
||||
Email string `gorm:"column:email;type:varchar(50);default:null;comment:邮箱" json:"email"`
|
||||
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
||||
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份信息" json:"-"`
|
||||
FixedPhone string `gorm:"column:fixed_phone;type:varchar(20);default:null;comment:固定电话" json:"fixed_phone"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"`
|
||||
Selected UserTenantSelected `gorm:"column:selected;type:tinyint(1);default:0;comment:最后一次选中的身份状态,用于下次登陆展示" json:"-"`
|
||||
Other string `gorm:"column:other;type:varchar(255);default:null;comment:其他信息" json:"-"`
|
||||
Status UserTenantStatus `gorm:"column:status;type:tinyint(0);default:0;comment:状态" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
@ -25,17 +25,6 @@ const (
|
||||
UserTenantSelectedForYes
|
||||
)
|
||||
|
||||
type UserTenantStatus int
|
||||
|
||||
const (
|
||||
// UserTenantStatusForExamineRefuse 审核拒绝
|
||||
UserTenantStatusForExamineRefuse UserTenantStatus = iota
|
||||
// UserTenantStatusForExamining 审核中
|
||||
UserTenantStatusForExamining
|
||||
// UserTenantStatusForExaminePass 审核通过
|
||||
UserTenantStatusForExaminePass
|
||||
)
|
||||
|
||||
func (m *UserTenant) TableName() string {
|
||||
return m.NewTableName("user_tenant")
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ func (a *Technology) PaperEdit(c *gin.Context) {
|
||||
api.IDStringForm
|
||||
paperForm
|
||||
}{}
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
|
@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/enterprise/controller/tenant"
|
||||
"SciencesServer/app/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -9,11 +10,75 @@ import (
|
||||
|
||||
type Tenant struct{}
|
||||
|
||||
type SettledBasic struct {
|
||||
api.IDStringForm
|
||||
api.ImageForm
|
||||
Name string `json:"name" form:"name"`
|
||||
Code string `json:"code" form:"code"`
|
||||
config.Area
|
||||
Introduce string `json:"introduce" form:"introduce"`
|
||||
Industry uint64 `json:"industry" form:"industry"`
|
||||
Keywords []string `json:"keywords" form:"keywords"`
|
||||
}
|
||||
|
||||
func (a *Tenant) SettledCompany(c *gin.Context) {
|
||||
err := tenant.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Company(nil, nil)
|
||||
form := &struct {
|
||||
SettledBasic
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := tenant.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Company(&tenant.SettledParams{
|
||||
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
||||
}, nil)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (a *Tenant) SettledExpert(c *gin.Context) {
|
||||
|
||||
form := &struct {
|
||||
SettledBasic
|
||||
config.IdentityForExpert
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := tenant.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Expert(&tenant.SettledParams{
|
||||
ID: form.Convert(), Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
||||
}, &form.IdentityForExpert)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (a *Tenant) SettledResearch(c *gin.Context) {
|
||||
form := &struct {
|
||||
SettledBasic
|
||||
config.IdentityForResearch
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := tenant.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Research(&tenant.SettledParams{
|
||||
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
||||
}, &form.IdentityForResearch)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (a *Tenant) SettledLaboratory(c *gin.Context) {
|
||||
form := &struct {
|
||||
SettledBasic
|
||||
config.IdentityForLaboratory
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := tenant.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Laboratory(&tenant.SettledParams{
|
||||
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
||||
}, &form.IdentityForLaboratory)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
@ -16,12 +16,10 @@ func (a *User) Info(c *gin.Context) {
|
||||
|
||||
func (a *User) Perfect(c *gin.Context) {
|
||||
form := &struct {
|
||||
Avatar string `json:"avatar" form:"avatar" binding:"required"` // 头像
|
||||
Name string `json:"name" form:"name" binding:"required"` // 名称
|
||||
Email string `json:"email" form:"email" binding:"required"` // 邮箱
|
||||
Job string `json:"job" form:"job" binding:"required"` // 职务
|
||||
Address string `json:"address" form:"address" ` // 地址
|
||||
Company user.TenantParamsForCompany `json:"company" form:"company"` // 公司属性
|
||||
FixedPhone string `json:"fixed_phone" form:"fixed_phone" ` // 固定电话
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
@ -29,9 +27,8 @@ func (a *User) Perfect(c *gin.Context) {
|
||||
}
|
||||
err := user.NewTenant()(api.GetSession()(c).(*service.SessionEnterprise)).Perfect(&user.TenantPerfectParams{
|
||||
TenantBasicParams: &user.TenantBasicParams{
|
||||
Avatar: form.Avatar, Name: form.Name, Email: form.Email, Job: form.Job, Address: form.Address,
|
||||
Name: form.Name, Email: form.Email, Job: form.Job, FixedPhone: form.FixedPhone,
|
||||
},
|
||||
TenantParamsForCompany: &form.Company,
|
||||
})
|
||||
api.APIResponse(err)
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/enterprise/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
)
|
||||
|
||||
@ -19,9 +20,12 @@ type SettledParams struct {
|
||||
Name string // 名称
|
||||
Code string // 唯一编码
|
||||
config.Area
|
||||
Introduce string `json:"introduce"`
|
||||
Introduce string
|
||||
Industry uint64 `json:"industry"`
|
||||
Keywords []string `json:"keywords"`
|
||||
}
|
||||
|
||||
// effect 入驻信息有效性
|
||||
func (c *SettledParams) effect(uid uint64, iModel model2.IModel) error {
|
||||
if c.ID <= 0 {
|
||||
var count int64
|
||||
@ -41,6 +45,14 @@ func (c *SettledParams) effect(uid uint64, iModel model2.IModel) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// pass 入驻信息通过性
|
||||
func (c *SettledParams) pass(uid, mUID uint64, mStatus model2.ExamineStatusKind) bool {
|
||||
if mUID != uid || mStatus != model2.ExamineStatusForRefuse {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Company 公司企业
|
||||
func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompany) error {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
@ -56,34 +68,115 @@ func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompan
|
||||
mManageCompany.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageCompany.Industry = other.Industry
|
||||
mManageCompany.SetKeywordAttribute(other.Keywords)
|
||||
mManageCompany.Industry = params.Industry
|
||||
mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
mManageCompany.Introduce = params.Introduce
|
||||
|
||||
if mManageCompany.ID <= 0 {
|
||||
mManageCompany.UID = c.UID
|
||||
return model2.Create(mManageCompany.ManageCompany)
|
||||
}
|
||||
if mManageCompany.UID != c.UID {
|
||||
return errors.New("异常,无权限操作")
|
||||
} else if mManageCompany.Status != model2.ExamineStatusForRefuse {
|
||||
return errors.New("操作错误,不允许操作")
|
||||
if !params.pass(c.UID, mManageCompany.UID, mManageCompany.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageCompany.Status = model2.ExamineStatusForOngoing
|
||||
return model2.Updates(mManageCompany.ManageCompany, mManageCompany.ManageCompany)
|
||||
}
|
||||
|
||||
// Expert 专家
|
||||
func (c *Settled) Expert() {
|
||||
func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert) error {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
err := params.effect(c.UID, mManageExpert.ManageExpert)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mManageExpert.TenantID = other.TenantID
|
||||
mManageExpert.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageExpert.Industry = params.Industry
|
||||
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() {
|
||||
func (c *Settled) Research(params *SettledParams, other *config.IdentityForResearch) error {
|
||||
mManageResearch := model.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.Industry
|
||||
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() {
|
||||
func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLaboratory) error {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
|
||||
err := params.effect(c.UID, mManageLaboratory.ManageLaboratory)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mManageLaboratory.TenantID = other.TenantID
|
||||
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.Industry
|
||||
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 经纪人
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"SciencesServer/app/service"
|
||||
config2 "SciencesServer/config"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
@ -18,11 +17,10 @@ type Tenant struct{ *service.SessionEnterprise }
|
||||
type TenantHandle func(session *service.SessionEnterprise) *Tenant
|
||||
|
||||
type TenantBasicParams struct {
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Name string `json:"name"` // 名称
|
||||
Email string `json:"email"` // 邮箱
|
||||
Job string `json:"job"` // 职务
|
||||
Address string `json:"address"` // 详细地址
|
||||
FixedPhone string `json:"fixed_phone"` // 固定电话
|
||||
}
|
||||
|
||||
type TenantIndustryParams struct {
|
||||
@ -32,37 +30,34 @@ type (
|
||||
// TenantPerfectParams 完善信息参数
|
||||
TenantPerfectParams struct {
|
||||
*TenantBasicParams // 基本信息
|
||||
*TenantParamsForCompany // 公司身份信息
|
||||
}
|
||||
// TenantParamsForCompany 公司参数信息
|
||||
TenantParamsForCompany struct {
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
config.Area
|
||||
model2.Position
|
||||
Industry string `json:"industry"`
|
||||
Introduce string `json:"introduce"`
|
||||
}
|
||||
)
|
||||
|
||||
// tenantHandlePerfect 完善信息处理方式
|
||||
var tenantHandlePerfect = map[int]func(params *TenantPerfectParams) (string, error){
|
||||
config.TenantUserIdentityForCompany: perfectForCompany,
|
||||
config.TenantUserIdentityForExpert: perfectForExpert,
|
||||
config.TenantUserIdentityForResearch: perfectForResearch,
|
||||
config.TenantUserIdentityForLaboratory: perfectForLaboratory,
|
||||
}
|
||||
|
||||
func perfectForCompany(params *TenantPerfectParams) (string, error) {
|
||||
if params.TenantParamsForCompany == nil {
|
||||
return "", errors.New("企业信息异常")
|
||||
}
|
||||
return utils.AnyToJSON(params.TenantParamsForCompany), nil
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func perfectForExpert(params *TenantPerfectParams) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func perfectForResearch() error {
|
||||
return nil
|
||||
func perfectForResearch(params *TenantPerfectParams) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func perfectForLaboratory(params *TenantPerfectParams) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// Perfect 完善信息
|
||||
@ -76,48 +71,25 @@ func (c *Tenant) Perfect(params *TenantPerfectParams) error {
|
||||
// 查询用户身份信息
|
||||
mUserTenant := model.NewUserTenant()
|
||||
|
||||
isExist, err := model2.FirstField(mUserTenant.UserTenant, []string{"id", "name", "identity", "status"},
|
||||
isExist, err := model2.FirstField(mUserTenant.UserTenant, []string{"id", "name", "identity"},
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("identity", c.Identity))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
if mUserTenant.Status != model2.UserTenantStatusForExamining {
|
||||
return errors.New("资料审核中,不可修改")
|
||||
} else if mUserTenant.Status != model2.UserTenantStatusForExaminePass {
|
||||
return errors.New("资料审核已通过,不可修改")
|
||||
}
|
||||
}
|
||||
mUserTenant.Avatar = params.TenantBasicParams.Avatar
|
||||
mUserTenant.Name = params.TenantBasicParams.Name
|
||||
mUserTenant.Email = params.TenantBasicParams.Email
|
||||
mUserTenant.Identity = c.SelectIdentity
|
||||
mUserTenant.Address = params.TenantBasicParams.Address
|
||||
mUserTenant.Job = params.TenantBasicParams.Job
|
||||
mUserTenant.FixedPhone = params.TenantBasicParams.FixedPhone
|
||||
|
||||
if mUserTenant.Other, err = _handle(params); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserTenant.Status = model2.UserTenantStatusForExamining
|
||||
|
||||
if isExist {
|
||||
if err = model2.Updates(mUserTenant.UserTenant, mUserTenant.UserTenant); err != nil {
|
||||
return err
|
||||
if !isExist {
|
||||
mUserTenant.Identity = c.SelectIdentity
|
||||
return model2.Create(mUserTenant.UserTenant)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Updates(mUserTenant.UserTenant, map[string]interface{}{
|
||||
"selected": model2.UserTenantSelectedForNo, "updated_at": time.Now(),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserTenant.Selected = model2.UserTenantSelectedForYes
|
||||
|
||||
return model2.Create(mUserTenant.UserTenant, tx)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return model2.Updates(mUserTenant.UserTenant, mUserTenant.UserTenant)
|
||||
}
|
||||
|
||||
// Auth 认证
|
||||
|
11
app/enterprise/model/manage_expert.go
Normal file
11
app/enterprise/model/manage_expert.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ManageExpert struct {
|
||||
*model.ManageExpert
|
||||
}
|
||||
|
||||
func NewManageExpert() *ManageExpert {
|
||||
return &ManageExpert{model.NewManageExpert()}
|
||||
}
|
11
app/enterprise/model/manage_laboratory.go
Normal file
11
app/enterprise/model/manage_laboratory.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ManageLaboratory struct {
|
||||
*model.ManageLaboratory
|
||||
}
|
||||
|
||||
func NewManageLaboratory() *ManageLaboratory {
|
||||
return &ManageLaboratory{model.NewManageLaboratory()}
|
||||
}
|
11
app/enterprise/model/manage_research.go
Normal file
11
app/enterprise/model/manage_research.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ManageResearch struct {
|
||||
*model.ManageResearch
|
||||
}
|
||||
|
||||
func NewManageResearch() *ManageResearch {
|
||||
return &ManageResearch{model.NewManageResearch()}
|
||||
}
|
@ -38,6 +38,11 @@ func DateTimeToTime(t string) time.Time {
|
||||
return _time
|
||||
}
|
||||
|
||||
func DataTimeToDate(t string) time.Time {
|
||||
_time, _ := time.ParseInLocation("2006-01-02", t, time.Local)
|
||||
return _time
|
||||
}
|
||||
|
||||
func GetMondayTime(t time.Time) time.Time {
|
||||
offset := int(time.Monday - t.Weekday())
|
||||
|
||||
|
Reference in New Issue
Block a user