소스 검색

feat:测试用例覆盖率提升

wangshan 3 년 전
부모
커밋
8ac22592f2
13개의 변경된 파일1370개의 추가작업 그리고 144개의 파일을 삭제
  1. 25 0
      Makefile
  2. BIN
      api/api.exe
  3. 1 1
      entity/user.go
  4. BIN
      rpc/rpc.exe
  5. 0 56
      rpc/test/user_test.go
  6. 0 17
      service/auxiliaryTest.go
  7. 58 0
      service/auxiliary_test.go
  8. 818 0
      service/coverage.html
  9. 33 35
      service/ent_test.go
  10. 157 0
      service/test_cover.out
  11. 42 0
      service/user_test.go
  12. 1 1
      service/workDesktop.go
  13. 235 34
      service/workDesktop_test.go

+ 25 - 0
Makefile

@@ -0,0 +1,25 @@
+SHELL=cmd
+.PHONY: all
+all:  fmt tidy lint
+genRpc:
+	cd rpc &&  goctl rpc protoc userCenter.proto --go_out=. --go-grpc_out=. --zrpc_out=.
+	@echo "===========> genRpc finish"
+
+genApi:
+	cd api/ && goctl api go -api userCenter.api -dir .
+	@echo "===========> genApi finish"
+
+fmt:
+	go fmt ./...
+	@echo "===========> fmt finish"
+tidy:
+	go mod tidy
+	@echo "===========> tidy finish"
+
+lint:
+	@echo "===========> Run golangci to lint source codes"
+	@golangci-lint run
+
+cover:
+	@echo "===========> Run go test "
+	cd service/ &&  go test -v -covermode=set -coverprofile=test_cover.out && go tool cover -html=test_cover.out -o coverage.html

BIN
api/api.exe


+ 1 - 1
entity/user.go

@@ -12,7 +12,7 @@ const (
 	IsNewFreeTimeCell       = 1637830020
 	BigMemberUserPowerTable = "bigmember_service_user"
 	RedisCode               = "newother"
-	RedisMenuKey            = "jy_workdesktopmenu_%s_%s"
+	RedisMenuKey            = "jy_workdesktopmenu_%s_%s_%s"
 	UserPowerRedisKey       = "jy_userpowerredis_%s_%d_%s"
 )
 

BIN
rpc/rpc.exe


+ 0 - 56
rpc/test/user_test.go

@@ -1,56 +0,0 @@
-package test
-
-import (
-	"context"
-	"log"
-	"testing"
-	"time"
-
-	"github.com/zeromicro/go-zero/zrpc"
-	"userCenter/rpc/pb"
-	usercenterclient "userCenter/rpc/usercenter"
-)
-
-// go test -v -run Test_UserAdd
-func Test_UserAdd(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
-	req := &pb.UserAddReq{
-		Appid:    "10000",
-		Phone:    "18530014520",
-		Nickname: "xx",
-		Company:  "郑州森曼木材有限公司",
-	}
-	res, err := FileSystem.UserAdd(ctx, req)
-	log.Println("err ", err)
-	log.Println("res:", res)
-}
-
-// go test -v -run Test_UserUpdate
-func Test_UserUpdate(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
-	req := &pb.UserIdReq{
-		Id:       int64(4),
-		Appid:    "10000",
-		Phone:    "18530014520",
-		Nickname: "小徐的公司",
-		Company:  "郑州森曼木材有限公司",
-	}
-	res, err := FileSystem.UserUpdate(ctx, req)
-	log.Println("err ", err)
-	log.Println("res:", res)
-}
-
-// go test -v -run Test_UserDel
-func Test_UserDel(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
-	req := &pb.UserIdReq{
-		Id:    int64(4),
-		Appid: "10000",
-	}
-	res, err := FileSystem.UserDel(ctx, req)
-	log.Println("err ", err)
-	log.Println("res:", res)
-}

+ 0 - 17
service/auxiliaryTest.go

@@ -1,17 +0,0 @@
-package service
-
-import (
-	"github.com/zeromicro/go-zero/core/discov"
-	"github.com/zeromicro/go-zero/zrpc"
-	usercenterclient "userCenter/rpc/usercenter"
-)
-
-func AutoInit() usercenterclient.UserCenter {
-	FileSystemConf := zrpc.MustNewClient(zrpc.RpcClientConf{
-		Etcd: discov.EtcdConf{
-			Hosts: []string{"127.0.0.1:2379"},
-			Key:   "usercenter.rpc",
-		},
-	})
-	return usercenterclient.NewUserCenter(FileSystemConf)
-}

+ 58 - 0
service/auxiliary_test.go

@@ -0,0 +1,58 @@
+package service
+
+import (
+	"app.yhyue.com/moapp/jybase/mongodb"
+	"app.yhyue.com/moapp/jybase/mysql"
+	"app.yhyue.com/moapp/jybase/redis"
+	"github.com/zeromicro/go-zero/core/discov"
+	"github.com/zeromicro/go-zero/zrpc"
+	"log"
+	"strings"
+	"userCenter/entity"
+	usercenterclient "userCenter/rpc/usercenter"
+)
+
+func AutoInit() usercenterclient.UserCenter {
+	FileSystemConf := zrpc.MustNewClient(zrpc.RpcClientConf{
+		Etcd: discov.EtcdConf{
+			Hosts: []string{"127.0.0.1:2379"},
+			Key:   "usercenter.rpc",
+		},
+	})
+	return usercenterclient.NewUserCenter(FileSystemConf)
+}
+
+func init() {
+	entity.Mysql = &mysql.Mysql{
+		Address:      "192.168.3.11:3366",
+		UserName:     "root",
+		PassWord:     "Topnet123",
+		DBName:       "jianyu",
+		MaxOpenConns: 5,
+		MaxIdleConns: 5,
+	}
+	log.Println("初始化  mysql")
+	entity.Mysql.Init()
+	entity.BaseMysql = &mysql.Mysql{
+		Address:      "192.168.3.217:4000",
+		UserName:     "root",
+		PassWord:     "=PDT49#80Z!RVv52_z",
+		DBName:       "base_service",
+		MaxOpenConns: 5,
+		MaxIdleConns: 5,
+	}
+	entity.BaseMysql.Init()
+	log.Println("初始化 base mysql")
+
+	log.Println("初始化 redis")
+	redis.InitRedisBySize(strings.Join([]string{"newother=192.168.3.206:1712"}, ","), 100, 30, 300)
+
+	//初始化 mongodb
+	log.Println("初始化 mongo main")
+	entity.Mgo = mongodb.MongodbSim{
+		MongodbAddr: "192.168.3.206:27080",
+		Size:        50,
+		DbName:      "qfw",
+	}
+	entity.Mgo.InitPool()
+}

+ 818 - 0
service/coverage.html

