WH01243 1 рік тому
батько
коміт
b71e73ae2d

+ 2 - 2
api/bicenter.api

@@ -14,8 +14,8 @@ type (
 		Type  string `json:"type"`
 	}
 	MyInfoReq {
-		Bid string `json:"bid "`
-		Sid string `json:"sid "`
+		Bid string `json:"bid,optional"`
+		Sid string `json:"sid"`
 	}
 )
 service biCenter {

+ 2 - 1
api/etc/bicenter.yaml

@@ -4,4 +4,5 @@ Port: 8888
 Gateway:
   ServerCode: biCenter
   Etcd:
-    - 127.0.0.1:2379
+    - 127.0.0.1:2379
+PublicKey: "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClE2QwCrAl+FQjqwGTXQ6Lf2nf\nc1Mt0M6jGAPkHz6NFZpoIPno2TMrWglQobS9UVjqp+xeuo3/O8PedHCE71Iy6BBE\nOI9yfeho2On67JZnrdEZtrEjD10fxrLAPvmcEWczU5Xfe9WCB5LDZtsiJOB8L0UY\nLrocaMa3sjTZCGHidQIDAQAB\n-----END PUBLIC KEY-----"

+ 2 - 2
api/etc/db.yaml

@@ -1,6 +1,6 @@
 redis:
     addr:
-        - msgCount=127.0.0.1:6379
+        - session=192.168.3.149:1713
 mongo:
     bidding:
         address: 192.168.3.206:27002
@@ -32,4 +32,4 @@ mysql:
         userName: root
         passWord: =PDT49#80Z!RVv52_z
         maxOpenConns: 5
-        maxIdleConns: 5
+        maxIdleConns: 5

+ 1 - 0
api/internal/config/config.go

@@ -11,6 +11,7 @@ type Config struct {
 		ServerCode string
 		Etcd       []string
 	}
+	PublicKey string
 }
 
 type Db struct {

+ 4 - 1
api/internal/logic/myinfologic.go

@@ -1,6 +1,7 @@
 package logic
 
 import (
+	"bp.jydev.jianyu360.cn/BaseService/biCenter/api/internal/service"
 	"context"
 
 	"bp.jydev.jianyu360.cn/BaseService/biCenter/api/internal/svc"
@@ -25,6 +26,8 @@ func NewMyinfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MyinfoLogi
 
 func (l *MyinfoLogic) Myinfo(req *types.MyInfoReq) (resp *types.Reply, err error) {
 	// todo: add your logic here and delete this line
-
+	resp = &types.Reply{}
+	infoService := &service.InfoService{}
+	resp.Data = infoService.Myinfo(req.Sid)
 	return
 }

+ 57 - 0
api/internal/service/infoService.go

@@ -0,0 +1,57 @@
+package service
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/redis"
+	IC "bp.jydev.jianyu360.cn/BaseService/biCenter/api/common"
+	"crypto/rand"
+	"crypto/rsa"
+	"crypto/x509"
+	"encoding/base64"
+	"encoding/pem"
+	"net/url"
+)
+
+type InfoService struct {
+}
+
+func (l *InfoService) Myinfo(sid string) map[string]interface{} {
+	infoMap := map[string]interface{}{}
+	info_i := redis.Get("session", sid)
+	if info_i != nil {
+		info_m, _ := info_i.(map[string]interface{})
+		infoMap = map[string]interface{}{
+			"nickName":     RsaEncrypt([]byte(common.InterfaceToStr(info_m["s_nickname"]))),
+			"entRole":      RsaEncrypt([]byte(common.InterfaceToStr(info_m["entRole"]))),
+			"entNicheDis":  RsaEncrypt([]byte(common.InterfaceToStr(info_m["entNicheDis"]))),
+			"positionId":   RsaEncrypt([]byte(common.InterfaceToStr(info_m["positionId"]))),
+			"accountId":    RsaEncrypt([]byte(common.InterfaceToStr(info_m["s_nickname"]))),
+			"entAccountId": RsaEncrypt([]byte(common.InterfaceToStr(info_m["s_nickname"]))),
+			"entId":        RsaEncrypt([]byte(common.InterfaceToStr(info_m["entId"]))),
+			"entName":      RsaEncrypt([]byte(common.InterfaceToStr(info_m["entName"]))),
+			"entUserName":  RsaEncrypt([]byte(common.InterfaceToStr(info_m["entUserName"]))),
+			"entUserId":    RsaEncrypt([]byte(common.InterfaceToStr(info_m["entUserId"]))),
+		}
+	}
+	return infoMap
+}
+
+// 加密
+func RsaEncrypt(origData []byte) string {
+	//解密pem格式的公钥
+	block, _ := pem.Decode([]byte(IC.C.PublicKey))
+	if block == nil {
+		return ""
+	}
+	// 解析公钥
+	pubInterface, err := x509.ParsePKIXPublicKey(block.Bytes)
+	if err != nil {
+		return ""
+	}
+	// 类型断言
+	pub := pubInterface.(*rsa.PublicKey)
+	//加密
+	data, _ := rsa.EncryptPKCS1v15(rand.Reader, pub, origData)
+	v1 := url.QueryEscape(base64.StdEncoding.EncodeToString(data))
+	return v1
+}

+ 6 - 0
api/internal/service/sqlService.go

@@ -2,6 +2,7 @@ package service
 
 import (
 	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
 	elastic "app.yhyue.com/moapp/jybase/es"
 	MC "bp.jydev.jianyu360.cn/BaseService/biCenter/api/common"
 	"bp.jydev.jianyu360.cn/BaseService/biCenter/api/internal/types"
@@ -24,6 +25,11 @@ func (l SqlService) SqlManage(in *types.SqlManageReq) *[]map[string]interface{}
 	case "es":
 		rs = elastic.Get(common.InterfaceToStr((*sqlData)["db_name"]), common.InterfaceToStr((*sqlData)["db_name"]), Sqlformat(common.InterfaceToStr((*sqlData)["content"]), *in))
 	}
+
+	for k, v := range *rs {
+		(*rs)[k]["id"] = encrypt.EncodeArticleId2ByCheck(common.InterfaceToStr(v["id"]))
+		delete((*rs)[k], "_id")
+	}
 	return rs
 }
 func Sqlformat(sqlStr string, sqlData types.SqlManageReq) string {