瀏覽代碼

Merge branch 'crm1.0' into debug

Roc 3 年之前
父節點
當前提交
b01df96b72

+ 1 - 0
controllers/admin.go

@@ -54,6 +54,7 @@ func (this *AdminCommon) Login() {
 		AdminName:    adminWx.AdminName,
 		RoleName:     adminWx.RoleName,
 		RoleTypeCode: adminWx.RoleTypeCode,
+		AdminId:      adminWx.AdminId,
 	}
 
 	resp.AdminId = adminWx.AdminId

+ 2 - 1
controllers/approval.go

@@ -13,6 +13,7 @@ import (
 	"hongze/hongze_mobile_admin/models/tables/company_product_log"
 	"hongze/hongze_mobile_admin/models/tables/company_report_permission"
 	"hongze/hongze_mobile_admin/services"
+	"hongze/hongze_mobile_admin/services/flow"
 	"hongze/hongze_mobile_admin/utils"
 	"rdluck_tools/paging"
 	"strconv"
@@ -595,7 +596,7 @@ func (this *ApprovalCommon) GetFlowDetail() {
 		return
 	}
 
-	flowItem, err := services.GetApprovalFlow(flowId)
+	flowItem, err := flow.GetApprovalFlow(flowId)
 	if err != nil {
 		this.FailWithMessage("获取失败", "获取数据失败,Err:"+err.Error())
 		return

+ 1 - 0
models/response/admin/admin.go

@@ -3,6 +3,7 @@ package admin
 type LoginResp struct {
 	AdminName    string `description:"系统用户名称"`
 	RealName     string `description:"系统用户姓名"`
+	Headimgurl   string `description:"用户头像"`
 	RoleName     string `description:"角色名称"`
 	RoleTypeCode string `description:"角色类型编码"`
 	AdminId      int    `description:"系统用户id"`

+ 7 - 3
models/response/wechat/wechat.go

@@ -1,12 +1,16 @@
 package wechat
 
-import "time"
+import (
+	"hongze/hongze_mobile_admin/models/response/admin"
+	"time"
+)
 
 type WxLoginResp struct {
 	Code          int
 	Authorization string
 	AdminId       int
 	Expires       time.Time
-	Headimgurl    string `description:"用户头像"`
-	RealName      string `description:"用户名称"`
+	Headimgurl    string          `description:"用户头像"`
+	RealName      string          `description:"用户名称"`
+	UserInfo      admin.LoginResp `description:"用户信息"`
 }

+ 7 - 0
models/tables/h5_admin_session/h5_admin_session.go

@@ -15,6 +15,13 @@ type H5AdminSession struct {
 	LastUpdatedTime time.Time `orm:"column(last_updated_time);" json:"last_updated_time"`
 }
 
+//更新session信息
+func (h5AdminSession *H5AdminSession) Update(cols []string) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Update(h5AdminSession, cols...)
+	return
+}
+
 func GetSessionByToken(token string) (item *H5AdminSession, err error) {
 	sql := `SELECT * FROM h5_admin_session WHERE access_token=? AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
 	o := orm.NewOrm()

+ 3 - 1
services/admin.go

@@ -262,7 +262,9 @@ QUERY_WX_USER:
 		//}
 		//如果联系人编号与session里面的联系人编号不一致的时候,需要做session变更
 		if tokenItem.AdminId != adminId {
-			_ = h5_admin_session.UpdateSession(tokenItem.SessionId, adminId, time.Now().AddDate(0, 1, 0))
+			tokenItem.AdminId = adminId
+			tokenItem.ExpireTime = time.Now().AddDate(0, 1, 0)
+			_ = tokenItem.Update([]string{"AdminId", "ExpireTime"})
 		}
 	}
 	return

+ 0 - 75
services/approval_flow.go

@@ -1,75 +0,0 @@
-package services
-
-import (
-	"errors"
-	"hongze/hongze_mobile_admin/models/tables/admin"
-	"hongze/hongze_mobile_admin/models/tables/approval_flow"
-	"hongze/hongze_mobile_admin/models/tables/approval_flow_node"
-	"strings"
-)
-
-//获取审批工作流(基础)
-func GetApprovalFlow(flowId int) (approvalFlow *approval_flow.ApprovalFlowItem, err error) {
-	approvalFlow, err = approval_flow.GetByFlowItemId(flowId)
-	if err != nil {
-		err = errors.New("查询审批流程失败:Err:" + err.Error())
-		return
-	}
-	approvalFlowNodeList, err := approval_flow_node.GetListByFlowId(approvalFlow.FlowId, approvalFlow.CurrVersion)
-	if err != nil {
-		err = errors.New("查询审批节点失败:Err:" + err.Error())
-		return
-	}
-	for _, approvalFlowNode := range approvalFlowNodeList {
-		userList, tmpErr := getAdminListByUserType(approvalFlowNode.UserType, approvalFlowNode.User, approvalFlow.ProductId)
-		if tmpErr != nil {
-			err = errors.New("获取审批人失败:Err:" + tmpErr.Error())
-			return
-		}
-		for _, user := range userList {
-			userInfo := approval_flow_node.User{
-				AdminId: user.AdminId,
-				Name:    user.RealName,
-			}
-			approvalFlowNode.UserList = append(approvalFlowNode.UserList, userInfo)
-		}
-	}
-	approvalFlow.NodeList = approvalFlowNodeList
-
-	return
-}
-
-//获取审批人信息
-func getAdminListByUserType(userType, user string, productId int) (adminList []*admin.Admin, err error) {
-	switch userType {
-	case "user":
-		adminList, err = admin.GetAdminListByIds(user)
-		return
-	case "manager":
-		roleTypeCode := ``
-		if productId == 1 {
-			roleTypeCode = `ficc_admin`
-		} else if productId == 1 {
-			roleTypeCode = `rai_admin`
-		}
-		if roleTypeCode == `` {
-			err = errors.New("找不到对应的主管")
-			return
-		}
-		adminList, err = admin.GetAdminListByRoleCode(roleTypeCode)
-		return
-	case "role": //角色类型
-		roleSlice := strings.Split(user, ",")
-		for _, roleTypeCode := range roleSlice {
-			list, tmpErr := admin.GetAdminListByRoleCode(roleTypeCode)
-			if tmpErr != nil {
-				err = tmpErr
-				return
-			}
-			adminList = append(adminList, list...)
-		}
-		return
-	}
-	err = errors.New("查找审批人信息异常")
-	return
-}