123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package controller
- import (
- "Medical_OAuth/common/dto"
- "gogs.baozhida.cn/zoie/OAuth-core/api"
- toolsConfig "gogs.baozhida.cn/zoie/OAuth-core/sdk/config"
- "net/http"
- "github.com/gin-gonic/gin"
- "Medical_OAuth/app/jobs/service"
- _ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
- "gogs.baozhida.cn/zoie/OAuth-core/sdk"
- )
- type SysJob struct {
- api.Api
- }
- // RemoveJobForService 调用service实现
- func (e SysJob) RemoveJobForService(c *gin.Context) {
- v := dto.GeneralDelDto{}
- s := service.SysJob{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&v, nil).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, "")
- return
- }
- s.Cron = sdk.Runtime.GetCrontabKey(toolsConfig.ApplicationConfig.Host)
- err = s.RemoveJob(&v)
- if err != nil {
- e.Logger.Errorf("RemoveJob error, %s", err.Error())
- e.Error(500, err, "")
- return
- }
- e.OK(nil, s.Msg)
- }
- // StartJobForService 启动job service实现
- func (e SysJob) StartJobForService(c *gin.Context) {
- e.MakeContext(c)
- log := e.GetLogger()
- db, err := e.GetOrm()
- if err != nil {
- log.Error(err)
- return
- }
- var v dto.GeneralGetDto
- err = c.BindUri(&v)
- if err != nil {
- log.Warnf("参数验证错误, error: %s", err)
- e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
- return
- }
- s := service.SysJob{}
- s.Orm = db
- s.Log = log
- s.Cron = sdk.Runtime.GetCrontabKey(toolsConfig.ApplicationConfig.Host)
- err = s.StartJob(&v)
- if err != nil {
- log.Errorf("GetCrontabKey error, %s", err.Error())
- e.Error(500, err, err.Error())
- return
- }
- e.OK(nil, s.Msg)
- }
|