修改打印模板
This commit is contained in:
208
controllers/app/wx_print.go
Normal file
208
controllers/app/wx_print.go
Normal file
@@ -0,0 +1,208 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-print/controllers/controller"
|
||||
"git.rosy.net.cn/jx-print/model"
|
||||
print "git.rosy.net.cn/jx-print/model/app_model"
|
||||
"git.rosy.net.cn/jx-print/putils"
|
||||
printServer "git.rosy.net.cn/jx-print/services/print_server/app_server"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Print struct{}
|
||||
|
||||
var PrintController = new(Print)
|
||||
|
||||
// AddPrinters 添加打印机 POST
|
||||
// @Title 添加打印机
|
||||
// @Description 添加打印机
|
||||
// @Param token cookie string true "用户登录token"
|
||||
// @Param data body app_model.AddPrintReq true "请求参数"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /addPrinters [post]
|
||||
func (p *Print) AddPrinters(c *gin.Context) {
|
||||
var (
|
||||
err error
|
||||
tokenInfo *model.TokenInfo
|
||||
param = print.AddPrintReq{}
|
||||
printInfo []*model.PrintInfo
|
||||
)
|
||||
|
||||
if err = c.ShouldBind(¶m); err != nil {
|
||||
controller.BuildErrJson(c, err)
|
||||
return
|
||||
}
|
||||
if tokenInfo = controller.CheckToken(c); tokenInfo == nil {
|
||||
return
|
||||
}
|
||||
if err = putils.UnmarshalUseNumber([]byte(param.Prints), &printInfo); err != nil {
|
||||
controller.BuildErrJson(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
err = printServer.AddPrinters(tokenInfo, param.AppID, printInfo)
|
||||
return retVal, "", err
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// GetPrinters 查询打印机 GET
|
||||
// @Title 查询打印机
|
||||
// @Description 查询打印机
|
||||
// @Param token cookie string true "用户登录token"
|
||||
// @Param data body app_model.QueryPrintReq true "请求参数"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /getPrinters [get]
|
||||
func (p *Print) GetPrinters(c *gin.Context) {
|
||||
var (
|
||||
err error
|
||||
tokenInfo *model.TokenInfo
|
||||
param = print.QueryPrintReq{}
|
||||
)
|
||||
if err = c.ShouldBind(¶m); err != nil {
|
||||
controller.BuildErrJson(c, err)
|
||||
return
|
||||
}
|
||||
if tokenInfo = controller.CheckToken(c); tokenInfo == nil {
|
||||
return
|
||||
}
|
||||
|
||||
controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = printServer.GetPrinters(param.AppID, param.PrintNo, param.Name, param.Status, param.IsOnline, param.Offset, param.PageSize, tokenInfo.User.UserID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// DelPrinters 删除打印机 POST
|
||||
// @Title 删除打印机
|
||||
// @Description 删除打印机
|
||||
// @Param token cookie string true "用户登录token"
|
||||
// @Param data body app_model.QueryPrintReq true "请求参数"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /delPrinters [post]
|
||||
func (p *Print) DelPrinters(c *gin.Context) {
|
||||
var (
|
||||
err error
|
||||
tokenInfo *model.TokenInfo
|
||||
param = print.DeletePrintReq{}
|
||||
printNos []string
|
||||
)
|
||||
if err = c.ShouldBind(¶m); err != nil {
|
||||
controller.BuildErrJson(c, err)
|
||||
return
|
||||
}
|
||||
if tokenInfo = controller.CheckToken(c); tokenInfo == nil {
|
||||
return
|
||||
}
|
||||
if err = putils.UnmarshalUseNumber([]byte(param.PrintNos), &printNos); err != nil {
|
||||
controller.BuildErrJson(c, err)
|
||||
return
|
||||
}
|
||||
controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
err = printServer.DelPrinters(param.AppID, tokenInfo, printNos)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// UpdatePrinter 更新打印机 POST
|
||||
// @Title 查询打印机
|
||||
// @Description 查询打印机
|
||||
// @Param token cookie string true "用户登录token"
|
||||
// @Param data body app_model.UpdatePrintReq true "请求参数"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /updatePrinter [post]
|
||||
func (p *Print) UpdatePrinter(c *gin.Context) {
|
||||
var (
|
||||
err error
|
||||
tokenInfo *model.TokenInfo
|
||||
param = print.UpdatePrintReq{}
|
||||
)
|
||||
if err = c.ShouldBind(¶m); err != nil {
|
||||
controller.BuildErrJson(c, err)
|
||||
return
|
||||
}
|
||||
if tokenInfo = controller.CheckToken(c); tokenInfo == nil {
|
||||
return
|
||||
}
|
||||
if !controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
err = printServer.UpdatePrinter(param.AppID, tokenInfo, param.PrintNo, param.Name, param.Sound, param.Volume)
|
||||
return retVal, "", err
|
||||
}) {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// TestPrint 更新打印机 POST
|
||||
// @Title 查询打印机
|
||||
// @Description 查询打印机
|
||||
// @Param token cookie string true "用户登录token"
|
||||
// @Param data body app_model.UpdatePrintReq true "请求参数"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /testPrinter [post]
|
||||
func (p *Print) TestPrint(c *gin.Context) {
|
||||
var (
|
||||
err error
|
||||
tokenInfo *model.TokenInfo
|
||||
param = print.TestPrintReq{}
|
||||
)
|
||||
if err = c.ShouldBind(¶m); err != nil {
|
||||
controller.BuildErrJson(c, err)
|
||||
return
|
||||
}
|
||||
if tokenInfo = controller.CheckToken(c); tokenInfo == nil {
|
||||
return
|
||||
}
|
||||
controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = printServer.TestPrint(param.AppID, tokenInfo, param.PrintNo, param.OrderNo, param.Content)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// GetPrintMessages 获取打印机消息 POST
|
||||
// @Title 获取打印机消息
|
||||
// @Description 获取打印机消息
|
||||
// @Param token cookie string true "用户登录token"
|
||||
// @Param data body app_model.UpdatePrintReq true "请求参数"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /getPrintMessages [get]
|
||||
func (p *Print) GetPrintMessages(c *gin.Context) {
|
||||
var (
|
||||
err error
|
||||
tokenInfo *model.TokenInfo
|
||||
param = print.GetPrintMsg{}
|
||||
)
|
||||
if err = c.ShouldBind(¶m); err != nil {
|
||||
controller.BuildErrJson(c, err)
|
||||
return
|
||||
}
|
||||
if tokenInfo = controller.CheckToken(c); tokenInfo == nil {
|
||||
return
|
||||
}
|
||||
|
||||
controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = printServer.GetPrintMessages(param.AppID, tokenInfo, param.PrintNo, param.MsgID, param.BeginAt, param.EndAt, param.Offset, param.PageSize)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// StatPrinterReport 查询打印统计(首页) GET
|
||||
func (p *Print) StatPrinterReport(c *gin.Context) {
|
||||
var (
|
||||
tokenInfo *model.TokenInfo
|
||||
)
|
||||
if tokenInfo = controller.CheckToken(c); tokenInfo == nil {
|
||||
return
|
||||
}
|
||||
controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = printServer.GetPrinterReport(tokenInfo)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user