31 changed files with 2744 additions and 95 deletions
@ -0,0 +1,25 @@ |
|||||
|
package flowchart |
||||
|
|
||||
|
import ( |
||||
|
"key_performance_indicators/overall/publicmethod" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 工作流入口
|
||||
|
type ApiMethod struct{} |
||||
|
|
||||
|
// 系统授权配置
|
||||
|
func (a *ApiMethod) Index(c *gin.Context) { |
||||
|
outputCont := publicmethod.MapOut[string]() |
||||
|
outputCont["index"] = "工作流入口" |
||||
|
publicmethod.Result(0, outputCont, c) |
||||
|
} |
||||
|
|
||||
|
// 审批工作流全图
|
||||
|
type ReviewFlow struct { |
||||
|
publicmethod.PublicId //考核项目ID
|
||||
|
IsCorrection int `json:"iscorrection"` //是否整改 1:不整改;2:整改
|
||||
|
PlusReduction int `json:"plusreduction"` //加减分 1:减少;2:增加;
|
||||
|
PeopleList []string `json:"peopleList"` //被测评的人userKey
|
||||
|
} |
||||
@ -0,0 +1,370 @@ |
|||||
|
package flowchart |
||||
|
|
||||
|
import ( |
||||
|
"key_performance_indicators/models/modelshr" |
||||
|
"key_performance_indicators/models/modelskpi" |
||||
|
"key_performance_indicators/overall" |
||||
|
"key_performance_indicators/overall/publicmethod" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 生成审批流程流
|
||||
|
func (a *ApiMethod) ReviewWorkFlow(c *gin.Context) { |
||||
|
//获取登录人信息
|
||||
|
context, err := publicmethod.LoginMyCont(c) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, err, c, "未知身份!不可操作!") |
||||
|
return |
||||
|
} |
||||
|
var receivedValue ReviewFlow |
||||
|
c.ShouldBindJSON(&receivedValue) |
||||
|
if receivedValue.Id == "" { |
||||
|
publicmethod.Result(1, receivedValue, c, "参数错误!") |
||||
|
return |
||||
|
} |
||||
|
if receivedValue.IsCorrection == 0 { |
||||
|
receivedValue.IsCorrection = 2 |
||||
|
} |
||||
|
if len(receivedValue.PeopleList) < 1 { |
||||
|
publicmethod.Result(1, receivedValue, c, "未知被考核人!请指定!") |
||||
|
return |
||||
|
} |
||||
|
//获取考核项性质
|
||||
|
var qualEvalScheme modelskpi.QualitativeEvaluationScheme |
||||
|
err = qualEvalScheme.GetCont(map[string]interface{}{"id": receivedValue.Id}) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(107, err, c) |
||||
|
return |
||||
|
} |
||||
|
//抄送人
|
||||
|
var sendCopyMan []publicmethod.UserListFlowAll |
||||
|
//流程图
|
||||
|
var flowMap []publicmethod.FlowChartList |
||||
|
endStep := 3 |
||||
|
//第一步:创建
|
||||
|
var begin publicmethod.FlowChartList |
||||
|
begin.Step = 1 //步伐
|
||||
|
begin.NodeName = publicmethod.GetSetpName(1) //节点名称
|
||||
|
begin.State = 2 //状态 1、不点亮;2、点亮
|
||||
|
begin.Class = 1 //节点类型 1、普通节点;2、运行中指定节点
|
||||
|
begin.RunType = 1 |
||||
|
beginUserList := append(begin.UserList, GetApproveUser(context.Wechat, context.WorkWechat)) |
||||
|
for _, bv := range beginUserList { |
||||
|
begin.UserList = append(begin.UserList, bv) |
||||
|
if receivedValue.IsCorrection == 1 { |
||||
|
sendCopyMan = append(sendCopyMan, bv) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
flowMap = append(flowMap, begin) |
||||
|
|
||||
|
//第二步:本部门负责人审批
|
||||
|
var stepTwo publicmethod.FlowChartList |
||||
|
stepTwo.Step = 2 //步伐
|
||||
|
stepTwo.NodeName = publicmethod.GetSetpName(2) //节点名称
|
||||
|
stepTwo.State = 1 //状态 1、不点亮;2、点亮
|
||||
|
stepTwo.Class = 1 //节点类型 1、普通节点;2、运行中指定节点
|
||||
|
if receivedValue.IsCorrection != 1 { |
||||
|
stepTwo.RunType = 2 |
||||
|
} else { |
||||
|
stepTwo.RunType = 3 |
||||
|
} |
||||
|
//获取审批人weChatOpenID
|
||||
|
sendUserList, userErr := publicmethod.GetRefereeTeamWorkWechat(16182159043990656, context.MainDeparment) |
||||
|
if userErr == nil { |
||||
|
for iu := 0; iu < len(sendUserList); iu++ { |
||||
|
departListUser := GetApproveUser(sendUserList[iu], sendUserList[iu]) |
||||
|
stepTwo.UserList = append(stepTwo.UserList, departListUser) |
||||
|
if receivedValue.IsCorrection != 1 { |
||||
|
sendCopyMan = append(sendCopyMan, departListUser) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
flowMap = append(flowMap, stepTwo) |
||||
|
|
||||
|
if qualEvalScheme.Attribute == 1 { |
||||
|
//定性
|
||||
|
if receivedValue.IsCorrection != 1 { |
||||
|
//整改措施提交人
|
||||
|
var stepThree publicmethod.FlowChartList |
||||
|
stepThree.Step = 3 //步伐
|
||||
|
stepThree.NodeName = publicmethod.GetSetpName(4) //节点名称
|
||||
|
stepThree.State = 1 //状态 1、不点亮;2、点亮
|
||||
|
stepThree.Class = 2 //节点类型 1、普通节点;2、运行中指定节点
|
||||
|
stepThree.RunType = 2 |
||||
|
//主要责任人负责提交整改措施
|
||||
|
if len(receivedValue.PeopleList) > 0 { |
||||
|
for ipv := 0; ipv < len(receivedValue.PeopleList); ipv++ { |
||||
|
var myUsCont modelshr.PersonArchives |
||||
|
meErr := myUsCont.GetCont(map[string]interface{}{"`key": receivedValue.PeopleList[ipv]}, "`wechat`", "`work_wechat`") |
||||
|
if meErr == nil { |
||||
|
appManList := GetApproveUser(myUsCont.Wechat, myUsCont.WorkWechat) |
||||
|
stepThree.UserList = append(stepThree.UserList, appManList) |
||||
|
sendCopyMan = append(sendCopyMan, appManList) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
flowMap = append(flowMap, stepThree) |
||||
|
//发起人验收
|
||||
|
var stepFour publicmethod.FlowChartList |
||||
|
stepFour.Step = 4 |
||||
|
stepFour.NodeName = publicmethod.GetSetpName(5) |
||||
|
stepFour.State = 1 |
||||
|
stepFour.Class = 1 |
||||
|
stepFour.RunType = 2 |
||||
|
stepFour.UserList = append(stepFour.UserList, GetApproveUser(context.Wechat, context.WorkWechat)) |
||||
|
flowMap = append(flowMap, stepFour) |
||||
|
endStep = 5 |
||||
|
} else { |
||||
|
if len(receivedValue.PeopleList) > 0 { |
||||
|
for ipv := 0; ipv < len(receivedValue.PeopleList); ipv++ { |
||||
|
var myUsCont modelshr.PersonArchives |
||||
|
meErr := myUsCont.GetCont(map[string]interface{}{"`key": receivedValue.PeopleList[ipv]}, "`wechat`", "`work_wechat`") |
||||
|
if meErr == nil { |
||||
|
appManList := GetApproveUser(myUsCont.Wechat, myUsCont.WorkWechat) |
||||
|
sendCopyMan = append(sendCopyMan, appManList) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
//抄送
|
||||
|
var stepCopy publicmethod.FlowChartList |
||||
|
stepCopy.Step = endStep |
||||
|
stepCopy.NodeName = publicmethod.GetSetpName(6) |
||||
|
stepCopy.State = 1 |
||||
|
stepCopy.Class = 1 |
||||
|
stepCopy.RunType = 3 |
||||
|
stepCopy.UserList = sendCopyMan |
||||
|
flowMap = append(flowMap, stepCopy) |
||||
|
publicmethod.Result(0, flowMap, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2022-10-01 09:50:09 |
||||
|
@ 功能: 获取人员信息 |
||||
|
@ 参数 |
||||
|
|
||||
|
#wechat 微信Openid |
||||
|
#workWechat 企业微信ID |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
#userCont 人员信息 |
||||
|
*/ |
||||
|
func GetApproveUser(wechat, workWechat string) (userCont publicmethod.UserListFlowAll) { |
||||
|
openId := wechat |
||||
|
if workWechat != "" { |
||||
|
openId = workWechat |
||||
|
} |
||||
|
var myCont modelshr.PersonArchives |
||||
|
err := overall.CONSTANT_DB_HR.Where("`wechat` = ? OR `work_wechat` = ?", openId, openId).First(&myCont).Error |
||||
|
if err == nil { |
||||
|
userCont.Id = strconv.FormatInt(myCont.Id, 10) //操作人ID
|
||||
|
userCont.Name = myCont.Name //操作人姓名
|
||||
|
userCont.Icon = myCont.Icon //操作人头像
|
||||
|
userCont.Wechat = wechat //微信Openid
|
||||
|
if workWechat != "" { |
||||
|
userCont.Wechat = workWechat |
||||
|
} |
||||
|
userCont.Company = myCont.Company //集团公司
|
||||
|
if myCont.Company != 0 { |
||||
|
var companyCont modelshr.AdministrativeOrganization |
||||
|
companyCont.GetCont(map[string]interface{}{"`id`": myCont.Company}, "`name`") |
||||
|
userCont.CompanyName = companyCont.Name //分厂名称
|
||||
|
} |
||||
|
|
||||
|
userCont.DepartmentId = myCont.MainDeparment //分厂Id
|
||||
|
if myCont.MainDeparment != 0 { |
||||
|
var departmentCont modelshr.AdministrativeOrganization |
||||
|
departmentCont.GetCont(map[string]interface{}{"`id`": myCont.MainDeparment}, "`name`") |
||||
|
userCont.DepartmentName = departmentCont.Name //分厂名称
|
||||
|
} |
||||
|
|
||||
|
userCont.WorkshopId = myCont.AdminOrg //工段Id
|
||||
|
if myCont.AdminOrg != 0 { |
||||
|
var adminOrgCont modelshr.AdministrativeOrganization |
||||
|
adminOrgCont.GetCont(map[string]interface{}{"`id`": myCont.AdminOrg}, "`name`") |
||||
|
userCont.WorkshopName = adminOrgCont.Name //工段名称
|
||||
|
} |
||||
|
|
||||
|
userCont.PostId = myCont.JobId //职务Id
|
||||
|
if myCont.JobId != 0 { |
||||
|
var dutiesCont modelshr.Duties |
||||
|
dutiesCont.GetCont(map[string]interface{}{"`id`": myCont.JobId}, "`name`") |
||||
|
userCont.PostName = dutiesCont.Name //职务名称
|
||||
|
} |
||||
|
userCont.Tema = myCont.TeamId //班组Id
|
||||
|
if myCont.TeamId != 0 { |
||||
|
var teamCont modelshr.TeamGroup |
||||
|
teamCont.GetCont(map[string]interface{}{"`id`": myCont.TeamId}, "`name`") |
||||
|
userCont.TemaName = teamCont.Name //班组名称
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2022-10-01 15:11:56 |
||||
|
@ 功能: 创建流程图 |
||||
|
@ 参数 |
||||
|
|
||||
|
#founderWechat 发起人微信或企业微信Openid |
||||
|
#founderDepartment 发起人部门 |
||||
|
#reviewFlowParameter 创建流程参数 |
||||
|
#isAdd 1:创建;2:其他 |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
#flowMap 工作流 |
||||
|
#err 系统信息 |
||||
|
*/ |
||||
|
func SetUpWorkFlow(founderWechat string, founderDepartment int64, reviewFlowParameter ReviewFlow, isAdd int) (flowMap []publicmethod.FlowChartList, err error) { |
||||
|
if reviewFlowParameter.IsCorrection == 0 { |
||||
|
reviewFlowParameter.IsCorrection = 2 |
||||
|
} |
||||
|
if len(reviewFlowParameter.PeopleList) < 1 { |
||||
|
return |
||||
|
} |
||||
|
//获取考核项性质
|
||||
|
var qualEvalScheme modelskpi.QualitativeEvaluationScheme |
||||
|
err = qualEvalScheme.GetCont(map[string]interface{}{"id": reviewFlowParameter.Id}) |
||||
|
if err != nil { |
||||
|
return |
||||
|
} |
||||
|
//抄送人
|
||||
|
var sendCopyMan []publicmethod.UserListFlowAll |
||||
|
var isTureCopyMan []string |
||||
|
//流程图
|
||||
|
// var flowMap []publicmethod.FlowChartList
|
||||
|
endStep := 1 |
||||
|
//第一步:创建
|
||||
|
var begin publicmethod.FlowChartList |
||||
|
begin.Step = endStep //步伐
|
||||
|
begin.NodeName = publicmethod.GetSetpName(1) //节点名称
|
||||
|
begin.State = 2 //状态 1、不点亮;2、点亮
|
||||
|
begin.Class = 1 //节点类型 1、普通节点;2、运行中指定节点
|
||||
|
begin.RunType = 1 //运行状态(1:开始;2:操作点;3:结束)
|
||||
|
beginUserList := append(begin.UserList, GetApproveUser(founderWechat, founderWechat)) |
||||
|
for _, bv := range beginUserList { |
||||
|
if isAdd == 1 { |
||||
|
var setLogList publicmethod.LogList |
||||
|
setLogList.State = 2 |
||||
|
setLogList.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1) |
||||
|
bv.LogList = append(bv.LogList, setLogList) |
||||
|
} |
||||
|
begin.UserList = append(begin.UserList, bv) |
||||
|
if reviewFlowParameter.IsCorrection == 1 { |
||||
|
sendCopyMan = append(sendCopyMan, bv) |
||||
|
isTureCopyMan = append(isTureCopyMan, bv.Id) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
flowMap = append(flowMap, begin) |
||||
|
|
||||
|
//第二步:本部门负责人审批
|
||||
|
endStep = endStep + 1 |
||||
|
var stepTwo publicmethod.FlowChartList |
||||
|
stepTwo.Step = endStep //步伐
|
||||
|
stepTwo.NodeName = publicmethod.GetSetpName(2) //节点名称
|
||||
|
stepTwo.State = 1 //状态 1、不点亮;2、点亮
|
||||
|
stepTwo.Class = 1 //节点类型 1、普通节点;2、运行中指定节点
|
||||
|
if reviewFlowParameter.IsCorrection == 1 { |
||||
|
stepTwo.RunType = 3 |
||||
|
} else { |
||||
|
stepTwo.RunType = 2 |
||||
|
} |
||||
|
//获取审批人weChatOpenID
|
||||
|
sendUserList, userErr := publicmethod.GetRefereeTeamWorkWechat(16182159043990656, founderDepartment) |
||||
|
if userErr == nil { |
||||
|
for iu := 0; iu < len(sendUserList); iu++ { |
||||
|
departListUser := GetApproveUser(sendUserList[iu], sendUserList[iu]) |
||||
|
stepTwo.UserList = append(stepTwo.UserList, departListUser) |
||||
|
if reviewFlowParameter.IsCorrection != 1 { |
||||
|
|
||||
|
if publicmethod.IsInTrue[string](departListUser.Id, isTureCopyMan) == false { |
||||
|
sendCopyMan = append(sendCopyMan, departListUser) |
||||
|
isTureCopyMan = append(isTureCopyMan, departListUser.Id) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
flowMap = append(flowMap, stepTwo) |
||||
|
|
||||
|
if qualEvalScheme.Attribute == 1 { |
||||
|
//定性
|
||||
|
if reviewFlowParameter.IsCorrection != 1 { |
||||
|
//整改措施提交人
|
||||
|
endStep = endStep + 1 |
||||
|
var stepThree publicmethod.FlowChartList |
||||
|
stepThree.Step = endStep //步伐
|
||||
|
stepThree.NodeName = publicmethod.GetSetpName(4) //节点名称
|
||||
|
stepThree.State = 1 //状态 1、不点亮;2、点亮
|
||||
|
stepThree.Class = 2 //节点类型 1、普通节点;2、运行中指定节点
|
||||
|
stepThree.RunType = 2 |
||||
|
//主要责任人负责提交整改措施
|
||||
|
if len(reviewFlowParameter.PeopleList) > 0 { |
||||
|
for ipv := 0; ipv < len(reviewFlowParameter.PeopleList); ipv++ { |
||||
|
var myUsCont modelshr.PersonArchives |
||||
|
meErr := myUsCont.GetCont(map[string]interface{}{"`key": reviewFlowParameter.PeopleList[ipv]}, "`wechat`", "`work_wechat`") |
||||
|
if meErr == nil { |
||||
|
appManList := GetApproveUser(myUsCont.Wechat, myUsCont.WorkWechat) |
||||
|
stepThree.UserList = append(stepThree.UserList, appManList) |
||||
|
|
||||
|
if publicmethod.IsInTrue[string](appManList.Id, isTureCopyMan) == false { |
||||
|
isTureCopyMan = append(isTureCopyMan, appManList.Id) |
||||
|
sendCopyMan = append(sendCopyMan, appManList) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
flowMap = append(flowMap, stepThree) |
||||
|
//发起人验收
|
||||
|
endStep = endStep + 1 |
||||
|
var stepFour publicmethod.FlowChartList |
||||
|
stepFour.Step = endStep |
||||
|
stepFour.NodeName = publicmethod.GetSetpName(5) |
||||
|
stepFour.State = 1 |
||||
|
stepFour.Class = 1 |
||||
|
stepFour.RunType = 3 |
||||
|
stepFour.UserList = append(stepFour.UserList, GetApproveUser(founderWechat, founderWechat)) |
||||
|
flowMap = append(flowMap, stepFour) |
||||
|
// endStep = 5
|
||||
|
} else { |
||||
|
if len(reviewFlowParameter.PeopleList) > 0 { |
||||
|
for ipv := 0; ipv < len(reviewFlowParameter.PeopleList); ipv++ { |
||||
|
var myUsCont modelshr.PersonArchives |
||||
|
meErr := myUsCont.GetCont(map[string]interface{}{"`key": reviewFlowParameter.PeopleList[ipv]}, "`wechat`", "`work_wechat`") |
||||
|
if meErr == nil { |
||||
|
appManList := GetApproveUser(myUsCont.Wechat, myUsCont.WorkWechat) |
||||
|
|
||||
|
if publicmethod.IsInTrue[string](appManList.Id, isTureCopyMan) == false { |
||||
|
isTureCopyMan = append(isTureCopyMan, appManList.Id) |
||||
|
sendCopyMan = append(sendCopyMan, appManList) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
//抄送
|
||||
|
endStep = endStep + 1 |
||||
|
var stepCopy publicmethod.FlowChartList |
||||
|
stepCopy.Step = endStep |
||||
|
stepCopy.NodeName = publicmethod.GetSetpName(6) |
||||
|
stepCopy.State = 1 |
||||
|
stepCopy.Class = 1 |
||||
|
stepCopy.UserList = sendCopyMan |
||||
|
flowMap = append(flowMap, stepCopy) |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
package workflowchart |
||||
|
|
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2022-09-30 09:49:37 |
||||
|
@ 功能: 工作流路由 |
||||
|
@ 参数 |
||||
|
# |
||||
|
@ 返回值 |
||||
|
# |
||||
|
*/ |
||||
|
type ApiRouter struct{} |
||||
@ -0,0 +1,19 @@ |
|||||
|
package workflowchart |
||||
|
|
||||
|
import ( |
||||
|
"key_performance_indicators/api/version1" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 工作流
|
||||
|
func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { |
||||
|
apiRouter := router.Group("workflow") |
||||
|
|
||||
|
var workFlow = version1.AppApiEntry.WorkFlowChat |
||||
|
{ |
||||
|
apiRouter.GET("", workFlow.Index) //入口
|
||||
|
apiRouter.POST("", workFlow.Index) //入口
|
||||
|
apiRouter.POST("review_workflow", workFlow.ReviewWorkFlow) //生成审批流程流
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,150 @@ |
|||||
|
package wechatcallback |
||||
|
|
||||
|
import ( |
||||
|
"encoding/json" |
||||
|
"encoding/xml" |
||||
|
"fmt" |
||||
|
"key_performance_indicators/middleware/wechatapp/wechatsendmsg" |
||||
|
"key_performance_indicators/models/modelskpi" |
||||
|
"key_performance_indicators/overall" |
||||
|
"strconv" |
||||
|
"strings" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 事件处理
|
||||
|
func EventProcessing(msg []byte, c *gin.Context) { |
||||
|
//通用类型判断是回调的什么事件
|
||||
|
var commonType CurrencyMessage |
||||
|
xml.Unmarshal(msg, &commonType) |
||||
|
switch commonType.Event { |
||||
|
case "subscribe": //关注
|
||||
|
case "unsubscribe": //取消关注
|
||||
|
case "enter_agent": //本事件在成员进入企业微信的应用时触发
|
||||
|
case "LOCATION": //上报地理位置
|
||||
|
GeographicalPosition(msg) |
||||
|
case "batch_job_result": //异步任务完成事件推送
|
||||
|
case "change_contact": //通讯录变更事件
|
||||
|
// WorkWechatMailList(msgContent.ChangeType, decryptMsg)
|
||||
|
case "click": //点击菜单拉取消息的事件推送
|
||||
|
case "view": //点击菜单跳转链接的事件推送
|
||||
|
case "scancode_push": //扫码推事件的事件推送
|
||||
|
case "scancode_waitmsg": //扫码推事件且弹出“消息接收中”提示框的事件推送
|
||||
|
case "pic_sysphoto": //弹出系统拍照发图的事件推送
|
||||
|
case "pic_photo_or_album": //弹出拍照或者相册发图的事件推送
|
||||
|
case "pic_weixin": //弹出微信相册发图器的事件推送
|
||||
|
case "location_select": //弹出地理位置选择器的事件推送
|
||||
|
case "open_approval_change": //审批状态通知事件 自建应用
|
||||
|
// OpenApprovalChange(decryptMsg)
|
||||
|
case "sys_approval_change": //系统审批应用
|
||||
|
case "share_agent_change": //企业互联共享应用事件回调
|
||||
|
case "share_chain_change": //上下游共享应用事件回调
|
||||
|
case "template_card_event": //模板卡片事件推送
|
||||
|
TemplateEvent(msg) |
||||
|
case "template_card_menu_event": //通用模板卡片右上角菜单事件推送
|
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 模板事件处理
|
||||
|
func TemplateEvent(msg []byte) { |
||||
|
var msgCont ButtonEventQuestion |
||||
|
err := xml.Unmarshal(msg, &msgCont) |
||||
|
if err != nil { |
||||
|
return |
||||
|
} |
||||
|
eventKeyAry := strings.Split(msgCont.EventKey, "_") |
||||
|
buttionLen := len(eventKeyAry) |
||||
|
if buttionLen >= 5 { |
||||
|
// for i, v := range eventKeyAry {
|
||||
|
|
||||
|
// fmt.Printf("eventKeyAry:%v====================>%v==================>%v\n", i, v, eventKeyAry[i])
|
||||
|
// }
|
||||
|
switch eventKeyAry[0] { |
||||
|
case "school": |
||||
|
default: //默认系统
|
||||
|
if eventKeyAry[1] == "post" { |
||||
|
//岗位考核
|
||||
|
} else { |
||||
|
//部门考核
|
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
jsonStr, _ := json.Marshal(msgCont) |
||||
|
fmt.Printf("TemplateEvent======>%v\n", string(jsonStr)) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2022-10-05 15:46:05 |
||||
|
@ 功能: 岗位按钮模板回调处理 |
||||
|
@ 参数 |
||||
|
|
||||
|
#orderId 流程Key |
||||
|
#clickEnter 1:同意;2:驳回 |
||||
|
#systemApp 系统 |
||||
|
#step 步进位 |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (b *ButtonEventQuestion) PostTemolateCallBack(orderId, clickEnter, systemApp, step string) { |
||||
|
//1、判断当前流程状态
|
||||
|
var flowCont modelskpi.PostWorkflowOrders |
||||
|
err := flowCont.GetCont(map[string]interface{}{"`order_id`": orderId}) |
||||
|
if err != nil { |
||||
|
var sendMsgText wechatsendmsg.SendTextCard |
||||
|
sendMsgText.Touser = b.FromUsername |
||||
|
sendMsgText.Msgtype = "textcard" |
||||
|
agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64) |
||||
|
sendMsgText.Agentid = agentIdInt |
||||
|
sendMsgText.EnableDuplicateCheck = 0 |
||||
|
sendMsgText.DuplicateCheckInterval = 1800 |
||||
|
sendMsgText.EnableIdTrans = 0 |
||||
|
sendMsgText.MsgBody.Title = "流程关闭" |
||||
|
sendMsgText.MsgBody.Description = "此审批流程已经关闭!请联系发起人!" |
||||
|
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v", orderId) |
||||
|
sendMsgText.MsgBody.URL = jumpUrl |
||||
|
sendMsgText.MsgBody.BtnTxt = "" |
||||
|
sendMsgText.SendMsg(systemApp) |
||||
|
return |
||||
|
} else { |
||||
|
var sendMsgText wechatsendmsg.SendTextCard |
||||
|
sendMsgText.Touser = b.FromUsername |
||||
|
sendMsgText.Msgtype = "textcard" |
||||
|
agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64) |
||||
|
sendMsgText.Agentid = agentIdInt |
||||
|
sendMsgText.EnableDuplicateCheck = 0 |
||||
|
sendMsgText.DuplicateCheckInterval = 1800 |
||||
|
sendMsgText.EnableIdTrans = 0 |
||||
|
|
||||
|
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v", orderId) |
||||
|
sendMsgText.MsgBody.URL = jumpUrl |
||||
|
sendMsgText.MsgBody.BtnTxt = "查看详情" |
||||
|
switch flowCont.State { |
||||
|
case 4: |
||||
|
sendMsgText.MsgBody.Title = "流程归档" |
||||
|
sendMsgText.MsgBody.Description = "此审批流程已经归档!不可继续操作!" |
||||
|
sendMsgText.SendMsg(systemApp) |
||||
|
return |
||||
|
case 5: |
||||
|
sendMsgText.MsgBody.Title = "流程废弃" |
||||
|
sendMsgText.MsgBody.Description = "此审批流程已经废弃!不可继续操作!" |
||||
|
sendMsgText.SendMsg(systemApp) |
||||
|
return |
||||
|
case 6: |
||||
|
sendMsgText.MsgBody.Title = "流程不存在" |
||||
|
sendMsgText.MsgBody.Description = "此审批流程不存在!请联系发起人!" |
||||
|
sendMsgText.SendMsg(systemApp) |
||||
|
return |
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
//判断当前步进位是否已经被操作
|
||||
|
var operatorIsTreu modelskpi.OpenApprovalChangeLog |
||||
|
err = operatorIsTreu.GetCont(map[string]interface{}{"`orderid`": orderId, `stepper`: step}) |
||||
|
} |
||||
@ -0,0 +1,64 @@ |
|||||
|
package wechatcallback |
||||
|
|
||||
|
import ( |
||||
|
"encoding/json" |
||||
|
"encoding/xml" |
||||
|
"fmt" |
||||
|
"key_performance_indicators/middleware/grocerystore" |
||||
|
"key_performance_indicators/overall" |
||||
|
"key_performance_indicators/overall/publicmethod" |
||||
|
"time" |
||||
|
) |
||||
|
|
||||
|
func GeographicalPosition(eventMsg []byte) { //进入应用上报地址位置
|
||||
|
var msgContent GeographicalPositionType |
||||
|
err := xml.Unmarshal(eventMsg, &msgContent) |
||||
|
if nil != err { |
||||
|
fmt.Println("***********Unmarshal fail") |
||||
|
} |
||||
|
userAddress := publicmethod.MapOut[string]() |
||||
|
userAddress["userid"] = msgContent.FromUsername //userID
|
||||
|
userAddress["latitude"] = msgContent.Latitude //地理位置纬度
|
||||
|
userAddress["longitude"] = msgContent.Longitude //地理位置经度
|
||||
|
userAddress["precision"] = msgContent.Precision //地理位置精度
|
||||
|
userAddress["time"] = time.Now().Unix() |
||||
|
|
||||
|
marshal, err := json.Marshal(userAddress) |
||||
|
if err != nil { |
||||
|
marshal = []byte{} |
||||
|
} |
||||
|
|
||||
|
redisPrefix := "Location:GeographicalPosition_" + overall.CONSTANT_CONFIG.RedisPrefixStr.PreFix + ":userId_" + msgContent.FromUsername //redis KEY
|
||||
|
// redisClient := redishandel.RunRedis()
|
||||
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS1) |
||||
|
// fmt.Printf("button===101===>%v\n", redisClient)
|
||||
|
locationJson, locationErr := redisClient.Lindex(redisPrefix, 0) |
||||
|
|
||||
|
// fmt.Printf("button===102===>%v===>%v\n", locationJson, locationErr)
|
||||
|
|
||||
|
if locationErr != nil { |
||||
|
redisClient.Lpush(redisPrefix, string(marshal)) |
||||
|
// fmt.Printf("button===1===>%v\n", marshal)
|
||||
|
} else { |
||||
|
var geographicalPositionRedis GeographicalPositionRedis |
||||
|
jsonErr := json.Unmarshal([]byte(locationJson), &geographicalPositionRedis) |
||||
|
|
||||
|
// fmt.Printf("button===2111===>%v===>%v\n", jsonErr, geographicalPositionRedis)
|
||||
|
if jsonErr != nil { |
||||
|
redisClient.Lpush(redisPrefix, string(marshal)) |
||||
|
// fmt.Printf("button===2===>%v===>%v\n", jsonErr, locationJson)
|
||||
|
} else { |
||||
|
timeVal := geographicalPositionRedis.Time |
||||
|
if time.Now().Unix()-timeVal >= 300 { |
||||
|
redisClient.Lpush(redisPrefix, string(marshal)) |
||||
|
// fmt.Printf("button===4===>%v\n", marshal)
|
||||
|
} else { |
||||
|
// fmt.Printf("button===412===>%v===>%v\n", timeVal, time.Now().Unix()-timeVal)
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
// longFloat, _ := strconv.ParseFloat(msgContent.Longitude, 64)
|
||||
|
// latFloat, _ := strconv.ParseFloat(msgContent.Latitude, 64)
|
||||
|
// long, latg := commonus.GCJ02toBD09(longFloat, latFloat)
|
||||
|
// fmt.Printf("button======>%v======>%v======>%v\n", msgContent, long, latg)
|
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package wechatsendmsg |
||||
|
|
||||
|
import "key_performance_indicators/middleware/wechatapp/wechatstatice" |
||||
|
|
||||
|
//发送markdown消息
|
||||
|
type SendMiniprogramNotice struct { |
||||
|
wechatstatice.PublicSendMsgSmaillSub |
||||
|
MsgBody MiniprogramNoticeCont `json:"miniprogram_notice"` |
||||
|
|
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
wechatstatice.PublicSendMsgBootem |
||||
|
} |
||||
|
type MiniprogramNoticeCont struct { |
||||
|
Appid string `json:"appid"` //小程序appid,必须是与当前应用关联的小程序,appid和pagepath必须同时填写,填写后会忽略url字段
|
||||
|
Page string `json:"page"` //点击消息卡片后的小程序页面,最长1024个字节,仅限本小程序内的页面。该字段不填则消息点击后不跳转。
|
||||
|
PublicTextCont |
||||
|
EmphasisFirstItem bool `json:"emphasis_first_item"` //是否放大第一个content_item
|
||||
|
ContentItem []ContentItemCont `json:"content_item"` //消息内容键值对,最多允许10个item
|
||||
|
} |
||||
|
type ContentItemCont struct { |
||||
|
Key string `json:"key"` //长度10个汉字以内
|
||||
|
Calue string `json:"value"` //长度30个汉字以内(支持id转译)
|
||||
|
} |
||||
@ -0,0 +1,301 @@ |
|||||
|
package wechatsendmsg |
||||
|
|
||||
|
import ( |
||||
|
"encoding/json" |
||||
|
"key_performance_indicators/middleware/wechatapp/wechatstatice" |
||||
|
"key_performance_indicators/overall/publicmethod" |
||||
|
) |
||||
|
|
||||
|
// 发送文本消息
|
||||
|
func (s *SendTextMsg) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送语音信息
|
||||
|
func (s *SendVoiceMsg) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送图片信息
|
||||
|
func (s *SendImage) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送视频信息
|
||||
|
func (s *SendVideo) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送文件消息
|
||||
|
func (s *SendFile) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送文本卡片消息
|
||||
|
func (s *SendTextCard) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送图文消息
|
||||
|
func (s *SendNews) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送图文消息(mpnews)
|
||||
|
func (s *SendMpNews) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送图文消息(mpnews)
|
||||
|
func (s *SendMarkDown) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送小程序通知消息
|
||||
|
func (s *SendMiniprogramNotice) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送文本通知型消息(All)
|
||||
|
func (s *SendTextNoticeAll) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送文本通知型(一级标题+二级文本+发送人)
|
||||
|
func (s *SendTextNoticeOneAndTwoTitleMan) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送文本通知型(引用文献+发送人)
|
||||
|
func (s *SendTextNoticeQuoteMan) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 发送图文展示型(All)
|
||||
|
func (s *SendImageNoticeAll) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 图文展示型(一级标题+图片)
|
||||
|
func (s *SendImageNoticeOneImg) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 图文展示型(卡片二级垂直内容+图片)
|
||||
|
func (s *SendImageNoticeImgVer) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 图文展示型(左图右文样式)
|
||||
|
func (s *SendImageNoticeLImgRText) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 按钮交互型(All)
|
||||
|
func (s *SendButtonInteractionAll) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 按钮交互型(simplify)
|
||||
|
func (s *SendButtonInteractionSimplify) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 投票选择型
|
||||
|
func (s *SendVoteInteraction) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 多项选择型
|
||||
|
func (s *SendMultipleInteraction) SendMsg(systemApp string) (callBackCont wechatstatice.SendCallBackMsg, err error) { |
||||
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "send") |
||||
|
if err != nil { |
||||
|
callBackCont.Unlicenseduser = sendUrl |
||||
|
callBackCont.Msgid = token |
||||
|
return |
||||
|
} |
||||
|
sendDate, _ := json.Marshal(s) |
||||
|
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) |
||||
|
err = json.Unmarshal(callBackByte, &callBackCont) |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,303 @@ |
|||||
|
package wechatsendmsg |
||||
|
|
||||
|
import "key_performance_indicators/middleware/wechatapp/wechatstatice" |
||||
|
|
||||
|
type PublicSource struct { |
||||
|
IconUrl string `json:"icon_url"` |
||||
|
Desc string `json:"desc"` |
||||
|
} |
||||
|
type SmaillSub struct { |
||||
|
Appid string `json:"appid"` //小程序appid,必须是与当前应用关联的小程序,appid和pagepath必须同时填写,填写后会忽略url字段
|
||||
|
PagePath string `json:"pagepath"` //点击消息卡片后的小程序页面,最长128字节,仅限本小程序内的页面。appid和pagepath必须同时填写,填写后会忽略url字段
|
||||
|
} |
||||
|
|
||||
|
//文本通知型
|
||||
|
type SendTextNoticeAll struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemplateCardContText `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
|
||||
|
type TemplateCardContText struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
ActionMenu ActionMenuCont `json:"action_menu"` //卡片右上角更多操作按钮
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式
|
||||
|
EmphasisContent EmphasisContentInfo `json:"emphasis_content"` //关键数据样式
|
||||
|
SubTitleText string `json:"sub_title_text"` //二级普通文本,建议不超过160个字,(支持id转译)
|
||||
|
HorizontalContentList []HorizontalContentListInfo `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
||||
|
JumpList []JumpListCont `json:"jump_list"` //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
|
||||
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
||||
|
} |
||||
|
|
||||
|
type SourceText struct { |
||||
|
PublicSource |
||||
|
DescColor int `json:"desc_color"` //来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色
|
||||
|
} |
||||
|
type ActionMenuCont struct { |
||||
|
Desc string `json:"desc"` //更多操作界面的描述
|
||||
|
ActionList []ActionListCont `json:"action_list"` //操作列表,列表长度取值范围为 [1, 3]
|
||||
|
} |
||||
|
type ActionListCont struct { |
||||
|
Key string `json:"key"` //操作key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复
|
||||
|
Text string `json:"text"` //操作的描述文案
|
||||
|
} |
||||
|
type MainTitleCont struct { |
||||
|
Title string `json:"title"` //标题,建议不超过36个字,文本通知型卡片本字段非必填
|
||||
|
Desc string `json:"desc"` //标题辅助信息,建议不超过44个字
|
||||
|
} |
||||
|
type QuoteAreaCont struct { |
||||
|
Type int `json:"type"` //引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序
|
||||
|
Url string `json:"url"` //点击跳转的url,quote_area.type是1时必填
|
||||
|
Title string `json:"title"` //引用文献样式的标题
|
||||
|
QuoteText string `json:"quote_text"` //引用文献样式的引用文案
|
||||
|
SmaillSub |
||||
|
} |
||||
|
type EmphasisContentInfo struct { |
||||
|
MainTitleCont |
||||
|
} |
||||
|
type HorizontalContentListInfo struct { |
||||
|
Type int `json:"type"` //链接类型,0或不填代表不是链接,1 代表跳转url,2 代表下载附件,3 代表点击跳转成员详情
|
||||
|
KeyName string `json:"keyname"` //二级标题,建议不超过5个字
|
||||
|
Value string `json:"value"` //二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字,(支持id转译)
|
||||
|
Url string `json:"url"` //链接跳转的url,horizontal_content_list.type是1时必填
|
||||
|
MediaIdCont //附件的media_id,horizontal_content_list.type是2时必填
|
||||
|
Userid string `json:"userid"` //成员详情的userid,horizontal_content_list.type是3时必填
|
||||
|
} |
||||
|
type JumpListCont struct { |
||||
|
Title string `json:"title"` //跳转链接样式的文案内容,建议不超过18个字
|
||||
|
CardActionCont |
||||
|
} |
||||
|
|
||||
|
type CardActionCont struct { |
||||
|
Type int `json:"type"` //跳转事件类型,1 代表跳转url,2 代表打开小程序。text_notice卡片模版中该字段取值范围为[1,2]
|
||||
|
Url string `json:"url"` //跳转事件的url,card_action.type是1时必填
|
||||
|
SmaillSub |
||||
|
} |
||||
|
|
||||
|
//文本通知型(引用文献+发送人)
|
||||
|
type SendTextNoticeQuoteMan struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemplateCardQuoteMan `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TemplateCardQuoteMan struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式
|
||||
|
HorizontalContentList []HorizontalContentListInfo `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
||||
|
JumpList []JumpListCont `json:"jump_list"` //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
|
||||
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
||||
|
} |
||||
|
|
||||
|
//文本通知型(一级标题+二级文本+发送人)
|
||||
|
type SendTextNoticeOneAndTwoTitleMan struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemplateCardOneAndTwoMan `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TemplateCardOneAndTwoMan struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
SubTitleText string `json:"sub_title_text"` //二级普通文本,建议不超过160个字,(支持id转译)
|
||||
|
HorizontalContentList []HorizontalContentListInfo `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
||||
|
JumpList []JumpListCont `json:"jump_list"` //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
|
||||
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
||||
|
} |
||||
|
|
||||
|
//图文展示型(All)
|
||||
|
type SendImageNoticeAll struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemplateCardContImage `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TemplateCardContImage struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
ActionMenu ActionMenuCont `json:"action_menu"` //卡片右上角更多操作按钮
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式
|
||||
|
|
||||
|
ImageTextArea ImageTextAreaCont `json:"image_text_area"` //左图右文样式,news_notice类型的卡片,card_image和image_text_area两者必填一个字段,不可都不填
|
||||
|
CardImage CardImageCont `json:"card_image"` //图片样式,news_notice类型的卡片,card_image和image_text_area两者必填一个字段,不可都不填
|
||||
|
VerticalContentList VerticalContentListCont `json:"vertical_content_list"` //卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4
|
||||
|
|
||||
|
HorizontalContentList []HorizontalContentListInfo `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
||||
|
JumpList []JumpListCont `json:"jump_list"` //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
|
||||
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
||||
|
} |
||||
|
type ImageTextAreaCont struct { |
||||
|
Type int `json:"type"` //左图右文样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序
|
||||
|
Url string `json:"url"` //点击跳转的url,image_text_area.type是1时必填
|
||||
|
Title string `json:"title"` //左图右文样式的标题
|
||||
|
Desc string `json:"desc"` //左图右文样式的描述
|
||||
|
ImageUrl string `json:"image_url"` //左图右文样式的图片url
|
||||
|
} |
||||
|
type CardImageCont struct { |
||||
|
Url string `json:"url"` //图片的url
|
||||
|
AspectRatio float64 `json:"aspect_ratio"` //图片的宽高比,宽高比要小于2.25,大于1.3,不填该参数默认1.3
|
||||
|
} |
||||
|
type VerticalContentListCont struct { |
||||
|
Title string `json:"title"` //卡片二级标题,建议不超过38个字
|
||||
|
Desc string `json:"desc"` //二级普通文本,建议不超过160个字
|
||||
|
} |
||||
|
|
||||
|
//图文展示型(一级标题+图片)
|
||||
|
type SendImageNoticeOneImg struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemplateCardOneImg `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TemplateCardOneImg struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式
|
||||
|
CardImage CardImageCont `json:"card_image"` //图片样式,news_notice类型的卡片,card_image和image_text_area两者必填一个字段,不可都不填
|
||||
|
HorizontalContentList []HorizontalContentListInfo `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
||||
|
JumpList []JumpListCont `json:"jump_list"` //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
|
||||
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
||||
|
} |
||||
|
|
||||
|
//图文展示型(卡片二级垂直内容+图片)
|
||||
|
type SendImageNoticeImgVer struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemplateCardImgVer `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TemplateCardImgVer struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式
|
||||
|
CardImage CardImageCont `json:"card_image"` //图片样式,news_notice类型的卡片,card_image和image_text_area两者必填一个字段,不可都不填
|
||||
|
VerticalContentList VerticalContentListCont `json:"vertical_content_list"` //卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4
|
||||
|
HorizontalContentList []HorizontalContentListInfo `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
||||
|
JumpList []JumpListCont `json:"jump_list"` //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
|
||||
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
} |
||||
|
|
||||
|
//图文展示型(左图右文样式)
|
||||
|
type SendImageNoticeLImgRText struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemplateCardLImgRText `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TemplateCardLImgRText struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
CardImage CardImageCont `json:"card_image"` //图片样式,news_notice类型的卡片,card_image和image_text_area两者必填一个字段,不可都不填
|
||||
|
ImageTextArea ImageTextAreaCont `json:"image_text_area"` //左图右文样式,news_notice类型的卡片,card_image和image_text_area两者必填一个字段,不可都不填
|
||||
|
|
||||
|
HorizontalContentList []HorizontalContentListInfo `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
||||
|
JumpList []JumpListCont `json:"jump_list"` //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
|
||||
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
||||
|
} |
||||
|
|
||||
|
//按钮交互型(All)
|
||||
|
type SendButtonInteractionAll struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemplateButtonInteraction `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TemplateButtonInteraction struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
ActionMenu ActionMenuCont `json:"action_menu"` //卡片右上角更多操作按钮
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式
|
||||
|
|
||||
|
SubTitleText string `json:"sub_title_text"` //二级普通文本,建议不超过160个字,(支持id转译)
|
||||
|
|
||||
|
ButtonSelection ButtonSelectionCont `json:"button_selection"` |
||||
|
ButtonList []ButtonListCont `json:"button_list"` |
||||
|
|
||||
|
HorizontalContentList []HorizontalContentListInfo `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
||||
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
||||
|
} |
||||
|
|
||||
|
type ButtonSelectionCont struct { |
||||
|
QuestionKey string `json:"question_key"` |
||||
|
Title string `json:"title"` //标题,建议不超过36个字,文本通知型卡片本字段非必填
|
||||
|
SelectedId string `json:"selected_id"` |
||||
|
OptionList []OptionListCont `json:"option_list"` |
||||
|
} |
||||
|
type OptionListCont struct { |
||||
|
Id string `json:"id"` |
||||
|
Text string `json:"text"` |
||||
|
} |
||||
|
type ButtonListCont struct { |
||||
|
Text string `json:"text"` |
||||
|
Style int `json:"style"` |
||||
|
Key string `json:"key"` |
||||
|
} |
||||
|
|
||||
|
//按钮交互型(simplify)
|
||||
|
type SendButtonInteractionSimplify struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemplateButtonInteractionSimplify `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TemplateButtonInteractionSimplify struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
SubTitleText string `json:"sub_title_text"` //二级普通文本,建议不超过160个字,(支持id转译)
|
||||
|
QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式
|
||||
|
ButtonList []ButtonListCont `json:"button_list"` |
||||
|
HorizontalContentList []HorizontalContentListInfo `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
|
||||
|
CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段
|
||||
|
} |
||||
|
|
||||
|
//投票选择型
|
||||
|
type SendVoteInteraction struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemplateVoteInteraction `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TemplateVoteInteraction struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
CheckBox CheckBoxCont `json:"checkbox"` |
||||
|
SubmitButton ActionListCont `json:"submit_button"` |
||||
|
} |
||||
|
type CheckBoxCont struct { |
||||
|
QuestionKey string `json:"question_key"` //选择题key值,用户提交选项后,会产生回调事件,回调事件会带上该key值表示该题,最长支持1024字节
|
||||
|
OptionList []OptionListContCheckBox `json:"option_list"` //选项list,选项个数不超过 20 个,最少1个
|
||||
|
Mode int `json:"mode"` // 选择题模式,单选:0,多选:1,不填默认0
|
||||
|
} |
||||
|
type OptionListContCheckBox struct { |
||||
|
OptionListCont |
||||
|
IsChecked bool `json:"is_checked"` //该选项是否要默认选中
|
||||
|
} |
||||
|
|
||||
|
//多项选择型
|
||||
|
type SendMultipleInteraction struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
TemplateCard TemMultipleInteraction `json:"template_card"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TemMultipleInteraction struct { |
||||
|
CardType string `json:"card_type"` //模板卡片类型
|
||||
|
Source SourceText `json:"source"` //卡片来源样式信息,不需要来源样式可不填写
|
||||
|
MainTitle MainTitleCont `json:"main_title"` //一级标题
|
||||
|
TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填
|
||||
|
SelectList []ButtonSelectionCont `json:"select_list"` |
||||
|
SubmitButton ActionListCont `json:"submit_button"` |
||||
|
} |
||||
@ -1,4 +1,116 @@ |
|||||
package wechatsendmsg |
package wechatsendmsg |
||||
|
|
||||
|
import "key_performance_indicators/middleware/wechatapp/wechatstatice" |
||||
|
|
||||
//企业微信发送消息
|
//企业微信发送消息
|
||||
type ApiRouter struct{} |
type ApiRouter struct{} |
||||
|
|
||||
|
//通用文本信息
|
||||
|
type PublicTextCont struct { |
||||
|
Title string `json:"title"` //消息的标题,不超过128个字节,超过会自动截断
|
||||
|
Description string `json:"description"` //消息的描述,不超过512个字节,超过会自动截断
|
||||
|
} |
||||
|
|
||||
|
//消息内容结构体
|
||||
|
type TextMsgCont struct { |
||||
|
Content string `json:"content"` //消息内容,最长不超过2048个字节,超过将截断(支持id转译)
|
||||
|
} |
||||
|
|
||||
|
type MediaIdCont struct { |
||||
|
MediaId string `json:"media_id"` //文件id,可以调用上传临时素材接口获取
|
||||
|
} |
||||
|
|
||||
|
//发送文本消息求情结构体
|
||||
|
type SendTextMsg struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
MsgBody TextMsgCont `json:"text"` |
||||
|
Safe int `json:"safe"` //表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0
|
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
|
||||
|
//发送语音消息
|
||||
|
type SendVoiceMsg struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
Voice MediaIdCont `json:"voice"` |
||||
|
} |
||||
|
|
||||
|
//发送图片信息
|
||||
|
type SendImage struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
MsgBody MediaIdCont `json:"image"` |
||||
|
Safe int `json:"safe"` //表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0
|
||||
|
} |
||||
|
|
||||
|
//发送视频信息
|
||||
|
type SendVideo struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
MsgBody VideoContSend `json:"video"` |
||||
|
Safe int `json:"safe"` //表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0
|
||||
|
} |
||||
|
type VideoContSend struct { |
||||
|
MediaIdCont |
||||
|
PublicTextCont |
||||
|
} |
||||
|
|
||||
|
//发送文件消息
|
||||
|
type SendFile struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
MsgBody MediaIdCont `json:"file"` |
||||
|
Safe int `json:"safe"` //表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0
|
||||
|
} |
||||
|
|
||||
|
//发送文本卡片消息
|
||||
|
type SendTextCard struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
MsgBody TextCardCont `json:"textcard"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type TextCardCont struct { |
||||
|
PublicTextCont |
||||
|
URL string `json:"url"` //点击后跳转的链接。最长2048字节,请确保包含了协议头(http/https)
|
||||
|
BtnTxt string `json:"btntxt"` //按钮文字。 默认为“详情”, 不超过4个文字,超过自动截断。
|
||||
|
} |
||||
|
|
||||
|
//发送图文消息
|
||||
|
type SendNews struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
MsgBody NewsArticles `json:"news"` |
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
|
||||
|
type NewsArticles struct { |
||||
|
Articles []ArticlesList `json:"articles"` //图文消息,一个图文消息支持1到8条图文
|
||||
|
} |
||||
|
type ArticlesList struct { |
||||
|
PublicTextCont |
||||
|
URL string `json:"url"` //点击后跳转的链接。最长2048字节,请确保包含了协议头(http/https)
|
||||
|
PicURL string `json:"picurl"` //图文消息的图片链接,最长2048字节,支持JPG、PNG格式,较好的效果为大图 1068*455,小图150*150。
|
||||
|
Appid string `json:"appid"` //小程序appid,必须是与当前应用关联的小程序,appid和pagepath必须同时填写,填写后会忽略url字段
|
||||
|
PagePath string `json:"pagepath"` //点击消息卡片后的小程序页面,最长128字节,仅限本小程序内的页面。appid和pagepath必须同时填写,填写后会忽略url字段
|
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
|
||||
|
//发送图文消息(mpnews)
|
||||
|
type SendMpNews struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
MsgBody NewsArticlesMp `json:"mpnews"` |
||||
|
Safe int `json:"safe"` //表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0
|
||||
|
EnableIdTrans int `json:"enable_id_trans"` //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
|
||||
|
} |
||||
|
type NewsArticlesMp struct { |
||||
|
Articles []ArticlesListMp `json:"articles"` //图文消息,一个图文消息支持1到8条图文
|
||||
|
} |
||||
|
type ArticlesListMp struct { |
||||
|
Title string `json:"title"` //消息的标题,不超过128个字节,超过会自动截断
|
||||
|
ThumbMediaId string `json:"thumb_media_id"` |
||||
|
Author string `json:"author"` |
||||
|
ContentSourceUrl string `json:"content_source_url"` |
||||
|
Content string `json:"content"` |
||||
|
Digest string `json:"digest"` |
||||
|
} |
||||
|
|
||||
|
//发送markdown消息
|
||||
|
type SendMarkDown struct { |
||||
|
wechatstatice.PublicSendMsg |
||||
|
MsgBody TextMsgCont `json:"markdown"` |
||||
|
} |
||||
|
|||||
@ -0,0 +1,73 @@ |
|||||
|
package modelskpi |
||||
|
|
||||
|
import ( |
||||
|
"key_performance_indicators/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
// 审批记录
|
||||
|
type OpenApprovalChangeLog struct { |
||||
|
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
||||
|
Type int `json:"type" gorm:"column:type;type:int(1) unsigned;default:1;not null;comment:类型(1:部门;2:岗位)"` |
||||
|
Title string `json:"title" gorm:"column:title;type:varchar(255);comment:节点名称"` |
||||
|
Operator int64 `json:"operator" gorm:"column:operator;type:bigint(20);comment:操作人"` |
||||
|
OrderId int64 `json:"orderid" gorm:"column:orderid;type:bigint(20) unsigned;default:0;not null;comment:订单ID"` |
||||
|
OperatorTime int64 `json:"operatortime" gorm:"column:operatortime;type:bigint(20) unsigned;default:0;not null;comment:操作时间"` |
||||
|
Step int `json:"step" gorm:"column:step;type:int(5) unsigned;default:1;not null;comment:操作第几步"` |
||||
|
OperatorType int `json:"operatortype" gorm:"column:operatortype;type:int(1) unsigned;default:1;not null;comment:操作状态(1:位操作;2:已操作)"` |
||||
|
Msgid string `json:"msgid" gorm:"column:msgid;type:varchar(255);comment:消息id,用于撤回应用消息"` |
||||
|
ResponseCode string `json:"responsecode" gorm:"column:response_code;type:varchar(255);comment:仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"` |
||||
|
Stepper int `json:"stepper" gorm:"column:stepper;type:int(5) unsigned;default:1;not null;comment:步进器"` |
||||
|
ChangeIsTrue int `json:"changeistrue" gorm:"column:change_is_true;type:int(1) unsigned;default:1;not null;comment:是否可变更(1:可变更;2:不可变更)"` |
||||
|
} |
||||
|
|
||||
|
func (OpenApprovalChangeLog *OpenApprovalChangeLog) TableName() string { |
||||
|
return "open_approval_change_log" |
||||
|
} |
||||
|
|
||||
|
// 编辑内容
|
||||
|
func (cont *OpenApprovalChangeLog) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取内容
|
||||
|
func (cont *OpenApprovalChangeLog) GetCont(whereMap interface{}, field ...string) (err error) { |
||||
|
gormDb := overall.CONSTANT_DB_KPI.Model(&cont) |
||||
|
if len(field) > 0 { |
||||
|
fieldStr := strings.Join(field, ",") |
||||
|
gormDb = gormDb.Select(fieldStr) |
||||
|
} |
||||
|
gormDb = gormDb.Where(whereMap) |
||||
|
err = gormDb.First(&cont).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 根据条件获取总数
|
||||
|
func (cont *OpenApprovalChangeLog) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *OpenApprovalChangeLog) ContMap(whereMap interface{}, field ...string) (countAry []OpenApprovalChangeLog, err error) { |
||||
|
gormDb := overall.CONSTANT_DB_KPI.Model(&cont) |
||||
|
if len(field) > 0 { |
||||
|
fieldStr := strings.Join(field, ",") |
||||
|
gormDb = gormDb.Select(fieldStr) |
||||
|
} |
||||
|
err = gormDb.Where(whereMap).Order("sort ASC").Find(&countAry).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 删除内容
|
||||
|
func (cont *OpenApprovalChangeLog) DelCont(whereMap interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 添加记录
|
||||
|
func (cont *OpenApprovalChangeLog) AddCont() (err error) { |
||||
|
err = overall.CONSTANT_DB_KPI.Create(&cont).Error |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,69 @@ |
|||||
|
package modelskpi |
||||
|
|
||||
|
import ( |
||||
|
"key_performance_indicators/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
// 当前节点是否可操作
|
||||
|
type OperatorIsTrue struct { |
||||
|
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
||||
|
OrderId int64 `json:"orderid" gorm:"column:orderid;type:bigint(20) unsigned;default:0;not null;comment:订单ID"` |
||||
|
Step int `json:"step" gorm:"column:step;type:int(5) unsigned;default:1;not null;comment:审批到第几步"` |
||||
|
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态:1:可操作;2:不可操作"` |
||||
|
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:操作时间"` |
||||
|
Msgid string `json:"msgid" gorm:"column:msgid;type:varchar(255);comment:消息id,用于撤回应用消息"` |
||||
|
ResponseCode string `json:"responsecode" gorm:"column:response_code;type:varchar(255);comment:仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"` |
||||
|
Stepper int `json:"stepper" gorm:"column:stepper;type:int(5) unsigned;default:1;not null;comment:步进器"` |
||||
|
} |
||||
|
|
||||
|
func (OperatorIsTrue *OperatorIsTrue) TableName() string { |
||||
|
return "operator_is_true" |
||||
|
} |
||||
|
|
||||
|
// 编辑内容
|
||||
|
func (cont *OperatorIsTrue) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取内容
|
||||
|
func (cont *OperatorIsTrue) GetCont(whereMap interface{}, field ...string) (err error) { |
||||
|
gormDb := overall.CONSTANT_DB_KPI.Model(&cont) |
||||
|
if len(field) > 0 { |
||||
|
fieldStr := strings.Join(field, ",") |
||||
|
gormDb = gormDb.Select(fieldStr) |
||||
|
} |
||||
|
gormDb = gormDb.Where(whereMap) |
||||
|
err = gormDb.First(&cont).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 根据条件获取总数
|
||||
|
func (cont *OperatorIsTrue) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *OperatorIsTrue) ContMap(whereMap interface{}, field ...string) (countAry []OperatorIsTrue, err error) { |
||||
|
gormDb := overall.CONSTANT_DB_KPI.Model(&cont) |
||||
|
if len(field) > 0 { |
||||
|
fieldStr := strings.Join(field, ",") |
||||
|
gormDb = gormDb.Select(fieldStr) |
||||
|
} |
||||
|
err = gormDb.Where(whereMap).Order("sort ASC").Find(&countAry).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 删除内容
|
||||
|
func (cont *OperatorIsTrue) DelCont(whereMap interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 添加记录
|
||||
|
func (cont *OperatorIsTrue) AddCont() (err error) { |
||||
|
err = overall.CONSTANT_DB_KPI.Create(&cont).Error |
||||
|
return |
||||
|
} |
||||
Loading…
Reference in new issue