Skip to content

Commit

Permalink
添加邮件通知。
Browse files Browse the repository at this point in the history
  • Loading branch information
lanyulei committed Jul 25, 2020
1 parent fb59a76 commit 7e80400
Show file tree
Hide file tree
Showing 12 changed files with 192 additions and 6 deletions.
1 change: 1 addition & 0 deletions apis/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func UpdateProcess(c *gin.Context) {
"tpls": processValue.Tpls,
"classify": processValue.Classify,
"task": processValue.Task,
"notice": processValue.Notice,
}).Error
if err != nil {
app.Error(c, -1, err, fmt.Sprintf("更新流程信息失败,%v", err.Error()))
Expand Down
37 changes: 34 additions & 3 deletions apis/process/workOrder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"ferry/global/orm"
"ferry/models/process"
"ferry/models/system"
"ferry/pkg/notify"
"ferry/pkg/service"
"ferry/tools"
"ferry/tools/app"
Expand Down Expand Up @@ -55,8 +56,13 @@ func ProcessStructure(c *gin.Context) {
// 新建工单
func CreateWorkOrder(c *gin.Context) {
var (
taskList []string
stateList []map[string]interface{}
userInfo system.SysUser
variableValue []interface{}
processValue process.Info
sendToUserList []system.SysUser
noticeList []int
workOrderValue struct {
process.WorkOrderInfo
Tpls map[string][]interface{} `json:"tpls"`
Expand Down Expand Up @@ -97,6 +103,13 @@ func CreateWorkOrder(c *gin.Context) {

// 创建工单数据
tx := orm.Eloquent.Begin()

// 查询流程信息
err = tx.Model(&processValue).Where("id = ?", workOrderValue.Process).Find(&processValue).Error
if err != nil {
return
}

var workOrderInfo = process.WorkOrderInfo{
Title: workOrderValue.Title,
Priority: workOrderValue.Priority,
Expand Down Expand Up @@ -156,7 +169,6 @@ func CreateWorkOrder(c *gin.Context) {
}

// 创建历史记录
var stateList []map[string]interface{}
err = json.Unmarshal(workOrderInfo.State, &stateList)
if err != nil {
tx.Rollback()
Expand All @@ -181,14 +193,33 @@ func CreateWorkOrder(c *gin.Context) {

tx.Commit()

// 发送通知
err = json.Unmarshal(processValue.Notice, &noticeList)
if err != nil {
app.Error(c, -1, err, "")
return
}
if len(noticeList) > 0 {
sendToUserList, err = service.GetPrincipalUserInfo(stateList, workOrderInfo.Creator)
if err != nil {
app.Error(c, -1, err, fmt.Sprintf("获取所有处理人的用户信息失败,%v", err.Error()))
return
}

go notify.SendNotify(noticeList, map[string]interface{}{
"userList": sendToUserList,
}, "您有一条待办工单,请及时处理。", "测试")
}

// 执行任务
var taskList []string
err = json.Unmarshal(workOrderValue.Tasks, &taskList)
if err != nil {
app.Error(c, -1, err, "")
return
}
go service.ExecTask(taskList)
if len(taskList) > 0 {
go service.ExecTask(taskList)
}

app.OK(c, "", "成功提交工单申请")
}
Expand Down
6 changes: 6 additions & 0 deletions config/settings.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ settings:
ssl:
key: keystring
pem: temp/pem.pem
email:
alias: ferry
host: smtp.163.com
pass: your password
port: 465
user: your username
8 changes: 7 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ settings:
host: 127.0.0.1
password: 123456
port: 3306
username: root
username: root
email:
alias: ferry
host: smtp.163.com
pass: your password
port: 465
user: your username
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/casbin/casbin/v2 v2.2.1
github.com/casbin/gorm-adapter/v2 v2.0.3
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/gin-contrib/cors v1.3.1
github.com/gin-contrib/cors v1.3.1 // indirect
github.com/gin-gonic/gin v1.5.0
github.com/go-kit/kit v0.8.0
github.com/go-ole/go-ole v1.2.4 // indirect
Expand All @@ -35,5 +35,7 @@ require (
github.com/ugorji/go v1.1.7 // indirect
github.com/unrolled/secure v1.0.8
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
)
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
github.com/json-iterator/go v1.1.8 h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46Ok=
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
Expand All @@ -312,6 +313,7 @@ github.com/klauspost/compress v1.10.10 h1:a/y8CglcM7gLGYmlbP/stPE5sR3hbhFRUjCBfd
github.com/klauspost/compress v1.10.10/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
Expand Down Expand Up @@ -367,9 +369,11 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.0 h1:XaTQmdKecIbwNHpzOIy0XMoEG5bmv/n0OVyaF1NKUdo=
github.com/onsi/ginkgo v1.10.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
Expand Down Expand Up @@ -450,7 +454,9 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203 h1:QVqDTf3h2WHt08YuiTGPZLls0Wq99X9bWd0Q5ZSBesM=
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKNihBbwlX8dLpwxCl3+HnXKV/R0e+sRLd9C8=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
Expand All @@ -461,6 +467,7 @@ github.com/swaggo/swag v1.5.1 h1:2Agm8I4K5qb00620mHq0VJ05/KT4FtmALPIcQR9lEZM=
github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y=
github.com/swaggo/swag v1.6.5 h1:2C+t+xyK6p1sujqncYO/VnMvPZcBJjNdKKyxbOdAW8o=
github.com/swaggo/swag v1.6.5/go.mod h1:Y7ZLSS0d0DdxhWGVhQdu+Bu1QhaF5k0RD7FKdiAykeY=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=
Expand Down Expand Up @@ -541,6 +548,7 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
Expand All @@ -550,6 +558,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -742,6 +751,7 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
Expand Down Expand Up @@ -798,6 +808,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand All @@ -812,6 +824,8 @@ gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2G
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
gopkg.in/go-playground/validator.v9 v9.29.1 h1:SvGtYmN60a5CVKTOzMSyfzWDeZRxRuGvRQyEAKbw1xc=
gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
Expand Down
48 changes: 48 additions & 0 deletions pkg/notify/email/email.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package email

/*
@Author : lanyulei
@Desc : 发送邮件
*/

import (
"strconv"

"github.com/spf13/viper"

log "github.com/sirupsen/logrus"
"gopkg.in/gomail.v2"
)

func server(mailTo []string, subject, body string, args ...string) error {
//定义邮箱服务器连接信息,如果是网易邮箱 pass填密码,qq邮箱填授权码
mailConn := map[string]string{
"user": viper.GetString("settings.email.user"),
"pass": viper.GetString("settings.email.pass"),
"host": viper.GetString("settings.email.host"),
"port": viper.GetString("settings.email.port"),
}

port, _ := strconv.Atoi(mailConn["port"]) //转换端口类型为int

m := gomail.NewMessage()

m.SetHeader("From", m.FormatAddress(mailConn["user"], viper.GetString("settings.email.alias"))) //这种方式可以添加别名,即“XX官方”
m.SetHeader("To", mailTo...) //发送给多个用户
m.SetHeader("Subject", subject) //设置邮件主题
m.SetBody("text/html", body) //设置邮件正文

d := gomail.NewDialer(mailConn["host"], port, mailConn["user"], mailConn["pass"])
err := d.DialAndSend(m)
return err

}

func SendMail(mailTo []string, subject, body string) {
err := server(mailTo, subject, body)
if err != nil {
log.Println(err)
return
}
log.Println("send successfully")
}
26 changes: 26 additions & 0 deletions pkg/notify/send.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package notify

import (
"ferry/models/system"
"ferry/pkg/notify/email"
)

/*
@Author : lanyulei
@同时发送多种通知方式
*/

func SendNotify(classify []int, sendTo interface{}, subject, body string) {
var (
emailList []string
)
for _, c := range classify {
switch c {
case 1: // 邮件
for _, user := range sendTo.(map[string]interface{})["userList"].([]system.SysUser) {
emailList = append(emailList, user.Email)
}
go email.SendMail(emailList, subject, body)
}
}
}
50 changes: 50 additions & 0 deletions pkg/service/getPrincipal.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

/*
@Author : lanyulei
@todo: 添加新的处理人时候,需要修改(先完善功能,后续有时间的时候优化一下这部分。)
*/

func GetPrincipal(processor []int, processMethod string) (principals string, err error) {
Expand Down Expand Up @@ -43,3 +44,52 @@ func GetPrincipal(processor []int, processMethod string) (principals string, err
}
return strings.Join(principalList, ","), nil
}

// 获取用户对应
func GetPrincipalUserInfo(stateList []map[string]interface{}, creator int) (userInfoList []system.SysUser, err error) {
var (
userInfo system.SysUser
deptInfo system.Dept
userInfoListTmp []system.SysUser // 临时保存查询的列表数据
)

err = orm.Eloquent.Model(&userInfo).Where("user_id = ?", creator).Find(&userInfo).Error
if err != nil {
return
}

for _, stateItem := range stateList {
switch stateItem["process_method"] {
case "person":
err = orm.Eloquent.Model(&system.SysUser{}).
Where("user_id in (?)", stateItem["processor"].([]interface{})).
Find(&userInfoListTmp).Error
if err != nil {
return
}
userInfoList = append(userInfoList, userInfoListTmp...)
case "variable": // 变量
for _, processor := range stateItem["processor"].([]interface{}) {
if int(processor.(float64)) == 1 {
// 创建者
userInfoList = append(userInfoList, userInfo)
} else if int(processor.(float64)) == 2 {
// 1. 查询部门信息
err = orm.Eloquent.Model(&deptInfo).Where("dept_id = ?", userInfo.DeptId).Find(&deptInfo).Error
if err != nil {
return
}

// 2. 查询Leader信息
err = orm.Eloquent.Model(&userInfo).Where("user_id = ?", deptInfo.Leader).Find(&userInfo).Error
if err != nil {
return
}
userInfoList = append(userInfoList, userInfo)
}
}
}
}

return
}
1 change: 1 addition & 0 deletions pkg/service/userAuthority.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

/*
@Author : lanyulei
@todo: 添加新的处理人时候,需要修改(先完善功能,后续有时间的时候优化一下这部分。)
*/

func JudgeUserAuthority(c *gin.Context, workOrderId int, currentState string) (status bool, err error) {
Expand Down
1 change: 1 addition & 0 deletions pkg/service/workOrderList.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

/*
@Author : lanyulei
@todo: 添加新的处理人时候,需要修改(先完善功能,后续有时间的时候优化一下这部分。)
*/

type WorkOrder struct {
Expand Down
2 changes: 1 addition & 1 deletion tools/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (p *logFileWriter) Write(data []byte) (n int, err error) {
p.size += int64(n)
//每天一个文件
if p.file.Name() != config2.LogConfig.Dir+"/api-"+time.Now().Format("2006-01-02")+".log" {
p.file.Close()
_ = p.file.Close()
p.file, _ = os.OpenFile(config2.LogConfig.Dir+"/api-"+time.Now().Format("2006-01-02")+".log", os.O_WRONLY|os.O_APPEND|os.O_CREATE|os.O_SYNC, 0600)
p.size = 0
}
Expand Down

0 comments on commit 7e80400

Please sign in to comment.