熊哥提交

This commit is contained in:
henry
2022-02-23 15:18:55 +08:00
parent dcb5948e91
commit 84dd9d1ea8
13 changed files with 125 additions and 61 deletions

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

@ -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

@ -4,7 +4,6 @@ import (
"SciencesServer/app/api/admin/model"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/session"
"errors"
)
type Config struct{ *session.Enterprise }
@ -19,22 +18,36 @@ type (
}
)
func (c *Config) Instance(kind int, key string) (*ConfigInfo, error) {
func (c *Config) Instance(kind int, key []string) (map[string]*ConfigInfo, error) {
mSysConfig := model.NewSysConfig()
where := []*model2.ModelWhere{model2.NewWhere("`key`", key)}
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
Where: model2.NewWhereIn("`key`", key),
Order: nil,
}}
if kind > 0 {
where = append(where, model2.NewWhere("kind", kind))
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhere("kind", kind),
Order: nil,
})
}
isExist, err := model2.FirstField(mSysConfig.SysConfig, []string{"id", "name", "`value`"}, where...)
out := make([]*model2.SysConfig, 0)
err := model2.ScanFields(mSysConfig.SysConfig, &out, []string{"id", "`key`", "name", "`value`"}, where...)
if err != nil {
return nil, err
} else if !isExist {
return nil, errors.New("操作错误,数据不存在或已被删除")
}
return &ConfigInfo{Name: mSysConfig.Name, Value: mSysConfig.Value}, nil
list := make(map[string]*ConfigInfo, 0)
for _, v := range out {
list[v.Key] = &ConfigInfo{
Name: v.Name,
Value: v.Value,
}
}
return list, nil
}
func NewConfig() ConfigHandle {

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"` // 工作地点