浏览代码

企业管理员更换手机号没有权限处理

WH01243 1 年之前
父节点
当前提交
efd8c3facd
共有 1 个文件被更改,包括 39 次插入8 次删除
  1. 39 8
      entbase/src/service/phone/phone.go

+ 39 - 8
entbase/src/service/phone/phone.go

@@ -1,10 +1,12 @@
-//手机号绑定、更换
+// 手机号绑定、更换
 package phone
 
 import (
 	"database/sql"
 	"entbase/src/config"
 	"fmt"
+	"log"
+	"net/rpc"
 
 	. "app.yhyue.com/moapp/jybase/api"
 	qutil "app.yhyue.com/moapp/jybase/common"
@@ -12,8 +14,6 @@ import (
 	"app.yhyue.com/moapp/jybase/encrypt"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
-	. "app.yhyue.com/moapp/jypkg/ent/entity"
-	. "app.yhyue.com/moapp/jypkg/ent/util"
 	"github.com/dchest/captcha"
 	"go.mongodb.org/mongo-driver/bson"
 )
@@ -25,15 +25,28 @@ type Action struct {
 	sendIdentCode xweb.Mapper `xweb:"/phone/sendIdentCode"` //发短信
 	replace       xweb.Mapper `xweb:"/phone/replace/(.*)"`  //手机号更改绑定
 }
+type CompletionUserInfo struct {
+	IsEnt      bool   `json:"isEnt"`
+	PersonName string `json:"personName"`
+	EntName    string `json:"entName"`
+	Phone      string `json:"phone"`
+	Mail       string `json:"mail"`
+	EntId      int    `json:"entId"`
+}
+type Resp struct {
+	Fool           bool  `json:"fool"`
+	EntPositionId  int64 `json:"entPositionId"`
+	UserPositionId int64 `json:"userpositionId"`
+}
 
-//已绑定的手机号
+// 已绑定的手机号
 func (a *Action) Bound() {
 	userId, _ := a.GetSession("mgoUserId").(string)
 	phone, _ := VarCurrentUser.Phone(userId)
 	a.ServeJson(Result{Data: M{"phone": phone}})
 }
 
-//手机号绑定
+// 手机号绑定
 func (a *Action) Bind() {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "code") {
 		return
@@ -73,7 +86,7 @@ func (a *Action) Bind() {
 	a.ServeJson(Result{Data: M{"status": status, "phone": phone, "myents": myents}})
 }
 
-//发短信
+// 发短信
 func (a *Action) SendIdentCode() {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "token") {
 		return
@@ -98,8 +111,9 @@ func (a *Action) SendIdentCode() {
 	a.ServeJson(Result{Data: M{"status": status}})
 }
 
-//更换/验证手机号  operation: --admin 管理员更换 --me 个人更换手机号
-//			step: --1 验证手机号  --2 更换手机号
+// 更换/验证手机号  operation: --admin 管理员更换 --me 个人更换手机号
+//
+//	step: --1 验证手机号  --2 更换手机号
 func (a *Action) Replace(operation string) {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "phone", "step", "identCode") {
 		return
@@ -209,6 +223,23 @@ func (a *Action) Replace(operation string) {
 				if update_status {
 					status = 1
 				}
+				//新管理员新增职位信息
+				//自然人 账号 职位添加
+				data := CompletionUserInfo{
+					IsEnt:      false,
+					PersonName: "",
+					Phone:      newphone,
+					EntId:      ent_id,
+					Mail:       "",
+				}
+				respData := Resp{
+					Fool: false,
+				}
+				r, err := rpc.DialHTTP("tcp", config.Config.PaymentAddress)
+				err = r.Call("JyUser.AddUserInfo", &data, &respData)
+				if err != nil {
+					log.Println("JyUser.AddUserInfo: ", err)
+				}
 			} else if operation == "me" { //个人
 				replace_status, _ := VarCurrentUser.ReplacePhone(userId, newphone, ent_id)
 				if replace_status == -1 {