浏览代码

新增是否为研究员判断

hsun 2 年之前
父节点
当前提交
7af2d42079

+ 28 - 11
logic/user/user.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hongze_yb/models/tables/company"
 	"hongze/hongze_yb/models/tables/company_product"
 	"hongze/hongze_yb/models/tables/rddp/msg_code"
+	"hongze/hongze_yb/models/tables/research_group_relation"
 	"hongze/hongze_yb/models/tables/wx_user"
 	"hongze/hongze_yb/models/tables/yb_apply_record"
 	"hongze/hongze_yb/models/tables/yb_message"
@@ -109,6 +110,7 @@ type Detail struct {
 	SellerMobile   string              `json:"seal_mobile" description:"所属销售手机号"`
 	PermissionList []CompanyPermission `json:"permission_list" description:"权限列表"`
 	IsInner        int                 `json:"is_inner" description:"是否为内部员工"`
+	IsResearcher   int                 `json:"is_researcher" description:"是否为研究员"`
 	AdminInfo      *admin2.Admin       `json:"admin_info" description:"系统管理员信息"`
 	UnRead         int64               `json:"un_read" description:"消息未读数"`
 	NickName       string              `json:"nick_name" description:"用户昵称"`
@@ -220,18 +222,33 @@ func GetUserInfo(userInfo user.UserInfo) (userDetail Detail, err error, errMsg s
 	if headimgurl == "" {
 		headimgurl = utils.DEFAULT_HONGZE_USER_LOGO
 	}
+	// 查询是否为研究员
+	isResearcher := 0
+	if isInner == 1 {
+		researchGroupList, e := research_group_relation.GetResearchGroupRelationByAdminId(int(adminInfo.AdminID))
+		if e != nil {
+			errMsg = "查询是否为研究员失败"
+			err = errors.New("用户身份信息有误")
+			return
+		}
+		if len(researchGroupList) > 0 {
+			isResearcher = 1
+		}
+	}
+
 	userDetail = Detail{
-		CompanyName:    companyName, 		//客户名称(公司名称)
-		Status:         status,      		//产品状态
-		IsSuspend:      isSuspend,   		//是否启用
+		CompanyName:    companyName, //客户名称(公司名称)
+		Status:         status,      //产品状态
+		IsSuspend:      isSuspend,   //是否启用
 		RealName:       userInfo.RealName,
 		Mobile:         userInfo.Mobile,
 		Email:          userInfo.Email,
 		SellerName:     sellerName,
 		SellerMobile:   sellerMobile,
-		PermissionList: list,				//权限列表
-		IsInner: 		isInner,			// 是否为内部员工
-		AdminInfo: 		adminInfo,			// 系统管理员信息
+		PermissionList: list,         //权限列表
+		IsInner:        isInner,      // 是否为内部员工
+		IsResearcher:   isResearcher, // 是否为研究员
+		AdminInfo:      adminInfo,    // 系统管理员信息
 		UnRead:         unRead,
 		NickName:       userInfo.NickName,
 		HeadImgUrl:     headimgurl,
@@ -246,14 +263,14 @@ func SetUserInfo(userInfo user.UserInfo, req userReq.SetUserInfoReq) (err error)
 	// todo 用户如果没有设置头像,用默认头像也允许上传
 	// 校验昵称长度
 	// 校验头像地址是否正确
-	if !strings.Contains(req.HeadImgUrl, "http://") && !strings.Contains(req.HeadImgUrl, "https://")  {
+	if !strings.Contains(req.HeadImgUrl, "http://") && !strings.Contains(req.HeadImgUrl, "https://") {
 		err = errors.New("上传头像出错")
 		return
 	}
 	wxUser := userInfo.WxUser
 	wxUser.NickName = req.NickName
 	wxUser.Headimgurl = req.HeadImgUrl
-	err = wxUser.Update([]string{"nick_name","headimgurl"})
+	err = wxUser.Update([]string{"nick_name", "headimgurl"})
 	if err != nil {
 		err = errors.New("更新用户信息操作失败")
 		return
@@ -294,7 +311,7 @@ func Apply(userId int, companyId int64, mobile, email string, applyInfo userReq.
 
 	tmpmYbApplyRecord, err := yb_apply_record.GetLastNotOpRecordByUserId(userId)
 	if err == nil {
-		ybApplyRecord = tmpmYbApplyRecord	// 申请来源每一种只存在一条数据
+		ybApplyRecord = tmpmYbApplyRecord // 申请来源每一种只存在一条数据
 		return
 	} else {
 		if err != utils.ErrNoRow {
@@ -355,7 +372,7 @@ func Apply(userId int, companyId int64, mobile, email string, applyInfo userReq.
 		CompanyIDPay:    int(companyId),
 		CompanyNamePay:  companyName,
 		CreateTime:      time.Now(),
-		Source: 		 applyInfo.Source,
+		Source:          applyInfo.Source,
 		SourceAgent:     applyInfo.SourceAgent,
 		FromPage:        applyInfo.FromPage,
 	}
@@ -467,4 +484,4 @@ func PcSendEmailCode(email string) (err error, errMsg string) {
 	}
 
 	return
-}
+}

+ 24 - 0
models/tables/research_group_relation/entity.go

@@ -0,0 +1,24 @@
+package research_group_relation
+
+// ResearchGroupRelation 研究方向分组关系表
+type ResearchGroupRelation struct {
+	ID              int `gorm:"primaryKey;column:id;type:int(10) unsigned;not null" json:"-"`
+	ResearchGroupID int `gorm:"column:research_group_id;type:int(10) unsigned;not null;default:0" json:"researchGroupId"` // 研究方向分组ID
+	AdminID         int `gorm:"column:admin_id;type:int(10) unsigned;not null;default:0" json:"adminId"`                  // 研究员ID
+}
+
+// TableName get sql table name.获取数据库表名
+func (m *ResearchGroupRelation) TableName() string {
+	return "research_group_relation"
+}
+
+// ResearchGroupRelationColumns get sql column name.获取数据库列名
+var ResearchGroupRelationColumns = struct {
+	ID              string
+	ResearchGroupID string
+	AdminID         string
+}{
+	ID:              "id",
+	ResearchGroupID: "research_group_id",
+	AdminID:         "admin_id",
+}

+ 9 - 0
models/tables/research_group_relation/model.go

@@ -0,0 +1,9 @@
+package research_group_relation
+
+import "hongze/hongze_yb/global"
+
+// GetResearchGroupRelationByAdminId 获取研究员研究方向分组
+func GetResearchGroupRelationByAdminId(adminId int) (items []*ResearchGroupRelation, err error) {
+	err = global.DEFAULT_MYSQL.Model(ResearchGroupRelation{}).Where("admin_id = ?", adminId).Scan(&items).Error
+	return
+}

+ 3 - 0
services/user/user.go

@@ -426,6 +426,9 @@ func GetAdminByUserInfo(userInfo UserInfo) (ok bool, adminInfo *admin2.Admin, er
 		// 用户有可能是通过邮箱登录
 		return
 	}
+	if userInfo.CompanyID != 16 {
+		return
+	}
 	adminInfo, err = admin2.GetAdminByMobile(mobile)
 	if err != nil {
 		if err == utils.ErrNoRow {