@@ -0,0 +1,818 @@
+
+<!DOCTYPE html>
+<html>
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+		<title>service: Go Coverage Report</title>
+		<style>
+			body {
+				background: black;
+				color: rgb(80, 80, 80);
+			}
+			body, pre, #legend span {
+				font-family: Menlo, monospace;
+				font-weight: bold;
+			}
+			#topbar {
+				background: black;
+				position: fixed;
+				top: 0; left: 0; right: 0;
+				height: 42px;
+				border-bottom: 1px solid rgb(80, 80, 80);
+			}
+			#content {
+				margin-top: 50px;
+			}
+			#nav, #legend {
+				float: left;
+				margin-left: 10px;
+			}
+			#legend {
+				margin-top: 12px;
+			}
+			#nav {
+				margin-top: 10px;
+			}
+			#legend span {
+				margin: 0 5px;
+			}
+			.cov0 { color: rgb(192, 0, 0) }
+.cov1 { color: rgb(128, 128, 128) }
+.cov2 { color: rgb(116, 140, 131) }
+.cov3 { color: rgb(104, 152, 134) }
+.cov4 { color: rgb(92, 164, 137) }
+.cov5 { color: rgb(80, 176, 140) }
+.cov6 { color: rgb(68, 188, 143) }
+.cov7 { color: rgb(56, 200, 146) }
+.cov8 { color: rgb(44, 212, 149) }
+.cov9 { color: rgb(32, 224, 152) }
+.cov10 { color: rgb(20, 236, 155) }
+
+		</style>
+	</head>
+	<body>
+		<div id="topbar">
+			<div id="nav">
+				<select id="files">
+				
+				<option value="file0">userCenter/service/entService.go (0.0%)</option>
+				
+				<option value="file1">userCenter/service/user.go (70.8%)</option>
+				
+				<option value="file2">userCenter/service/workDesktop.go (87.5%)</option>
+				
+				</select>
+			</div>
+			<div id="legend">
+				<span>not tracked</span>
+			
+				<span class="cov0">not covered</span>
+				<span class="cov8">covered</span>
+			
+			</div>
+		</div>
+		<div id="content">
+		
+		<pre class="file" id="file0" style="display: none">package service
+
+import (
+        "fmt"
+        "strconv"
+        "time"
+
+        "app.yhyue.com/moapp/jybase/common"
+        "userCenter/entity"
+        userCenter "userCenter/rpc/usercenter"
+)
+
+type EntService struct {
+        Url string
+}
+
+//创建企业用户
+/*
+
+根据统一社会信用代码判断
+        查询是否已存在该企业
+                若无该企业
+                         创建新企业
+                存在该企业
+                         老企业更新
+*/
+
+const (
+        EXAMINEINGMSG = "该机构正在审核中,无法提交认证申请"
+        APPROVEDMSG   = "该机构已完成认证,无法提交认证申请"
+        OKMSG         = "提交成功"
+)
+
+//return error_code error_msg  status entid
+func (this *EntService) CreateEnt(data *userCenter.EntAuthReq) (int64, string, int64, int64) <span class="cov0" title="0">{
+        if data.Name == "" || data.Phone == "" || data.CreditCode == "" </span><span class="cov0" title="0">{
+                return entity.ErrorCode, "参数异常", entity.ErrorCode, 0
+        }</span>
+        <span class="cov0" title="0">authType, _ := strconv.Atoi(data.ComPanyType)
+        entinfo := &amp;entity.EntInfo{
+                Name:              data.Name,       //企业名称
+                Phone:             data.Phone,      //注册人手机号
+                Code:              data.CreditCode, //统一社会信用代码
+                Createtime:        time.Now().Format("2006-01-02 15:04:05"),
+                Organization_type: data.OrganizationType, //机构类型  1投标企业  2招标采购单位 3厂商 4招标代理机构 5经销商  6服务提供商  7其他
+                Auth_type:         authType,              // 认证类型 1-事业单位 0-企业
+                License:           data.Business,         //营业执照
+                Official_letter:   data.OfficialLetter,   //认证公函
+                Linkman_phone:     data.AuthPhone,        //联系人手机号
+                Linkman_name:      data.AuthName,         //联系人姓名
+                AreaNumber:        data.AreaNumber,       //
+                Frozen_status:     1,
+                Auth_status:       0,
+                Audit_status:      1,
+                Mysql:             entity.Mysql,
+        }
+        //存在统一社会信用代码
+        r := entity.Mysql.SelectBySql(`select id,audit_status,auth_status,name,phone from entniche_info where code =?`, data.CreditCode)
+
+        if r != nil &amp;&amp; len(*r) &gt; 0 </span><span class="cov0" title="0">{
+                //记录所有的统一社会信用代码相同的企业
+                sameCode := map[int64]interface{}{}
+                for _, v := range *r </span><span class="cov0" title="0">{
+                        id, _ := v["id"].(int64)
+                        audit_status, _ := v["audit_status"].(int64)
+                        auth_status, _ := v["auth_status"].(int64)
+                        ent_name, _ := v["name"].(string)
+                        // phone, _ := v["phone"].(string)
+                        if audit_status == 1 </span><span class="cov0" title="0">{ //根据统一社会信用代码查看该企业正在审核中
+                                return entity.ErrorCode, EXAMINEINGMSG, entity.ErrorCode, 0
+                        }</span>
+                        <span class="cov0" title="0">if auth_status == 1 </span><span class="cov0" title="0">{
+                                sameCode[id] = map[string]interface{}{
+                                        "name":        ent_name,
+                                        "authStatus":  auth_status,
+                                        "auditStatus": audit_status,
+                                }
+                        }</span>
+                }
+                <span class="cov0" title="0">if len(sameCode) &gt; 0 </span><span class="cov0" title="0">{
+                        entids := ""
+                        i := 0
+                        for k, _ := range sameCode </span><span class="cov0" title="0">{
+                                //判断企业是否已认证
+                                entids += fmt.Sprint(k)
+                                if i != len(sameCode)-1 </span><span class="cov0" title="0">{
+                                        entids += ","
+                                }</span>
+                                <span class="cov0" title="0">i++</span>
+                        }
+                        //查看该用户是否在已认证的企业机构下,如果在机构下则可以重新发起认证(编辑)如果不在则提示已被认证
+                        <span class="cov0" title="0">list := entity.Mysql.SelectBySql(`
+                                                SELECT a.ent_id,b.name FROM entniche_user a inner join  entniche_info b  
+                                                on a.ent_id = b.id WHERE  a.ent_id IN(?) AND a.phone = ?`, entids, entinfo.Phone)
+                        if len(*list) &lt;= 0 </span><span class="cov0" title="0">{
+                                return entity.ErrorCode, APPROVEDMSG, entity.ErrorCode, 0
+                        }</span>
+                        //log.Println(fmt.Printf("查询到该统一社会信用代码存在%v个认证企业中,默认获取第一个企业进行认证,该企业企业id为%v", len(*list), (*list)[0]["ent_id"]))
+                        <span class="cov0" title="0">entinfo.Id = common.IntAll((*list)[0]["ent_id"])
+                        if entinfo.Update() </span><span class="cov0" title="0">{
+                                return entity.SuccessCode, OKMSG, 1, int64(entinfo.Id)
+                        }</span>
+                }
+        }
+        //不存在统一社会信用代码
+        <span class="cov0" title="0">r = entity.Mysql.SelectBySql(`select id,audit_status,auth_status,name,phone from entniche_info where id =?`, data.EntId)
+        if r != nil &amp;&amp; len(*r) &gt; 0 </span><span class="cov0" title="0">{
+                for _, v := range *r </span><span class="cov0" title="0">{
+                        id, _ := v["id"].(int64)
+                        audit_status, _ := v["audit_status"].(int64)
+                        auth_status, _ := v["auth_status"].(int64)
+                        ent_name, _ := v["name"].(string)
+                        // phone, _ := v["phone"].(string)
+                        //该企业下员工 可以重新认证
+                        if ent_name != entinfo.Name </span><span class="cov0" title="0">{ //企业名称不同 创建全新企业
+                                if ok, entid := entinfo.Add(); ok </span><span class="cov0" title="0">{
+                                        return entity.SuccessCode, OKMSG, 1, entid
+                                }</span>
+                        }
+                        <span class="cov0" title="0">if audit_status == 1 </span><span class="cov0" title="0">{ //审核中
+                                return entity.ErrorCode, EXAMINEINGMSG, entity.ErrorCode, 0
+                        }</span>
+                        <span class="cov0" title="0">if auth_status == 1 </span><span class="cov0" title="0">{ //已认证
+                                list := entity.Mysql.SelectBySql(`select * from entniche_user where ent_id =? and phone =?`, id, entinfo.Phone)
+                                if len(*list) &lt;= 0 </span><span class="cov0" title="0">{
+                                        return entity.ErrorCode, APPROVEDMSG, entity.ErrorCode, 0
+                                }</span>
+
+                        }
+                        <span class="cov0" title="0">entinfo.Id = int(id)
+                        // entinfo.Phone = phone //更换注册人手机号为管理员手机号
+                        if entinfo.Update() </span><span class="cov0" title="0">{
+                                return entity.SuccessCode, OKMSG, 1, int64(entinfo.Id)
+                        }</span>
+                }
+        }
+        <span class="cov0" title="0">if ok, id := entinfo.Add(); ok </span><span class="cov0" title="0">{
+                return entity.SuccessCode, OKMSG, 1, id
+        }</span>
+        <span class="cov0" title="0">return entity.ErrorCode, "", entity.ErrorCode, 0</span>
+}
+
+//机构审核
+func (this *EntService) Examinet(data *userCenter.ExamineReq) (int64, string, int64) <span class="cov0" title="0">{
+        if data.EntId == 0 || data.ExamineId == "" </span><span class="cov0" title="0">{
+                return -1, "参数异常", 0
+        }</span>
+        <span class="cov0" title="0">info := &amp;entity.Examine{
+                ExamineId:   data.ExamineId,
+                EntId:       data.EntId,
+                Reason:      data.Reason,
+                AuthType:    data.AuthType,
+                AuditUser:   data.AuditUser,
+                Mysql:       entity.Mysql,
+                ResourceLib: entity.ResourceLib,
+        }
+        if info.EntExamine() </span><span class="cov0" title="0">{
+                return 1, "", 0
+        }</span>
+        //修改状态
+        <span class="cov0" title="0">return -1, "修改失败", -1</span>
+}
+
+//企业列表
+func (this *EntService) EntList(data *userCenter.EntListReq) (int64, string, *userCenter.EntData) <span class="cov0" title="0">{
+        info := &amp;entity.List{
+                Name:            data.Name,
+                AuthStatus:      data.AuthStatus,
+                PageNum:         data.PageNum,
+                PageSize:        data.PageSize,
+                CreditCode:      data.CreditCode,
+                CreateStartTime: data.CreateStartTime,
+                CreateEndTime:   data.CreateEndTime,
+                ValidStartTime:  data.ValidStartTime,
+                ValidEndTime:    data.ValidEndTime,
+                FrozenStatus:    data.FrozenStatus,
+                RegPhone:        data.RegPhone,
+                AuthPhone:       data.AuthPhone,
+                Mysql:           entity.Mysql,
+        }
+        r, count := info.List()
+        pageSize := common.If(data.PageSize != "", data.PageSize, "10").(string)
+        i_pageSize, _ := strconv.Atoi(pageSize)
+        list := []*userCenter.EntList{}
+        for _, v := range *r </span><span class="cov0" title="0">{
+                list = append(list, &amp;userCenter.EntList{
+                        Id:               common.Int64All(v["id"]),                  //机构id
+                        ComPanyType:      common.Int64All(v["comPanyType"]),         // 机构性质    1企业   2党政机关事业单位及其他
+                        Name:             common.ObjToString(v["name"]),             //机构名称
+                        OrganizationType: common.ObjToString(v["organizationType"]), //机构类型  1企业   2党政机关事业单位及其他
+                        Createtime:       common.ObjToString(v["createTime"]),       //创建时间
+                        ValidTime:        common.ObjToString(v["validTime"]),        //有效截至日期
+                        AuthStatus:       common.Int64All(v["authStatus"]),          //认证状态
+                        FrozenStatus:     common.Int64All(v["frozenStatus"]),
+                })
+        }</span>
+        <span class="cov0" title="0">return 0, "", &amp;userCenter.EntData{
+                Count:    count,
+                PageSize: int64(i_pageSize),
+                List:     list,
+        }</span>
+}
+
+//审核列表
+func (this *EntService) ExamineList(data *userCenter.ExamineListReq) (int64, string, *userCenter.ExamineListData) <span class="cov0" title="0">{
+        info := &amp;entity.ExamineList{
+                Name:          data.Name,
+                AuthPhone:     data.AuthPhone,
+                RegPhone:      data.RegPhone,
+                AuthType:      data.AuthType,      //审核状态 1:待审核  2:审核通过 3:审核不通过
+                AuthStartTime: data.AuthStartTime, //申请开始时间
+                AuthEndTime:   data.AuthEndTime,   //申请结束时间
+                PageNum:       data.PageNum,       //页码
+                PageSize:      data.PageSize,      //每页展示条数
+                Mysql:         entity.Mysql,
+        }
+        r, count := info.List()
+        pageSize := common.If(data.PageSize != "", data.PageSize, "10").(string)
+        i_pageSize, _ := strconv.Atoi(pageSize)
+        list := []*userCenter.ExamineList{}
+        for _, v := range *r </span><span class="cov0" title="0">{
+                list = append(list, &amp;userCenter.ExamineList{
+                        Id:          common.Int64All(v["id"]),
+                        EntId:       common.Int64All(v["entId"]),
+                        ComPanyType: common.Int64All(v["comPanyType"]),   // 机构性质    1企业   2党政机关事业单位及其他
+                        Name:        common.ObjToString(v["name"]),       //机构名称
+                        CreditCode:  common.ObjToString(v["creditCode"]), //统一社会信用代码
+                        AuthPhone:   common.ObjToString(v["authPhone"]),  //联系人手机号
+                        ApplyTime:   common.ObjToString(v["authTime"]),   //申请时间戳
+                        AuthType:    common.Int64All(v["authStatus"]),    //审核状态
+                        RegPhone:    common.ObjToString(v["regPhone"]),
+                })
+        }</span>
+        <span class="cov0" title="0">return 0, "", &amp;userCenter.ExamineListData{
+                Count:    count,
+                PageSize: int64(i_pageSize),
+                List:     list,
+        }</span>
+}
+
+func (this *EntService) CheckEnt(data *userCenter.CheckEntReq) (int64, int64, string, int64) <span class="cov0" title="0">{
+        info := &amp;entity.CheckEnt{
+                EntId: data.EntId,
+                Mysql: entity.Mysql,
+        }
+        authStatus, frozenStatus, msg := info.Check()
+        return authStatus, frozenStatus, msg, common.Int64All(common.If(msg == "", entity.SuccessCode, entity.ErrorCode))
+}</span>
+
+//企业信息
+func (this *EntService) Info(data *userCenter.CheckEntReq) (int64, string, *userCenter.EntInfoData) <span class="cov0" title="0">{
+        info := &amp;entity.CheckEnt{
+                EntId: data.EntId,
+                Mysql: entity.Mysql,
+                Url:   this.Url,
+        }
+        rdata := info.Info()
+        entInfoData := &amp;userCenter.EntInfoData{
+                Name:             rdata.Name,
+                OrganizationType: rdata.OrganizationType,
+                CreditCode:       rdata.CreditCode,
+                CompanyType:      rdata.CompanyType,
+                AreaNumber:       rdata.AreaNumber,
+                Business:         rdata.Business,
+                OfficialLetter:   rdata.OfficialLetter,
+                AuthStartTime:    rdata.AuthStartTime,
+                AuthEndTime:      rdata.AuthEndTime,
+                ForzenStatus:     rdata.ForzenStatus,
+                AuthState:        rdata.AuthState,
+                ContactPerson:    rdata.ContactPerson,
+                ContactPhone:     rdata.ContactPhone,
+                AuthType:         rdata.AuthType,
+                CreateTime:       rdata.CreateTime,
+                AuthReason:       rdata.AuthReason,
+        }
+        return 0, "", entInfoData
+}</span>
+
+func (this *EntService) UpdateEnt(data *userCenter.EntUpdateReq) (int64, string, int64) <span class="cov0" title="0">{
+        info := &amp;entity.UpdateEnt{
+                EntId:       data.EntId,
+                UpdateType:  data.UpdateType,
+                Mysql:       entity.Mysql,
+                ResourceLib: entity.ResourceLib,
+        }
+        status, msg := info.UpdateEnt()
+        return 0, msg, status
+}</span>
+
+func (this *EntService) ExamineInfo(data *userCenter.CheckExamineReq) (int64, string, *userCenter.EntInfoData) <span class="cov0" title="0">{
+        info := &amp;entity.ExamineInfo{
+                ExamineId: data.ExamineId,
+                Mysql:     entity.Mysql,
+        }
+        rdata := info.Info()
+        entInfoData := &amp;userCenter.EntInfoData{
+                Name:             rdata.Name,
+                OrganizationType: rdata.OrganizationType,
+                CreditCode:       rdata.CreditCode,
+                CompanyType:      rdata.CompanyType,
+                AreaNumber:       rdata.AreaNumber,
+                Business:         rdata.Business,
+                OfficialLetter:   rdata.OfficialLetter,
+                AuthState:        rdata.AuthState,
+                ContactPerson:    rdata.ContactPerson,
+                ContactPhone:     rdata.ContactPhone,
+                RegPhone:         rdata.RegPhone,
+                AuthTime:         rdata.AuthTime,
+                AuthReason:       rdata.AuthReason,
+                AuditUser:        rdata.AuditUser,
+                AuditTime:        rdata.AuditTime,
+        }
+        return 0, "", entInfoData
+}</span>
+
+func (this *EntService) GetStatusByCode(data *userCenter.GetStatusByCodeReq) (int, bool, string) <span class="cov0" title="0">{
+        info := &amp;entity.GetStatusByCodeStruct{
+                Mysql: entity.Mysql,
+                Code:  data.Code,
+                Phone: data.Phone,
+        }
+        return info.GetStatusByCode()
+}</span>
+</pre>
+		
+		<pre class="file" id="file1" style="display: none">package service
+
+import (
+        "database/sql"
+        "time"
+
+        "userCenter/entity"
+        . "userCenter/rpc/usercenter"
+)
+
+func UserAdd(this *UserAddReq) *UserAddResp <span class="cov8" title="1">{
+        userId := entity.BaseMysql.Insert(entity.UserTable, map[string]interface{}{
+                "appid":       this.Appid,
+                "phone":       this.Phone,
+                "nickname":    this.Nickname,
+                "headimg":     this.Headimg,
+                "company":     this.Company,
+                "position":    this.Position,
+                "password":    this.Password,
+                "s_openid":    this.SOpenid,
+                "a_openid":    this.AOpenid,
+                "unionid":     this.Unionid,
+                "create_time": time.Now().Format("2006-01-02 15:04:05"),
+        })
+        status, msg := 0, ""
+        if userId &gt; 0 </span><span class="cov8" title="1">{
+                status = 1
+        }</span> else<span class="cov0" title="0"> {
+                msg = "新增用户失败"
+        }</span>
+        <span class="cov8" title="1">return &amp;UserAddResp{
+                ErrorCode: entity.SuccessCode,
+                ErrorMsg:  msg,
+                Data:      &amp;UserAdds{Status: int64(status), Id: userId},
+        }</span>
+}
+
+func UserUpdate(this *UserIdReq) *ExamineResp <span class="cov8" title="1">{
+        ok := UserUpdates(this)
+        status, msg := 0, ""
+        if ok </span><span class="cov8" title="1">{
+                status = 1
+        }</span> else<span class="cov0" title="0"> {
+                msg = "更新用户失败"
+        }</span>
+        <span class="cov8" title="1">return &amp;ExamineResp{
+                ErrorCode: entity.SuccessCode,
+                ErrorMsg:  msg,
+                Data:      &amp;ExamineData{Status: int64(status)},
+        }</span>
+}
+
+func UserDel(this *UserIdReq) *ExamineResp <span class="cov8" title="1">{
+        ok := UserDels(this)
+        status, msg := 0, ""
+        if ok </span><span class="cov0" title="0">{
+                status = 1
+        }</span> else<span class="cov8" title="1"> {
+                msg = "删除用户失败"
+        }</span>
+        <span class="cov8" title="1">return &amp;ExamineResp{
+                ErrorCode: entity.SuccessCode,
+                ErrorMsg:  msg,
+                Data:      &amp;ExamineData{Status: int64(status)},
+        }</span>
+}
+
+func UserUpdates(this *UserIdReq) bool <span class="cov8" title="1">{
+        ok := false
+        flag := entity.BaseMysql.ExecTx("", func(tx *sql.Tx) bool </span><span class="cov8" title="1">{
+                set := map[string]interface{}{}
+                if this.Phone != "" </span><span class="cov8" title="1">{
+                        set["phone"] = this.Phone
+                }</span> else<span class="cov0" title="0"> {
+                        set["phone"] = ""
+                }</span>
+                <span class="cov8" title="1">if this.Nickname != "" </span><span class="cov8" title="1">{
+                        set["nickname"] = this.Nickname
+                }</span> else<span class="cov0" title="0"> {
+                        set["nickname"] = ""
+                }</span>
+                <span class="cov8" title="1">if this.Headimg != "" </span><span class="cov0" title="0">{
+                        set["headimg"] = this.Headimg
+                }</span> else<span class="cov8" title="1"> {
+                        set["headimg"] = ""
+                }</span>
+                <span class="cov8" title="1">if this.Company != "" </span><span class="cov8" title="1">{
+                        set["company"] = this.Company
+                }</span> else<span class="cov0" title="0"> {
+                        set["company"] = ""
+                }</span>
+                <span class="cov8" title="1">if this.Position != "" </span><span class="cov0" title="0">{
+                        set["position"] = this.Position
+                }</span> else<span class="cov8" title="1"> {
+                        set["position"] = ""
+                }</span>
+                <span class="cov8" title="1">if this.Password != "" </span><span class="cov0" title="0">{
+                        set["password"] = this.Password
+                }</span> else<span class="cov8" title="1"> {
+                        set["password"] = ""
+                }</span>
+                <span class="cov8" title="1">if this.AOpenid != "" </span><span class="cov0" title="0">{
+                        set["a_openid"] = this.AOpenid
+                }</span> else<span class="cov8" title="1"> {
+                        set["a_openid"] = ""
+                }</span>
+                <span class="cov8" title="1">if this.SOpenid != "" </span><span class="cov0" title="0">{
+                        set["s_openid"] = this.SOpenid
+                }</span> else<span class="cov8" title="1"> {
+                        set["s_openid"] = ""
+                }</span>
+                <span class="cov8" title="1">if this.Unionid != "" </span><span class="cov0" title="0">{
+                        set["unionid"] = this.Unionid
+                }</span> else<span class="cov8" title="1"> {
+                        set["unionid"] = ""
+                }</span>
+                <span class="cov8" title="1">ok1 := entity.BaseMysql.UpdateByTx(tx, entity.UserTable, map[string]interface{}{"id": this.Id}, set)
+                snapshot := entity.BaseMysql.InsertByTx(tx, entity.UserSnapshotTable, map[string]interface{}{
+                        "appid":       this.Appid,
+                        "user_id":     this.Id,
+                        "phone":       this.Phone,
+                        "nickname":    this.Nickname,
+                        "headimg":     this.Headimg,
+                        "company":     this.Company,
+                        "position":    this.Position,
+                        "password":    this.Password,
+                        "s_openid":    this.SOpenid,
+                        "a_openid":    this.AOpenid,
+                        "unionid":     this.Unionid,
+                        "create_time": time.Now().Format("2006-01-02 15:04:05"),
+                })
+                return ok1 &amp;&amp; snapshot &gt; 0</span>
+        })
+        <span class="cov8" title="1">if flag </span><span class="cov8" title="1">{
+                ok = true
+        }</span>
+        <span class="cov8" title="1">return ok</span>
+}
+
+func UserDels(this *UserIdReq) bool <span class="cov8" title="1">{
+        ok := false
+        userData := entity.BaseMysql.FindOne(entity.UserTable, map[string]interface{}{"id": this.Id}, "", "")
+        if userData != nil &amp;&amp; len(*userData) &gt; 0 </span><span class="cov0" title="0">{
+                flag := entity.BaseMysql.ExecTx("", func(tx *sql.Tx) bool </span><span class="cov0" title="0">{
+                        thisdata := *userData
+                        ok1 := entity.BaseMysql.DeleteByTx(tx, entity.UserTable, map[string]interface{}{"id": this.Id})
+                        snapshot := entity.BaseMysql.InsertByTx(tx, entity.UserSnapshotTable, map[string]interface{}{
+                                "appid":       thisdata["appid"],
+                                "user_id":     this.Id,
+                                "phone":       thisdata["phone"],
+                                "nickname":    thisdata["nickname"],
+                                "headimg":     thisdata["headimg"],
+                                "company":     thisdata["company"],
+                                "position":    thisdata["position"],
+                                "password":    thisdata["password"],
+                                "s_openid":    thisdata["s_openid"],
+                                "a_openid":    thisdata["a_openid"],
+                                "unionid":     thisdata["unionid"],
+                                "create_time": time.Now().Format("2006-01-02 15:04:05"),
+                        })
+                        return ok1 &amp;&amp; snapshot &gt; 0
+                }</span>)
+                <span class="cov0" title="0">if flag </span><span class="cov0" title="0">{
+                        ok = true
+                }</span>
+        }
+        <span class="cov8" title="1">return ok</span>
+}
+</pre>
+		
+		<pre class="file" id="file2" style="display: none">package service
+
+import (
+        MC "app.yhyue.com/moapp/jybase/common"
+        "app.yhyue.com/moapp/jybase/redis"
+        "encoding/json"
+        "errors"
+        "fmt"
+        "github.com/zeromicro/go-zero/core/logx"
+        "math/rand"
+        "strings"
+        "time"
+        "userCenter/entity"
+        "userCenter/rpc/pb"
+        . "userCenter/rpc/usercenter"
+)
+
+//工作桌面--菜单当前选择模式--全部:all/可用:usable
+//工作桌面--常用功能更新
+//工作桌面--常用功能列表
+func RenewWorkDesktopMenuModeOrCommonly(in *WorkDesktopComprehensiveReq) (r *WorkDesktopComprehensiveResp) <span class="cov8" title="1">{
+        r = &amp;WorkDesktopComprehensiveResp{}
+        switch in.ActionMode </span>{
+        case "commonlyRenew":<span class="cov8" title="1"> //常用功能更新
+                //in.MenuIds  为空;删除
+                if in.MenuIds == "" </span><span class="cov8" title="1">{
+                        count := entity.BaseMysql.CountBySql(`SELECT COUNT(id)  FROM `+entity.WorkCommonly+` WHERE userid = ? AND appid = ? AND platform = ? AND field = ?`, in.UserId, in.AppId, in.Platform, in.ActionMode)
+                        if count &gt; 0 </span><span class="cov8" title="1">{
+                                if count := entity.BaseMysql.UpdateOrDeleteBySql(`DELETE  FROM `+entity.WorkCommonly+` WHERE userid = ? AND appid = ? AND platform = ? AND field = ?`, in.UserId, in.AppId, in.Platform, in.ActionMode); count &lt;= 0 </span><span class="cov0" title="0">{
+                                        r.ErrorCode = -1
+                                        r.ErrorMsg = "常用功能-清空常用功能异常"
+                                }</span>
+                        }
+                } else<span class="cov8" title="1"> {
+                        //in.MenuIds 不为空:更新
+                        if b, m := entity.CommonlyUpdate(in); !b </span><span class="cov0" title="0">{
+                                r.ErrorCode = -1
+                                r.ErrorMsg = m
+                        }</span>
+                }
+        case "commonlyList":<span class="cov8" title="1">
+                //查询常用功能列表
+                in.ActionMode = "commonlyRenew"
+                existingData := entity.BaseMysql.SelectBySql(`SELECT value  FROM `+entity.WorkCommonly+` WHERE userid = ? AND appid = ? AND field = ? AND platform = ?  ORDER BY id DESC `, in.UserId, in.AppId, in.ActionMode, in.Platform)
+                if existingData != nil &amp;&amp; len(*existingData) &gt; 0 </span><span class="cov8" title="1">{
+                        eData := (*existingData)[0]
+                        if MC.ObjToString(eData["value"]) != "" </span><span class="cov8" title="1">{
+                                var (
+                                        params []string
+                                        pIds   []interface{}
+                                )
+                                for _, pv := range strings.Split(MC.ObjToString(eData["value"]), ",") </span><span class="cov8" title="1">{
+                                        params = append(params, "?")
+                                        pIds = append(pIds, pv)
+                                }</span>
+                                <span class="cov8" title="1">menuData := entity.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT * from %s WHERE  id IN (%s) AND status = 0`, entity.WorkMenu, strings.Join(params, ",")), pIds...)
+                                if menuData != nil &amp;&amp; len(*menuData) &gt; 0 </span><span class="cov8" title="1">{
+                                        var menuList = []*pb.ThreeLevelMenu{}
+                                        var m = &amp;entity.WorkDesktopMenu{
+                                                MenuTree:     nil,
+                                                UserId:       in.UserId,
+                                                AppId:        in.AppId,
+                                                TimeOut:      int(in.RedisOutTime),
+                                                BigMemberOff: in.BigMemberOff,
+                                        }
+                                        for _, mv := range *menuData </span><span class="cov8" title="1">{
+                                                //0:默认展示;1:需验证权限,有权限展示;2:需验证权限,无权限也可展示(可用服务无权限不展示)
+                                                usable := m.VerifyPermissions(MC.ObjToString(mv["powerids"]))
+                                                menu := &amp;pb.ThreeLevelMenu{
+                                                        Name:     MC.ObjToString(mv["name"]),
+                                                        Icon:     MC.ObjToString(mv["icon"]),
+                                                        AppType:  MC.ObjToString(mv["apptype"]),
+                                                        Usable:   MC.If(MC.ObjToString(mv["powerids"]) != "", usable &amp;&amp; MC.IntAll(mv["checkcode"]) == 1, true).(bool),
+                                                        OpenType: MC.ObjToString(mv["opentype"]),
+                                                }
+                                                switch in.Platform </span>{
+                                                case "WX":<span class="cov8" title="1">
+                                                        menu.Url = MC.ObjToString(mv["wxurl"])</span>
+                                                case "APP":<span class="cov8" title="1">
+                                                        menu.Url = MC.ObjToString(mv["appurl"])</span>
+                                                default:<span class="cov8" title="1">
+                                                        menu.Url = MC.ObjToString(mv["pcurl"])</span>
+                                                }
+                                                <span class="cov8" title="1">if additionalInfo := MC.ObjToString(mv["additionalinfo"]); additionalInfo != "" </span><span class="cov8" title="1">{
+                                                        additional := pb.TipInfo{}
+                                                        if json.Unmarshal([]byte(additionalInfo), &amp;additional) == nil </span><span class="cov8" title="1">{
+                                                                menu.TipInfo = &amp;additional
+                                                        }</span>
+                                                }
+                                                <span class="cov8" title="1">menuList = append(menuList, menu)</span>
+                                        }
+                                        <span class="cov8" title="1">r.Data = menuList</span>
+                                }
+                        }
+
+                }
+        case "menuMode":<span class="cov8" title="1"> //菜单模式更新
+                if in.MenuMode == "" || (in.MenuMode != "usable" &amp;&amp; in.MenuMode != "all") </span><span class="cov8" title="1">{
+                        r.ErrorCode = -1
+                        r.ErrorMsg = "菜单模式-参数异常"
+                }</span> else<span class="cov8" title="1"> {
+                        menuModes := entity.BaseMysql.SelectBySql(`SELECT id,value FROM `+entity.WorkCommonly+` WHERE appid=? AND userid=? AND field = ? AND platform = ? LIMIT 1`, in.AppId, in.UserId, in.ActionMode, in.Platform)
+                        if menuModes != nil &amp;&amp; len(*menuModes) &gt; 0 </span><span class="cov8" title="1">{
+                                menuMode := (*menuModes)[0]
+                                if MC.ObjToString(menuMode["value"]) != in.MenuMode </span><span class="cov8" title="1">{
+                                        if entity.BaseMysql.UpdateOrDeleteBySql(`UPDATE `+entity.WorkCommonly+` SET value = ? WHERE id = ?`, in.MenuMode, MC.IntAll(menuMode["id"])) &lt; 0 </span><span class="cov0" title="0">{
+                                                r.ErrorCode = -1
+                                                r.ErrorMsg = "菜单模式-更新异常"
+                                        }</span>
+                                }
+                        } else<span class="cov0" title="0"> {
+                                if entity.BaseMysql.Insert(entity.WorkCommonly, map[string]interface{}{
+                                        "appid":    in.AppId,
+                                        "userid":   in.UserId,
+                                        "field":    in.ActionMode,
+                                        "platform": in.Platform,
+                                        "value":    in.MenuMode,
+                                }) &lt; 0 </span><span class="cov0" title="0">{
+                                        r.ErrorCode = -1
+                                        r.ErrorMsg = "菜单模式-插入异常"
+                                }</span>
+                        }
+                }
+        }
+        <span class="cov8" title="1">return</span>
+}
+
+//
+func GetWorkDesktopMenuMode(in *WorkDesktopMenuInfoReq) (str string, err error) <span class="cov8" title="1">{
+        if in.UserId == "" </span><span class="cov8" title="1">{
+                return "", fmt.Errorf("参数异常")
+        }</span>
+        <span class="cov8" title="1">str = "all"
+        menuModes := entity.BaseMysql.SelectBySql(`SELECT value FROM `+entity.WorkCommonly+` WHERE appid=? AND userid=? AND field = 'menuMode' AND platform = ? LIMIT 1`, in.AppId, in.UserId, in.Platform)
+        if menuModes != nil &amp;&amp; len(*menuModes) &gt; 0 </span><span class="cov8" title="1">{
+                menuMode := (*menuModes)[0]
+                if MC.ObjToString(menuMode["value"]) != "" </span><span class="cov8" title="1">{
+                        str = MC.ObjToString(menuMode["value"])
+                }</span>
+        }
+        <span class="cov8" title="1">return</span>
+}
+
+//获取工作桌面菜单树
+func GetWordDesktopMenuTree(in *WorkDesktopMenuInfoReq) ([]*pb.MenuList, error) <span class="cov8" title="1">{
+        t1 := time.Now()
+        //redis缓存
+        var menuList []*pb.MenuList
+        RedisMenuKey := fmt.Sprintf(entity.RedisMenuKey, in.AppId, in.Platform, in.UserId)
+        menuBytes, err := redis.GetBytes(entity.RedisCode, RedisMenuKey)
+        if err == nil &amp;&amp; len(*menuBytes) &gt; 0 </span><span class="cov8" title="1">{
+                if json.Unmarshal(*menuBytes, &amp;menuList) == nil </span><span class="cov8" title="1">{
+                        return menuList, nil
+                }</span>
+        }
+        //tidb数据
+        <span class="cov8" title="1">menuData := entity.BaseMysql.SelectBySql(`SELECT * FROM `+entity.WorkMenu+` WHERE status=0 AND appid=? ORDER BY id ASC`, in.AppId)
+        if menuData == nil || len(*menuData) == 0 </span><span class="cov0" title="0">{
+                return nil, errors.New("查询数据异常")
+        }</span>
+        <span class="cov8" title="1">wdm := &amp;entity.WorkDesktopMenu{
+                MenuTree:     []*entity.JYMenu{},
+                UserId:       in.UserId,
+                AppId:        in.AppId,
+                TimeOut:      int(in.RedisOutTime),
+                BigMemberOff: in.BigMemberOff,
+        }
+        for _, v := range *menuData </span><span class="cov8" title="1">{
+                menu := &amp;entity.JYMenu{
+                        Id:        MC.IntAll(v["id"]),
+                        Name:      MC.ObjToString(v["name"]),
+                        OrderId:   MC.IntAll(v["orderid"]),
+                        ParentId:  MC.IntAll(v["parentid"]),
+                        PowerIds:  MC.ObjToString(v["powerids"]),
+                        CheckCode: MC.IntAll(v["checkcode"]),
+                        Icon:      MC.ObjToString(v["icon"]),
+                        AppType:   MC.ObjToString(v["apptype"]),
+                        OpenType:  MC.ObjToString(v["opentype"]),
+                }
+                switch in.Platform </span>{
+                case "WX":<span class="cov8" title="1">
+                        menu.Url = MC.ObjToString(v["wxurl"])</span>
+                case "APP":<span class="cov8" title="1">
+                        menu.Url = MC.ObjToString(v["appurl"])</span>
+                default:<span class="cov8" title="1">
+                        menu.Url = MC.ObjToString(v["pcurl"])</span>
+                }
+                <span class="cov8" title="1">if additionalInfo := MC.ObjToString(v["additionalinfo"]); additionalInfo != "" </span><span class="cov8" title="1">{
+                        additional := entity.Additional{}
+                        if json.Unmarshal([]byte(additionalInfo), &amp;additional) == nil </span><span class="cov8" title="1">{
+                                menu.AdditionalInfo = additional
+                        }</span>
+                }
+                <span class="cov8" title="1">if menu.Id &gt; 0 </span><span class="cov8" title="1">{
+                        wdm.MenuTree = append(wdm.MenuTree, menu)
+                }</span>
+        }
+        <span class="cov8" title="1">logx.Info("数据长度:", len(wdm.MenuTree), "-- 查询菜单数据耗时:", time.Since(t1))
+        //jyMenu := wdm.WorkMenuTree(0)
+        wdm.MenuTree = wdm.WorkMenuTree(0)
+        logx.Info("菜单树生成耗时:", time.Since(t1))
+        menuList, err = wdm.WorkMenuFormat()
+        logx.Info("菜单格式化耗时:", time.Since(t1))
+        if err == nil &amp;&amp; len(menuList) &gt; 0 </span><span class="cov8" title="1">{
+                if menuBytes, err := json.Marshal(menuList); err == nil </span><span class="cov8" title="1">{
+                        redisOutTime := int(in.RedisOutTime) + rand.Intn(60*60)
+                        if redis.PutBytes(entity.RedisCode, RedisMenuKey, &amp;menuBytes, redisOutTime) != nil </span><span class="cov0" title="0">{
+                                logx.Info("工作桌面菜单 redis缓存异常")
+                        }</span>
+                } else<span class="cov0" title="0"> {
+                        logx.Info("菜单数据序列化异常")
+                }</span>
+        }
+        <span class="cov8" title="1">logx.Info("整体耗时:", time.Since(t1))
+        return menuList, err</span>
+}
+</pre>
+		
+		</div>
+	</body>
+	<script>
+	(function() {
+		var files = document.getElementById('files');
+		var visible;
+		files.addEventListener('change', onChange, false);
+		function select(part) {
+			if (visible)
+				visible.style.display = 'none';
+			visible = document.getElementById(part);
+			if (!visible)
+				return;
+			files.value = part;
+			visible.style.display = 'block';
+			location.hash = part;
+		}
+		function onChange() {
+			select(files.value);
+			window.scrollTo(0, 0);
+		}
+		if (location.hash != "") {
+			select(location.hash.substr(1));
+		}
+		if (!visible) {
+			select("file0");
+		}
+	})();
+	</script>
+</html>

+ 33 - 35
rpc/test/ent_test.go → service/ent_test.go

@@ -1,40 +1,38 @@
-package test
+package service
 
 import (
 	"context"
+
 	// "flag"
 	"log"
 	"testing"
 	"time"
 
-	"userCenter/rpc/pb"
-	usercenterclient "userCenter/rpc/usercenter"
-
 	resourcepb "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/pb"
 	"bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/resource"
+	"userCenter/rpc/pb"
 
-	"github.com/zeromicro/go-zero/core/conf"
 	"github.com/zeromicro/go-zero/core/discov"
 	"github.com/zeromicro/go-zero/zrpc"
 )
 
-type Config struct {
-	zrpc.RpcServerConf
-	Node           int    // 节点
-	CalleeId       string // 服务名字
-	FileSystemConf zrpc.RpcClientConf
-}
-
-var c Config
-
-func init() {
-	conf.MustLoad("usercenter.yaml", &c)
-}
+//type Config struct {
+//	zrpc.RpcServerConf
+//	Node           int    // 节点
+//	CalleeId       string // 服务名字
+//	FileSystemConf zrpc.RpcClientConf
+//}
+//
+//var c Config
+//
+//func init() {
+//	conf.MustLoad("usercenter.yaml", &c)
+//}
 
 // go test -v -run Test_GetStatusByCode
 func Test_GetStatusByCode(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	//ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
+	FileSystem := AutoInit() //usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
 	req := &pb.GetStatusByCodeReq{
 		Code:  "91230881MA18Y5NM11",
 		Phone: "15225181827",
@@ -46,8 +44,8 @@ func Test_GetStatusByCode(t *testing.T) {
 
 // go test -v -run Test_ExamineInfo
 func Test_ExamineInfo(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	//ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
+	FileSystem := AutoInit() //usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
 	req := &pb.CheckExamineReq{
 		ExamineId: 18,
 	}
@@ -58,8 +56,8 @@ func Test_ExamineInfo(t *testing.T) {
 
 // go test -v -run Test_UpdateEnt
 func Test_UpdateEnt(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	//ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
+	FileSystem := AutoInit() //usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
 	req := &pb.EntUpdateReq{
 		EntId:      14823,
 		UpdateType: 2,
@@ -71,8 +69,8 @@ func Test_UpdateEnt(t *testing.T) {
 
 // go test -v -run Test_EntInfo
 func Test_EntInfo(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	//ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem := AutoInit() //usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
 	req := &pb.CheckEntReq{
 		EntId: 14783,
 	}
@@ -106,8 +104,8 @@ func Test_Resource(t *testing.T) {
 
 // go test -v -run Test_CheckEnt
 func Test_CheckEnt(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	//ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem := AutoInit() //usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
 	req := &pb.CheckEntReq{
 		EntId: 1,
 	}
@@ -118,8 +116,8 @@ func Test_CheckEnt(t *testing.T) {
 
 //
 func Test_EntAuth(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	//ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem := AutoInit() //usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
 	req := &pb.EntAuthReq{
 		Name:             "张鑫磊企业2",
 		AuthPhone:        "15538267985",
@@ -141,8 +139,8 @@ func Test_EntAuth(t *testing.T) {
 
 // go test -v -run Test_EntExamine
 func Test_EntExamine(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	//ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem := AutoInit() //usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
 	req := &pb.ExamineReq{
 		EntId:     14823,
 		AuthType:  "2",
@@ -158,8 +156,8 @@ func Test_EntExamine(t *testing.T) {
 
 // go test -v -run Test_EntList
 func Test_EntList(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	//ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem := AutoInit() //usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
 	req := &pb.EntListReq{
 		Name:       "企业",
 		AuthStatus: "1",
@@ -182,8 +180,8 @@ func Test_EntList(t *testing.T) {
 
 // go test -v -run Test_ExamineList
 func Test_ExamineList(t *testing.T) {
-	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
-	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	//ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem := AutoInit() //usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
 	req := &pb.ExamineListReq{
 		Name:          "中凯",
 		AuthPhone:     "",

+ 157 - 0
service/test_cover.out

@@ -0,0 +1,157 @@
+mode: set
+userCenter/service/user.go:11.45,26.16 3 1
+userCenter/service/user.go:31.2,35.3 1 1
+userCenter/service/user.go:26.16,28.3 1 1
+userCenter/service/user.go:28.8,30.3 1 0
+userCenter/service/user.go:38.47,41.8 3 1
+userCenter/service/user.go:46.2,50.3 1 1
+userCenter/service/user.go:41.8,43.3 1 1
+userCenter/service/user.go:43.8,45.3 1 0
+userCenter/service/user.go:53.44,56.8 3 1
+userCenter/service/user.go:61.2,65.3 1 1
+userCenter/service/user.go:56.8,58.3 1 0
+userCenter/service/user.go:58.8,60.3 1 1
+userCenter/service/user.go:68.40,70.60 2 1
+userCenter/service/user.go:134.2,134.10 1 1
+userCenter/service/user.go:137.2,137.11 1 1
+userCenter/service/user.go:70.60,72.23 2 1
+userCenter/service/user.go:77.3,77.26 1 1
+userCenter/service/user.go:82.3,82.25 1 1
+userCenter/service/user.go:87.3,87.25 1 1
+userCenter/service/user.go:92.3,92.26 1 1
+userCenter/service/user.go:97.3,97.26 1 1
+userCenter/service/user.go:102.3,102.25 1 1
+userCenter/service/user.go:107.3,107.25 1 1
+userCenter/service/user.go:112.3,112.25 1 1
+userCenter/service/user.go:117.3,132.29 3 1
+userCenter/service/user.go:72.23,74.4 1 1
+userCenter/service/user.go:74.9,76.4 1 0
+userCenter/service/user.go:77.26,79.4 1 1
+userCenter/service/user.go:79.9,81.4 1 0
+userCenter/service/user.go:82.25,84.4 1 0
+userCenter/service/user.go:84.9,86.4 1 1
+userCenter/service/user.go:87.25,89.4 1 1
+userCenter/service/user.go:89.9,91.4 1 0
+userCenter/service/user.go:92.26,94.4 1 0
+userCenter/service/user.go:94.9,96.4 1 1
+userCenter/service/user.go:97.26,99.4 1 0
+userCenter/service/user.go:99.9,101.4 1 1
+userCenter/service/user.go:102.25,104.4 1 0
+userCenter/service/user.go:104.9,106.4 1 1
+userCenter/service/user.go:107.25,109.4 1 0
+userCenter/service/user.go:109.9,111.4 1 1
+userCenter/service/user.go:112.25,114.4 1 0
+userCenter/service/user.go:114.9,116.4 1 1
+userCenter/service/user.go:134.10,136.3 1 1
+userCenter/service/user.go:140.37,143.43 3 1
+userCenter/service/user.go:167.2,167.11 1 1
+userCenter/service/user.go:143.43,144.61 1 0
+userCenter/service/user.go:163.3,163.11 1 0
+userCenter/service/user.go:144.61,162.4 4 0
+userCenter/service/user.go:163.11,165.4 1 0
+userCenter/service/workDesktop.go:21.108,23.23 2 1
+userCenter/service/workDesktop.go:125.2,125.8 1 1
+userCenter/service/workDesktop.go:24.23,26.23 1 1
+userCenter/service/workDesktop.go:41.22,45.52 3 1
+userCenter/service/workDesktop.go:97.18,98.77 1 1
+userCenter/service/workDesktop.go:26.23,28.17 2 1
+userCenter/service/workDesktop.go:28.17,29.217 1 1
+userCenter/service/workDesktop.go:29.217,32.6 2 0
+userCenter/service/workDesktop.go:34.9,36.45 1 1
+userCenter/service/workDesktop.go:36.45,39.5 2 0
+userCenter/service/workDesktop.go:45.52,47.44 2 1
+userCenter/service/workDesktop.go:47.44,52.75 2 1
+userCenter/service/workDesktop.go:56.5,57.46 2 1
+userCenter/service/workDesktop.go:52.75,55.6 2 1
+userCenter/service/workDesktop.go:57.46,66.35 3 1
+userCenter/service/workDesktop.go:92.6,92.23 1 1
+userCenter/service/workDesktop.go:66.35,76.26 3 1
+userCenter/service/workDesktop.go:84.7,84.87 1 1
+userCenter/service/workDesktop.go:90.7,90.40 1 1
+userCenter/service/workDesktop.go:77.17,78.46 1 1
+userCenter/service/workDesktop.go:79.18,80.47 1 1
+userCenter/service/workDesktop.go:81.15,82.46 1 1
+userCenter/service/workDesktop.go:84.87,86.70 2 1
+userCenter/service/workDesktop.go:86.70,88.9 1 1
+userCenter/service/workDesktop.go:98.77,101.4 2 1
+userCenter/service/workDesktop.go:101.9,103.47 2 1
+userCenter/service/workDesktop.go:103.47,105.57 2 1
+userCenter/service/workDesktop.go:105.57,106.151 1 1
+userCenter/service/workDesktop.go:106.151,109.7 2 0
+userCenter/service/workDesktop.go:111.10,118.12 1 0
+userCenter/service/workDesktop.go:118.12,121.6 2 0
+userCenter/service/workDesktop.go:129.81,130.21 1 1
+userCenter/service/workDesktop.go:133.2,135.45 3 1
+userCenter/service/workDesktop.go:141.2,141.8 1 1
+userCenter/service/workDesktop.go:130.21,132.3 1 1
+userCenter/service/workDesktop.go:135.45,137.46 2 1
+userCenter/service/workDesktop.go:137.46,139.4 1 1
+userCenter/service/workDesktop.go:145.81,151.39 5 1
+userCenter/service/workDesktop.go:157.2,158.44 2 1
+userCenter/service/workDesktop.go:161.2,168.30 2 1
+userCenter/service/workDesktop.go:198.2,204.37 6 1
+userCenter/service/workDesktop.go:214.2,215.22 2 1
+userCenter/service/workDesktop.go:151.39,152.51 1 1
+userCenter/service/workDesktop.go:152.51,154.4 1 1
+userCenter/service/workDesktop.go:158.44,160.3 1 0
+userCenter/service/workDesktop.go:168.30,180.22 2 1
+userCenter/service/workDesktop.go:188.3,188.82 1 1
+userCenter/service/workDesktop.go:194.3,194.18 1 1
+userCenter/service/workDesktop.go:181.13,182.41 1 1
+userCenter/service/workDesktop.go:183.14,184.42 1 1
+userCenter/service/workDesktop.go:185.11,186.41 1 1
+userCenter/service/workDesktop.go:188.82,190.66 2 1
+userCenter/service/workDesktop.go:190.66,192.5 1 1
+userCenter/service/workDesktop.go:194.18,196.4 1 1
+userCenter/service/workDesktop.go:204.37,205.59 1 1
+userCenter/service/workDesktop.go:205.59,207.87 2 1
+userCenter/service/workDesktop.go:207.87,209.5 1 0
+userCenter/service/workDesktop.go:210.9,212.4 1 0
+userCenter/service/entService.go:35.94,36.66 1 0
+userCenter/service/entService.go:39.2,60.29 4 0
+userCenter/service/entService.go:106.2,107.29 2 0
+userCenter/service/entService.go:137.2,137.33 1 0
+userCenter/service/entService.go:140.2,140.50 1 0
+userCenter/service/entService.go:36.66,38.3 1 0
+userCenter/service/entService.go:60.29,63.24 2 0
+userCenter/service/entService.go:80.3,80.24 1 0
+userCenter/service/entService.go:63.24,69.25 5 0
+userCenter/service/entService.go:72.4,72.24 1 0
+userCenter/service/entService.go:69.25,71.5 1 0
+userCenter/service/entService.go:72.24,78.5 1 0
+userCenter/service/entService.go:80.24,83.31 3 0
+userCenter/service/entService.go:92.4,95.23 2 0
+userCenter/service/entService.go:99.4,100.24 2 0
+userCenter/service/entService.go:83.31,86.29 2 0
+userCenter/service/entService.go:89.5,89.8 1 0
+userCenter/service/entService.go:86.29,88.6 1 0
+userCenter/service/entService.go:95.23,97.5 1 0
+userCenter/service/entService.go:100.24,102.5 1 0
+userCenter/service/entService.go:107.29,108.24 1 0
+userCenter/service/entService.go:108.24,115.32 5 0
+userCenter/service/entService.go:120.4,120.25 1 0
+userCenter/service/entService.go:123.4,123.24 1 0
+userCenter/service/entService.go:130.4,132.24 2 0
+userCenter/service/entService.go:115.32,116.39 1 0
+userCenter/service/entService.go:116.39,118.6 1 0
+userCenter/service/entService.go:120.25,122.5 1 0
+userCenter/service/entService.go:123.24,125.24 2 0
+userCenter/service/entService.go:125.24,127.6 1 0
+userCenter/service/entService.go:132.24,134.5 1 0
+userCenter/service/entService.go:137.33,139.3 1 0
+userCenter/service/entService.go:144.86,145.45 1 0
+userCenter/service/entService.go:148.2,157.23 2 0
+userCenter/service/entService.go:161.2,161.31 1 0
+userCenter/service/entService.go:145.45,147.3 1 0
+userCenter/service/entService.go:157.23,159.3 1 0
+userCenter/service/entService.go:165.99,185.23 6 0
+userCenter/service/entService.go:197.2,201.3 1 0
+userCenter/service/entService.go:185.23,196.3 1 0
+userCenter/service/entService.go:205.115,221.23 6 0
+userCenter/service/entService.go:234.2,238.3 1 0
+userCenter/service/entService.go:221.23,233.3 1 0
+userCenter/service/entService.go:241.94,248.2 3 0
+userCenter/service/entService.go:251.101,277.2 4 0
+userCenter/service/entService.go:279.89,288.2 3 0
+userCenter/service/entService.go:290.112,314.2 4 0
+userCenter/service/entService.go:316.98,323.2 2 0

+ 42 - 0
service/user_test.go

@@ -0,0 +1,42 @@
+package service
+
+import (
+	"log"
+	"testing"
+	"userCenter/rpc/pb"
+)
+
+// go test -v -run Test_UserAdd
+func Test_UserAdd(t *testing.T) {
+	req := &pb.UserAddReq{
+		Appid:    "10000",
+		Phone:    "18530014520",
+		Nickname: "xx",
+		Company:  "郑州森曼木材有限公司",
+	}
+	res := UserAdd(req)
+	log.Println("res:", res)
+}
+
+// go test -v -run Test_UserUpdate
+func Test_UserUpdate(t *testing.T) {
+	req := &pb.UserIdReq{
+		Id:       int64(4),
+		Appid:    "10000",
+		Phone:    "18530014520",
+		Nickname: "小徐的公司",
+		Company:  "郑州森曼木材有限公司",
+	}
+	res := UserUpdate(req)
+	log.Println("res:", res)
+}
+
+// go test -v -run Test_UserDel
+func Test_UserDel(t *testing.T) {
+	req := &pb.UserIdReq{
+		Id:    int64(4),
+		Appid: "10000",
+	}
+	res := UserDel(req)
+	log.Println("res:", res)
+}

+ 1 - 1
service/workDesktop.go

@@ -146,7 +146,7 @@ func GetWordDesktopMenuTree(in *WorkDesktopMenuInfoReq) ([]*pb.MenuList, error)
 	t1 := time.Now()
 	//redis缓存
 	var menuList []*pb.MenuList
-	RedisMenuKey := fmt.Sprintf(entity.RedisMenuKey, in.AppId, in.UserId)
+	RedisMenuKey := fmt.Sprintf(entity.RedisMenuKey, in.AppId, in.Platform, in.UserId)
 	menuBytes, err := redis.GetBytes(entity.RedisCode, RedisMenuKey)
 	if err == nil && len(*menuBytes) > 0 {
 		if json.Unmarshal(*menuBytes, &menuList) == nil {

+ 235 - 34
service/workDesktop_test.go

@@ -1,10 +1,13 @@
 package service
 
 import (
+	"app.yhyue.com/moapp/jybase/redis"
 	"context"
+	"fmt"
 	"log"
 	"testing"
 	"time"
+	"userCenter/entity"
 	"userCenter/rpc/pb"
 )
 
@@ -12,48 +15,217 @@ var (
 	ctx, _ = context.WithTimeout(context.Background(), 2*time.Second)
 )
 
-// 菜单模式选择
-// go test -v -run Test_MenuMode
-func Test_MenuMode(t *testing.T) {
-	FileSystem := AutoInit()
-	AutoInit()
-	req := &pb.WorkDesktopComprehensiveReq{
+//工作桌面菜单树 无缓存
+//go test -run=Test_WorkDesktopMenuTreeNoCache
+func Test_WorkDesktopMenuTreeNoCache(t *testing.T) {
+	in := &pb.WorkDesktopMenuInfoReq{
+		UserId:       "61e7820581197c2e50af18df",
+		AppId:        "10000",
+		Platform:     "PC",
+		Phone:        "",
+		BigMemberOff: true,
+		InternalTime: 1200,
+		RedisOutTime: 1200,
+	}
+	RedisMenuKey := fmt.Sprintf(entity.RedisMenuKey, in.AppId, in.Platform, in.UserId)
+	redis.Del(entity.RedisCode, RedisMenuKey)
+	res, err := GetWordDesktopMenuTree(in)
+	log.Println("err:", err, "---res:", res)
+}
+
+//工作桌面菜单树
+//go test -run=Test_WorkDesktopMenuTree
+func Test_WorkDesktopMenuTree(t *testing.T) {
+	in := &pb.WorkDesktopMenuInfoReq{
+		UserId:       "61e7820581197c2e50af18df",
+		AppId:        "10000",
+		Platform:     "PC",
+		Phone:        "",
+		BigMemberOff: true,
+		InternalTime: 1200,
+		RedisOutTime: 1200,
+	}
+	res, err := GetWordDesktopMenuTree(in)
+	log.Println("err:", err, "---res:", res)
+}
+
+//工作桌面菜单树
+//go test -run=Test_WorkDesktopMenuTreeWX
+func Test_WorkDesktopMenuTreeWX(t *testing.T) {
+	in := &pb.WorkDesktopMenuInfoReq{
+		UserId:       "61e7820581197c2e50af18df",
+		AppId:        "10000",
+		Platform:     "WX",
+		Phone:        "",
+		BigMemberOff: true,
+		InternalTime: 1200,
+		RedisOutTime: 1200,
+	}
+	RedisMenuKey := fmt.Sprintf(entity.RedisMenuKey, in.AppId, in.Platform, in.UserId)
+	redis.Del(entity.RedisCode, RedisMenuKey)
+	res, err := GetWordDesktopMenuTree(in)
+	log.Println("err:", err, "---res:", res)
+}
+
+//工作桌面菜单树
+//go test -run=Test_WorkDesktopMenuTreeAPP
+func Test_WorkDesktopMenuTreeAPP(t *testing.T) {
+	in := &pb.WorkDesktopMenuInfoReq{
+		UserId:       "61e7820581197c2e50af18df",
+		AppId:        "10000",
+		Platform:     "APP",
+		Phone:        "",
+		BigMemberOff: true,
+		InternalTime: 1200,
+		RedisOutTime: 1200,
+	}
+	RedisMenuKey := fmt.Sprintf(entity.RedisMenuKey, in.AppId, in.Platform, in.UserId)
+	redis.Del(entity.RedisCode, RedisMenuKey)
+	res, err := GetWordDesktopMenuTree(in)
+	log.Println("err:", err, "---res:", res)
+}
+
+// 菜单模式插入
+// go test -v -run Test_MenuModeSave
+func Test_MenuModeSave(t *testing.T) {
+	in := &pb.WorkDesktopComprehensiveReq{
+		UserId:       "61e7820581197c2e50af18df",
+		AppId:        "10000",
+		Platform:     "PC",
+		Phone:        "",
+		ActionMode:   "menuMode",
+		MenuMode:     "usable",
+		MenuIds:      "",
+		BigMemberOff: true,
+		CommonlySize: 10,
+		RedisOutTime: 1200,
+	}
+	res := RenewWorkDesktopMenuModeOrCommonly(in)
+	log.Println("menuModeNew:", res)
+}
+
+// 菜单模式更新-非指定内容
+// go test -v -run Test_MenuModeUpdateWrong
+func Test_MenuModeUpdateWrong(t *testing.T) {
+	in := &pb.WorkDesktopComprehensiveReq{
+		UserId:       "61e7820581197c2e50af18df",
+		AppId:        "10000",
+		Platform:     "PC",
+		Phone:        "",
+		ActionMode:   "menuMode",
+		MenuMode:     "allll",
+		MenuIds:      "",
+		BigMemberOff: true,
+		CommonlySize: 10,
+		RedisOutTime: 1200,
+	}
+	res := RenewWorkDesktopMenuModeOrCommonly(in)
+	log.Println("menuModeNew:", res)
+}
+
+// 菜单模式更新
+// go test -v -run Test_MenuModeUpdate
+func Test_MenuModeUpdate(t *testing.T) {
+	in := &pb.WorkDesktopComprehensiveReq{
+		UserId:       "61e7820581197c2e50af18df",
+		AppId:        "10000",
+		Platform:     "PC",
+		Phone:        "",
+		ActionMode:   "menuMode",
+		MenuMode:     "all",
+		MenuIds:      "",
+		BigMemberOff: true,
+		CommonlySize: 10,
+		RedisOutTime: 1200,
+	}
+	res := RenewWorkDesktopMenuModeOrCommonly(in)
+	log.Println("menuModeNew:", res)
+}
+
+//当前工作桌面菜单模式
+// go test -v -run Test_WorkMenuMode
+func Test_WorkMenuMode(t *testing.T) {
+	in := &pb.WorkDesktopMenuInfoReq{
+		UserId:       "61e7820581197c2e50af18df",
+		AppId:        "10000",
+		Platform:     "PC",
+		Phone:        "",
+		BigMemberOff: true,
+		InternalTime: 1200,
+		RedisOutTime: 1200,
+	}
+	res, err := GetWorkDesktopMenuMode(in)
+	log.Println("err:", err, "---res:", res)
+}
+
+// 当前工作桌面菜单模式-非正常用户
+// go test -v -run Test_WorkMenuModeNoUserId
+func Test_WorkMenuModeNoUserId(t *testing.T) {
+	in := &pb.WorkDesktopMenuInfoReq{
+		UserId:       "",
+		AppId:        "10000",
+		Platform:     "PC",
+		Phone:        "",
+		BigMemberOff: true,
+		InternalTime: 1200,
+		RedisOutTime: 1200,
+	}
+	res, err := GetWorkDesktopMenuMode(in)
+	log.Println("err:", err, "---res:", res)
+}
+
+// 常用功能更新新增
+// go test -v -run Test_CommonlyRenewWX
+func Test_CommonlyRenewWX(t *testing.T) {
+	in := &pb.WorkDesktopComprehensiveReq{
 		UserId:     "61e7820581197c2e50af18df",
 		AppId:      "10000",
-		Platform:   "PC",
+		Platform:   "WX",
 		Phone:      "",
-		ActionMode: "menuMode",
-		MenuMode:   "usable",
-		MenuIds:    "",
+		ActionMode: "commonlyRenew",
+		MenuMode:   "",
+		MenuIds:    "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=",
+	}
+	res := RenewWorkDesktopMenuModeOrCommonly(in)
+	log.Println("res:", res)
+}
+
+// 常用功能更新新增
+// go test -v -run Test_CommonlyRenewAPP
+func Test_CommonlyRenewAPP(t *testing.T) {
+	in := &pb.WorkDesktopComprehensiveReq{
+		UserId:     "61e7820581197c2e50af18df",
+		AppId:      "10000",
+		Platform:   "APP",
+		Phone:      "",
+		ActionMode: "commonlyRenew",
+		MenuMode:   "",
+		MenuIds:    "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=",
 	}
-	res, err := FileSystem.WorkDesktopComprehensive(ctx, req)
-	log.Println("err ", err)
+	res := RenewWorkDesktopMenuModeOrCommonly(in)
 	log.Println("res:", res)
 }
 
-// 常用功能更新
+// 常用功能更新新增
 // go test -v -run Test_CommonlyRenew
 func Test_CommonlyRenew(t *testing.T) {
-	FileSystem := AutoInit()
-	req := &pb.WorkDesktopComprehensiveReq{
+	in := &pb.WorkDesktopComprehensiveReq{
 		UserId:     "61e7820581197c2e50af18df",
 		AppId:      "10000",
 		Platform:   "PC",
 		Phone:      "",
 		ActionMode: "commonlyRenew",
 		MenuMode:   "",
-		MenuIds:    "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J",
+		MenuIds:    "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=",
 	}
-	res, err := FileSystem.WorkDesktopComprehensive(ctx, req)
-	log.Println("err ", err)
+	res := RenewWorkDesktopMenuModeOrCommonly(in)
 	log.Println("res:", res)
 }
 
 // 常用功能列表
 // go test -v -run Test_CommonlyList
 func Test_CommonlyList(t *testing.T) {
-	FileSystem := AutoInit()
-	req := &pb.WorkDesktopComprehensiveReq{
+	in := &pb.WorkDesktopComprehensiveReq{
 		UserId:     "61e7820581197c2e50af18df",
 		AppId:      "10000",
 		Platform:   "PC",
@@ -62,21 +234,50 @@ func Test_CommonlyList(t *testing.T) {
 		MenuMode:   "",
 		MenuIds:    "",
 	}
-	res, err := FileSystem.WorkDesktopComprehensive(ctx, req)
-	log.Println("err ", err)
+	res := RenewWorkDesktopMenuModeOrCommonly(in)
+	log.Println("res:", res)
+} // 常用功能列表
+// go test -v -run Test_CommonlyListWX
+func Test_CommonlyListWX(t *testing.T) {
+	in := &pb.WorkDesktopComprehensiveReq{
+		UserId:     "61e7820581197c2e50af18df",
+		AppId:      "10000",
+		Platform:   "WX",
+		Phone:      "",
+		ActionMode: "commonlyList",
+		MenuMode:   "",
+		MenuIds:    "",
+	}
+	res := RenewWorkDesktopMenuModeOrCommonly(in)
+	log.Println("res:", res)
+} // 常用功能列表
+// go test -v -run Test_CommonlyListAPP
+func Test_CommonlyListAPP(t *testing.T) {
+	in := &pb.WorkDesktopComprehensiveReq{
+		UserId:     "61e7820581197c2e50af18df",
+		AppId:      "10000",
+		Platform:   "APP",
+		Phone:      "",
+		ActionMode: "commonlyList",
+		MenuMode:   "",
+		MenuIds:    "",
+	}
+	res := RenewWorkDesktopMenuModeOrCommonly(in)
 	log.Println("res:", res)
 }
 
-//工作桌面菜单树
-//go test -run=Test_WorkDesktopMenuTree
-func Test_WorkDesktopMenuTree(t *testing.T) {
-	FileSystem := AutoInit()
-	req := &pb.WorkDesktopMenuInfoReq{
-		UserId:   "61e7820581197c2e50af18df",
-		AppId:    "10000",
-		Platform: "PC",
-		Phone:    "",
-	}
-	res, err := FileSystem.WorkDesktopMenuInfo(ctx, req)
-	log.Println("err:", err, "---res:", res)
+// 常用功能更新清空
+// go test -v -run Test_CommonlyRenew
+func Test_CommonlyClear(t *testing.T) {
+	in := &pb.WorkDesktopComprehensiveReq{
+		UserId:     "61e7820581197c2e50af18df",
+		AppId:      "10000",
+		Platform:   "PC",
+		Phone:      "",
+		ActionMode: "commonlyRenew",
+		MenuMode:   "",
+		MenuIds:    "",
+	}
+	res := RenewWorkDesktopMenuModeOrCommonly(in)
+	log.Println("res:", res)
 }