| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- package partial
- import (
- "git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
- //sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
- //sysutils "git.qianqiusoft.com/qianqiusoft/light-apiengine/utils"
- "fmt"
- "strconv"
- "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
- sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
- "git.qianqiusoft.com/qianqiusoft/light-apiengine/wfclient"
- //__import_packages__
- )
- // _WfInstanceList
- // @Title _WfInstanceList
- // @Description 分页获取流程实例
- // @Param false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_WfInstanceList(c *entitys.CtrlContext) {
- page, _ := strconv.Atoi(c.Ctx.DefaultQuery("page", "1"))
- rows, _ := strconv.Atoi(c.Ctx.DefaultQuery("rows", "10"))
- //page :=c.Ctx.GetInt("page")
- //rows :=c.Ctx.GetInt("rows")
- sidx := c.Ctx.DefaultQuery("sidx", "")
- sord := c.Ctx.DefaultQuery("sord", "")
- filter := c.Ctx.Query("filters")
- bytess, err := wfclient.NewWFClient(c).FetchWFINstances(page, rows, filter, sidx, sord)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- //c.Ctx.String(200,"",string(bytess))
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _InstanceStepCurrent
- // @Title _InstanceStepCurrent
- // @Description 实例当前状态
- // @Param instance_id false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_InstanceStepCurrent(c *entitys.CtrlContext) {
- instanceId := c.Ctx.Query("instance_id")
- bytess, err := wfclient.NewWFClient(c).FetchCurrentStepByLoginUser(instanceId)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _Prerun
- // @Title _Prerun
- // @Description 运行实例前奏
- // @Param choice false ""
- // @Param instance_id false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_Prerun(c *entitys.CtrlContext) {
- obj := models.WfRunData{}
- err := c.Ctx.Bind(&obj)
- if err != nil {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- return
- }
- bytess, err := wfclient.NewWFClient(c).PreRun(obj.InstanceId, obj.Choice)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _Run
- // @Title _Run
- // @Description 运行实例
- // @Param choice false ""
- // @Param instance_id false ""
- // @Param nextStep false ""
- // @Param option false ""
- // @Param users false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_Run(c *entitys.CtrlContext) {
- obj := models.WfRunData{}
- err := c.Ctx.Bind(&obj)
- if err != nil {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- return
- }
- bytess, err := wfclient.NewWFClient(c).Run(obj.InstanceId, obj.Users, obj.Choice, obj.Opinion, obj.NextStep, c)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _NewStep
- // @Title _NewStep
- // @Description 创建步骤
- // @Param choice false ""
- // @Param instance_id false ""
- // @Param nextStep false ""
- // @Param option false ""
- // @Param users false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_NewStep(c *entitys.CtrlContext) {
- obj := models.WfRunData{}
- err := c.Ctx.Bind(&obj)
- if err != nil {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- return
- }
- bytess, err := wfclient.NewWFClient(c).NewStep(obj.InstanceId, obj.Users, obj.Choice, obj.Opinion, obj.NextStep, c)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _WfDefinesTag
- // @Title _WfDefinesTag
- // @Description 根据tag获取工作流事项
- // @Param tag false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_WfDefinesTag(c *entitys.CtrlContext) {
- tag := c.Ctx.Query("tag")
- bytess, err := wfclient.NewWFClient(c).FetchDefinesByTag(tag)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _WfDefineForm
- // @Title _WfDefineForm
- // @Description 根据表单名称获取表单
- // @Param form false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_WfDefineForm(c *entitys.CtrlContext) {
- form := c.Ctx.Query("form")
- ret := __none_func_sys_wf__(form)
- if ret {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _Recall
- // @Title _Recall
- // @Description 撤回
- // @Param instance_id false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_Recall(c *entitys.CtrlContext) {
- obj := models.WfRunData{}
- err := c.Ctx.Bind(&obj)
- if err != nil {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- return
- }
- bytess, err := wfclient.NewWFClient(c).Recall(obj.InstanceId)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _Interrupt
- // @Title _Interrupt
- // @Description 终止
- // @Param instance_id false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_Interrupt(c *entitys.CtrlContext) {
- obj := map[string]interface{}{}
- err := c.Ctx.Bind(&obj)
- if err != nil {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- return
- }
- instanceId := fmt.Sprintf("%v", obj["instance_id"])
- bytess, err := wfclient.NewWFClient(c).Interrupt(instanceId, obj, c)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _Interrupt
- // @Title _Interrupt
- // @Description 终止
- // @Param instance_id false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_RepairSync(c *entitys.CtrlContext) {
- obj := map[string]interface{}{}
- err := c.Ctx.Bind(&obj)
- if err != nil {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- return
- }
- instanceId := fmt.Sprintf("%v", obj["instance_id"])
- bytess, err := wfclient.NewWFClient(c).RepairSync(instanceId, obj, c)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _Designer
- // @Title _Designer
- // @Description 修改流程定义
- // @Param define_id false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_Designer(c *entitys.CtrlContext) {
- define_id := c.Ctx.Query("define_id")
- bytess, err := wfclient.NewWFClient(c).FetchDesignDiagram(define_id)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _DefineSave
- // @Title _DefineSave
- // @Description 保存流程定义
- // @Param define_id false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_DefineSave(c *entitys.CtrlContext) {
- PostData := models.WfDefine{}
- err := c.Ctx.Bind(&PostData)
- bytess, err := wfclient.NewWFClient(c).CreateOrUpdateDefine(PostData.DefineId, PostData.Name, PostData.Descript, PostData.Data, PostData.Form, PostData.Tag, PostData.Code)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _DefineCreate
- // @Title _DefineCreate
- // @Description 创建流程定义
- // @Param false ""
- // @Success 200 {object} models.Account
- // @Failure 403 :id is empty
- func SysWf_DefineCreate(c *entitys.CtrlContext) {
- PostData := models.WfDefine{}
- err := c.Ctx.Bind(&PostData)
- bytess, err := wfclient.NewWFClient(c).CreateOrUpdateDefine(PostData.DefineId, PostData.Name, PostData.Descript, PostData.Data, PostData.Form, PostData.Tag, PostData.Code)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
- }
- }
- // _CreateInstance
- // @Title _CreateInstance
- // @Description 创建流程实例
- // @Param false ""
- // @Success 200 {object} Account
- // @Failure 403 :id is empty
- func SysWf_CreateInstance(c *entitys.CtrlContext) {
- var InstanceInfo struct {
- DefineId string `json:"define_id"`
- Name string `json:"name"`
- FormData string `json:"form_data"`
- }
- err := c.Ctx.BindJSON(&InstanceInfo)
- if err != nil {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
- return
- }
- bytess, err := wfclient.NewWFClient(c).CreateInstance(InstanceInfo.DefineId, InstanceInfo.Name, InstanceInfo.FormData)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
- }
- }
- // _Define
- // @Title _Define
- // @Description 获取流程定义
- // @Param define_id string false ""
- // @Success 200 {object} Account
- // @Failure 403 :id is empty
- func SysWf_Define(c *entitys.CtrlContext) {
- define_id := c.Ctx.Query("define_id")
- bytess, err := wfclient.NewWFClient(c).FetchDefine(define_id)
- fmt.Println(string(bytess))
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
- }
- }
- // _AllDefine
- // @Title _AllDefine
- // @Description 获取所有流程定义
- // @Success 200 {object} Account
- // @Failure 403 :id is empty
- func SysWf_AllDefine(c *entitys.CtrlContext) {
- bytess, err := wfclient.NewWFClient(c).FetchAllDefines()
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
- }
- }
- // _UpdateIntanceForm
- // @Title _UpdateIntanceForm
- // @Description 更新流程实例form表单
- // @Success 200 {object} Account
- // @Failure 403 :id is empty
- func SysWf_UpdateIntanceForm(c *entitys.CtrlContext) {
- var data struct {
- InstanceId string `json:"instance_id"`
- FormData string `json:"form_data"`
- }
- err := c.Ctx.BindJSON(&data)
- if err != nil {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
- return
- }
- bytess, err := wfclient.NewWFClient(c).UpdateInstanceForm(data.InstanceId, data.FormData)
- if err == nil {
- c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
- } else {
- c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), ""})
- }
- }
- func __none_func_sys_wf__(params ...interface{}) bool {
- return true
- }
|