feat:优化项目信息

This commit is contained in:
henry
2022-03-05 15:33:22 +08:00
16 changed files with 115 additions and 58 deletions

View File

@ -81,7 +81,7 @@ func loginForPassword(params *AccountLoginParams, tenantID uint64) (*loginHandle
// loginForSmsCaptcha 短信验证码登陆
func loginForSmsCaptcha(params *AccountLoginParams, tenantID uint64) (*loginHandleReturn, error) {
if params.Password == "" {
if params.Captcha == "" {
return nil, errors.New("操作错误,验证码不可为空")
}
// 验证验证码

View File

@ -151,6 +151,7 @@ func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) er
if mManageCompany.ExamineStatus == model2.ExamineStatusForAgree {
_ = manage.Update()
}
return nil
}
// 查询手机号码是否在当前租户下是否已经注册了
mManageCompany.Name = params.Name

View File

@ -5,9 +5,11 @@ import (
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/app/session"
config2 "SciencesServer/config"
"errors"
"strings"
)
// Laboratory 实验室信息
@ -22,7 +24,9 @@ type (
LaboratoryInstance struct {
ID string `json:"id"`
*model.ManageLaboratoryInfo
Area string `json:"area"`
Area string `json:"area"`
Industrys []string `json:"industrys"`
Researchs []string `json:"researchs"`
}
// LaboratorySelect 实验室筛选信息
LaboratorySelect struct {
@ -34,10 +38,10 @@ type (
ID string `json:"id"`
TenantID string `json:"tenant_id"`
*model2.ManageLaboratory
Industrys []*config.Industry `json:"industrys"`
Keywords []string `json:"keywords"`
Researchs []string `json:"researchs"`
Area string `json:"area"`
ResearchID string `json:"research_id"`
Industrys []*config.Industry `json:"industrys"`
Keywords []string `json:"keywords"`
Researchs []string `json:"researchs"`
}
)
@ -69,13 +73,23 @@ func (c *Laboratory) Instance(tenantID uint64, name string, examineStatus, page,
list := make([]*LaboratoryInstance, 0)
for _, v := range out {
mManageLaboratory.Industry = v.Industry
mManageLaboratory.Research = v.Research
v.Address = v.FormatBasic()
_industrys := make([]string, 0)
for _, v := range mManageLaboratory.GetIndustryAttribute() {
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", ">").Value)
}
list = append(list, &LaboratoryInstance{
ID: v.GetEncodeID(), ManageLaboratoryInfo: v, Area: (&model2.Area{
Province: v.TenantProvince,
City: v.TenantCity,
}).FormatBasic(),
Industrys: _industrys,
Researchs: mManageLaboratory.GetResearchAttribute(),
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
@ -158,8 +172,25 @@ func (c *Laboratory) Form(params *BasicParams, other *config.IdentityForLaborato
if c.TenantID <= 0 {
mManageLaboratory.TenantID = params.TenantID
}
_industrys := make([]string, 0)
for _, v := range params.Industrys {
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
}
manage := service.NewESManage(
service.WithManageIdentity(config.TenantUserIdentityForLaboratory),
service.WithManageIndustry(strings.Join(_industrys, "")),
service.WithManageKeyword(strings.Join(params.Keywords, "")),
service.WithManageResearch(strings.Join(other.Researchs, "")),
)
if mManageLaboratory.ID > 0 {
return model2.Updates(mManageLaboratory.ManageLaboratory, mManageLaboratory.ManageLaboratory)
if err := model2.Updates(mManageLaboratory.ManageLaboratory, mManageLaboratory.ManageLaboratory); err != nil {
return err
}
if mManageLaboratory.ExamineStatus == model2.ExamineStatusForAgree {
_ = manage.Update()
}
return nil
}
mManageLaboratory.Name = params.Name
mManageLaboratory.Code = params.Code
@ -172,7 +203,13 @@ func (c *Laboratory) Form(params *BasicParams, other *config.IdentityForLaborato
} else if isExist {
return errors.New("操作错误,已存在同一实验室机构代码")
}
return model2.Create(mManageLaboratory.ManageLaboratory)
if err := model2.Create(mManageLaboratory.ManageLaboratory); err != nil {
return err
}
service.WithManageID(mManageLaboratory.ID)(manage)
service.WithManageTitle(params.Name)(manage)
return manage.Create()
}
@ -197,6 +234,7 @@ func (c *Laboratory) Detail(id uint64) (*LaboratoryDetail, error) {
return &LaboratoryDetail{
ID: out.GetEncodeID(),
TenantID: out.GetEncodeTenantID(),
ResearchID: (&model2.Model{ID: out.ResearchID}).GetEncodeID(),
ManageLaboratory: out.ManageLaboratory,
Industrys: _industrys,
Keywords: out.GetKeywordAttribute(),

View File

@ -5,9 +5,11 @@ import (
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/app/session"
config2 "SciencesServer/config"
"errors"
"strings"
)
// Research 研究机构
@ -165,8 +167,26 @@ func (c *Research) Form(params *BasicParams, other *config.IdentityForResearch)
if c.TenantID <= 0 {
mManageResearch.TenantID = params.TenantID
}
_industrys := make([]string, 0)
for _, v := range params.Industrys {
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
}
manage := service.NewESManage(
service.WithManageIdentity(config.TenantUserIdentityForResearch),
service.WithManageIndustry(strings.Join(_industrys, "")),
service.WithManageKeyword(strings.Join(params.Keywords, "")),
service.WithManageResearch(strings.Join(other.Researchs, "")),
)
if mManageResearch.ID > 0 {
return model2.Updates(mManageResearch.ManageResearch, mManageResearch.ManageResearch)
if err := model2.Updates(mManageResearch.ManageResearch, mManageResearch.ManageResearch); err != nil {
return err
}
if mManageResearch.ExamineStatus == model2.ExamineStatusForAgree {
_ = manage.Update()
}
return nil
}
mManageResearch.Name = params.Name
mManageResearch.Code = params.Code
@ -179,7 +199,13 @@ func (c *Research) Form(params *BasicParams, other *config.IdentityForResearch)
} else if isExist {
return errors.New("操作错误,已存在同一研究机构代码")
}
return model2.Create(mManageResearch.ManageResearch)
if err := model2.Create(mManageResearch.ManageResearch); err != nil {
return err
}
service.WithManageID(mManageResearch.ID)(manage)
service.WithManageTitle(params.Name)(manage)
return manage.Create()
}
// Detail 详细信息

View File

@ -17,9 +17,11 @@ type (
model.Model
Name string `json:"name"`
Industry string `json:"industry"`
Research string `json:"research"`
ResearchName string `json:"research_name"`
model.Image
model.Area
model.Examine
CreatedAt time.Time `json:"created_at"`
TenantProvince string `json:"-"`
TenantCity string `json:"-"`
@ -27,7 +29,6 @@ type (
// ManageLaboratoryDetail 实验室详细信息
ManageLaboratoryDetail struct {
*model.ManageLaboratory
model.Area
}
)
@ -48,12 +49,12 @@ func (m *ManageLaboratory) Laboratory(id uint64) (*ManageLaboratoryDetail, error
// Laboratorys 实验室信息
func (m *ManageLaboratory) Laboratorys(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageLaboratoryInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS l").
Select("l.id", "l.name", "l.industry", "l.name AS research_name", "l.image",
Select("l.id", "l.name", "l.industry", "l.research", "r.name AS research_name", "l.image", "l.examine_status",
"l.province", "l.city", "l.created_at",
"t.province AS tenant_province", "t.city AS tenant_city").
Joins(fmt.Sprintf("LEFT JOIN %s AS r ON l.research_id = r.id", model.NewManageResearch().TableName())).
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON l.tenant_id = t.id", model.NewSysTenant().TableName())).
Where("e.is_deleted = ?", model.DeleteStatusForNot)
Where("l.is_deleted = ?", model.DeleteStatusForNot)
if len(where) > 0 {
for _, v := range where {

View File

@ -4,6 +4,7 @@ import (
"SciencesServer/app/api/enterprise/controller/user"
"SciencesServer/app/basic/api"
"SciencesServer/app/session"
"github.com/gin-gonic/gin"
)

View File

@ -9,8 +9,9 @@ import (
config2 "SciencesServer/config"
"SciencesServer/serve/orm"
"errors"
"gorm.io/gorm"
"time"
"gorm.io/gorm"
)
type Identity struct{ *session.Enterprise }
@ -213,7 +214,7 @@ func (c *Identity) Switch(identity int) error {
if c.Identity&identity > 0 {
mUserIdentity := model.NewUserIdentity()
// 查询用户身份
isExist, err := model2.FirstField(mUserIdentity.UserIdentity, []string{"id", "name", "uuid"},
isExist, err := model2.FirstField(mUserIdentity.UserIdentity, []string{"id", "name", "uid"},
model2.NewWhere("uid", c.UID), model2.NewWhere("identity", identity))
if err != nil {
@ -224,7 +225,7 @@ func (c *Identity) Switch(identity int) error {
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
if err = model2.UpdatesWhere(mUserIdentity.UserIdentity, map[string]interface{}{
"is_selected": model2.UserIdentitySelectedForNo, "updated_at": now,
}, []*model2.ModelWhere{model2.NewWhere("uuid", c.IdentityUID)}, tx); err != nil {
}, []*model2.ModelWhere{model2.NewWhere("uid", c.IdentityUID)}, tx); err != nil {
return err
}
return model2.Updates(mUserIdentity.UserIdentity, map[string]interface{}{
@ -235,7 +236,7 @@ func (c *Identity) Switch(identity int) error {
}
}
c.SelectIdentity = identity
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccountEnterprise, c.GetStringUID(), c.Enterprise)
service.Publish(config2.EventForRedisHashProduce, config2.RedisKeyForAccountEnterprise, c.GetStringUID(), c.Enterprise)
return nil
}
return errors.New("操作错误,无效的身份信息")

View File

@ -3,6 +3,8 @@ package api
import (
"SciencesServer/app/api/website/controller"
"SciencesServer/app/basic/api"
"strings"
"github.com/gin-gonic/gin"
)
@ -17,6 +19,6 @@ func (*Config) Index(c *gin.Context) {
api.APIFailure(err.(error))(c)
return
}
data, err := controller.NewConfig()(nil).Instance(form.Kind, form.Key)
data, err := controller.NewConfig()(nil).Instance(form.Kind, strings.Split(form.Key, ","))
api.APIResponse(err, data)(c)
}

View File

@ -26,8 +26,9 @@ type (
ActivityInfo struct {
ID string `json:"id"`
*model.ActivityInstanceInfo
IsJoin bool `json:"is_join"`
Status int `json:"status"` // 状态1未开始2进行中3已结束
Amount float64 `json:"amount"`
IsJoin bool `json:"is_join"`
Status int `json:"status"` // 状态1未开始2进行中3已结束
}
// ActivityDetail 详细信息
ActivityDetail struct {
@ -76,7 +77,7 @@ func (c *Activity) Instance(title, industry string, status, page, pageSize int)
v.Image.Image = v.Image.Analysis(config.SystemConfig[config.SysImageDomain])
data := &ActivityInfo{
ID: v.GetEncodeID(), ActivityInstanceInfo: v, IsJoin: v.JoinID > 0, Status: 2,
ID: v.GetEncodeID(), Amount: v.Amount, ActivityInstanceInfo: v, IsJoin: v.JoinID > 0, Status: 2,
}
if now.Before(v.BeginAt) {
data.Status = 1

View File

@ -17,8 +17,9 @@ type (
model.Model
model.Image
*model.ActivityInstanceBasic
JoinID uint64 `json:"-"`
JoinCount int `json:"join_count"`
Amount float64 `json:"amount"`
JoinID uint64 `json:"-"`
JoinCount int `json:"join_count"`
}
// ActivityInstanceDetail 活动详细信息
ActivityInstanceDetail struct {
@ -33,7 +34,7 @@ func (m *ActivityInstance) Activity(uid uint64, identity, page, pageSize int, co
mActivityJoin := model.NewActivityJoin()
db := orm.GetDB().Table(m.TableName()+" AS a").
Select("a.id", "a.title", "a.image", "a.begin_at", "a.finish_at", "a.join_deadline",
Select("a.id", "a.title", "a.image", "a.begin_at", "a.amount", "a.finish_at", "a.join_deadline",
"IFNULL(u.id, 0) AS join_id", "j.count AS join_count").
Joins(fmt.Sprintf("LEFT JOIN %s u ON a.id = u.activity_id AND u.uid = %d AND u.identity = %d AND u.status = %d AND u.is_deleted = %d",
mActivityJoin.TableName(), uid, identity, model.ActivityJoinStatusForSuccess, model.DeleteStatusForNot)).

View File

@ -5,9 +5,10 @@ import (
"SciencesServer/serve/logger"
"SciencesServer/utils"
"errors"
"net/http"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"net/http"
)
const (

View File

@ -53,7 +53,7 @@ type (
}
// IdentityForAgent 经纪人
IdentityForAgent struct {
ResearchID string `json:"research_id" form:"research_id" binding:"required"` // 科研机构ID
ResearchID string `json:"research_id" form:"research_id"` // 科研机构ID
IDCard string `json:"id_card" form:"id_card" binding:"required"` // 身份证号
WorkExperience string `json:"work_experience" form:"work_experience" binding:"required"` // 工作经历
WorkPlace string `json:"work_place" form:"work_place" binding:"required"` // 工作地点