Browse Source

feat:测试用例更新

wangshan 3 years ago
parent
commit
be7e21912f
4 changed files with 126 additions and 968 deletions
  1. 8 6
      Makefile
  2. 0 818
      service/coverage.html
  3. 0 1
      service/test_cover.out
  4. 118 143
      service/workDesktop_test.go

+ 8 - 6
Makefile

@@ -32,10 +32,10 @@ lint:
 	golangcli-lint run --enable-all
 
 #定义变量
-API_LINUX_FILE=./api/userCenter_linux
-API_WIN_FILE=./api/userCenter.exe
-RPC_LINUX_FILE=./rpc/userCenter_linux
-RPC_WIN_FILE=./rpc/userCenter.exe
+API_LINUX_FILE=./api/usercenter_linux
+API_WIN_FILE=./api/usercenter.exe
+RPC_LINUX_FILE=./rpc/usercenter_linux
+RPC_WIN_FILE=./rpc/usercenter.exe
 
 #编译api--linux
 build_api_linux:
@@ -45,6 +45,7 @@ build_api_linux:
 
 #编辑api--win
 build_api_win:
+	@echo "===========> windows go build api "
 	go build -ldflags="-s -w"  -o ${API_WIN_FILE} ./api/usercenter.go
 
 #编译rpc--linux
@@ -55,6 +56,7 @@ build_rpc_linux:
 
 #编辑rpc--win
 build_rpc_win:
+	@echo "===========> windows go build rpc "
 	go build -ldflags="-s -w"  -o ${RPC_WIN_FILE} ./rpc/usercenter.go
 
 #单元测试覆盖率
@@ -65,8 +67,8 @@ cover:
 #清理
 clean:
 	go clean
-	rm -rf ./rpc/*.exe
-	rm -rf ./api/*.exe
+	cd rpc && del *.exe
+	cd api && del *.exe
 
 #显示帮助
 help:

+ 0 - 818
service/coverage.html

@@ -1,818 +0,0 @@
-
-<!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>

+ 0 - 1
service/test_cover.out

@@ -1 +0,0 @@
-mode: set

+ 118 - 143
service/workDesktop_test.go

@@ -16,162 +16,137 @@ var (
 )
 
 //工作桌面菜单树 无缓存
-//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,
+	var ins []*pb.WorkDesktopMenuInfoReq
+	ins = append(ins,
+		&pb.WorkDesktopMenuInfoReq{
+			UserId:       "61e7820581197c2e50af18df",
+			AppId:        "10000",
+			Platform:     "PC",
+			Phone:        "",
+			BigMemberOff: true,
+			InternalTime: 1200,
+			RedisOutTime: 1200,
+		},
+		&pb.WorkDesktopMenuInfoReq{
+			UserId:       "61e7820581197c2e50af18df",
+			AppId:        "10000",
+			Platform:     "PC",
+			Phone:        "",
+			BigMemberOff: true,
+			InternalTime: 1200,
+			RedisOutTime: 1200,
+		},
+		&pb.WorkDesktopMenuInfoReq{
+			UserId:       "61e7820581197c2e50af18df",
+			AppId:        "10000",
+			Platform:     "WX",
+			Phone:        "",
+			BigMemberOff: true,
+			InternalTime: 1200,
+			RedisOutTime: 1200,
+		},
+		&pb.WorkDesktopMenuInfoReq{
+			UserId:       "61e7820581197c2e50af18df",
+			AppId:        "10000",
+			Platform:     "APP",
+			Phone:        "",
+			BigMemberOff: true,
+			InternalTime: 1200,
+			RedisOutTime: 1200,
+		},
+	)
+	var redisMap = map[string]bool{}
+	for _, in := range ins {
+		t.Run("工作桌面菜单树", func(t *testing.T) {
+			if !redisMap[in.Platform] {
+				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)
+		})
 	}
-	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,
+// go test -v -run Test_MenuMode
+func Test_MenuMode(t *testing.T) {
+	var ins []*pb.WorkDesktopComprehensiveReq
+	ins = append(ins,
+		&pb.WorkDesktopComprehensiveReq{
+			UserId:       "61e7820581197c2e50af18df",
+			AppId:        "10000",
+			Platform:     "PC",
+			Phone:        "",
+			ActionMode:   "menuMode",
+			MenuMode:     "usable",
+			MenuIds:      "",
+			BigMemberOff: true,
+			CommonlySize: 10,
+			RedisOutTime: 1200,
+		}, &pb.WorkDesktopComprehensiveReq{
+			UserId:       "61e7820581197c2e50af18df",
+			AppId:        "10000",
+			Platform:     "PC",
+			Phone:        "",
+			ActionMode:   "menuMode",
+			MenuMode:     "allll",
+			MenuIds:      "",
+			BigMemberOff: true,
+			CommonlySize: 10,
+			RedisOutTime: 1200,
+		}, &pb.WorkDesktopComprehensiveReq{
+			UserId:       "61e7820581197c2e50af18df",
+			AppId:        "10000",
+			Platform:     "PC",
+			Phone:        "",
+			ActionMode:   "menuMode",
+			MenuMode:     "all",
+			MenuIds:      "",
+			BigMemberOff: true,
+			CommonlySize: 10,
+			RedisOutTime: 1200,
+		},
+	)
+	for _, in := range ins {
+		t.Run("菜单模式插入、异常、更新", func(t *testing.T) {
+			res := RenewWorkDesktopMenuModeOrCommonly(in)
+			log.Println("menuModeNew:", res)
+		})
 	}
-	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,
+	var ins []*pb.WorkDesktopMenuInfoReq
+	ins = append(ins,
+		&pb.WorkDesktopMenuInfoReq{
+			UserId:       "61e7820581197c2e50af18df",
+			AppId:        "10000",
+			Platform:     "PC",
+			Phone:        "",
+			BigMemberOff: true,
+			InternalTime: 1200,
+			RedisOutTime: 1200,
+		}, &pb.WorkDesktopMenuInfoReq{
+			UserId:       "",
+			AppId:        "10000",
+			Platform:     "PC",
+			Phone:        "",
+			BigMemberOff: true,
+			InternalTime: 1200,
+			RedisOutTime: 1200,
+		},
+	)
+	for _, in := range ins {
+		t.Run("当前工作桌面菜单模式(非正常用户|正常用户)", func(t *testing.T) {
+			res, err := GetWorkDesktopMenuMode(in)
+			log.Println("err:", err, "---res:", res)
+		})
 	}
-	res, err := GetWorkDesktopMenuMode(in)
-	log.Println("err:", err, "---res:", res)
 }
 
 // 常用功能更新新增