|
@@ -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 := &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 && len(*r) > 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) > 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) <= 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 && len(*r) > 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) <= 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 := &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 := &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, &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, "", &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 := &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, &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, "", &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 := &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 := &entity.CheckEnt{
|
|
|
|
+ EntId: data.EntId,
|
|
|
|
+ Mysql: entity.Mysql,
|
|
|
|
+ Url: this.Url,
|
|
|
|
+ }
|
|
|
|
+ rdata := info.Info()
|
|
|
|
+ entInfoData := &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 := &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 := &entity.ExamineInfo{
|
|
|
|
+ ExamineId: data.ExamineId,
|
|
|
|
+ Mysql: entity.Mysql,
|
|
|
|
+ }
|
|
|
|
+ rdata := info.Info()
|
|
|
|
+ entInfoData := &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 := &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 > 0 </span><span class="cov8" title="1">{
|
|
|
|
+ status = 1
|
|
|
|
+ }</span> else<span class="cov0" title="0"> {
|
|
|
|
+ msg = "新增用户失败"
|
|
|
|
+ }</span>
|
|
|
|
+ <span class="cov8" title="1">return &UserAddResp{
|
|
|
|
+ ErrorCode: entity.SuccessCode,
|
|
|
|
+ ErrorMsg: msg,
|
|
|
|
+ Data: &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 &ExamineResp{
|
|
|
|
+ ErrorCode: entity.SuccessCode,
|
|
|
|
+ ErrorMsg: msg,
|
|
|
|
+ Data: &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 &ExamineResp{
|
|
|
|
+ ErrorCode: entity.SuccessCode,
|
|
|
|
+ ErrorMsg: msg,
|
|
|
|
+ Data: &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 && snapshot > 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 && len(*userData) > 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 && snapshot > 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 = &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 > 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 <= 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 && len(*existingData) > 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 && len(*menuData) > 0 </span><span class="cov8" title="1">{
|
|
|
|
+ var menuList = []*pb.ThreeLevelMenu{}
|
|
|
|
+ var m = &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 := &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 && 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), &additional) == nil </span><span class="cov8" title="1">{
|
|
|
|
+ menu.TipInfo = &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" && 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 && len(*menuModes) > 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"])) < 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,
|
|
|
|
+ }) < 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 && len(*menuModes) > 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 && len(*menuBytes) > 0 </span><span class="cov8" title="1">{
|
|
|
|
+ if json.Unmarshal(*menuBytes, &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 := &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 := &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), &additional) == nil </span><span class="cov8" title="1">{
|
|
|
|
+ menu.AdditionalInfo = additional
|
|
|
|
+ }</span>
|
|
|
|
+ }
|
|
|
|
+ <span class="cov8" title="1">if menu.Id > 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 && len(menuList) > 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, &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>
|