From 44a0938bee1ddc0155452d2a443a8aba79b73f8b Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Thu, 10 Aug 2023 19:26:09 +0800 Subject: [PATCH] Username --- common/dao/checkin.go | 2 +- common/dao/checkin_money.go | 2 +- common/model/checkin.go | 2 +- common/model/checkin_money.go | 2 +- wechat/info.log | 4 ++++ worker/autopay.go | 6 +++--- worker/checkin.go | 2 +- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/common/dao/checkin.go b/common/dao/checkin.go index f204f16..48b3938 100644 --- a/common/dao/checkin.go +++ b/common/dao/checkin.go @@ -53,7 +53,7 @@ func (d *CheckinDao) Get(id int64) (*model.Checkin, error) { func (d *CheckinDao) GetByDay(userId, day string) (*model.Checkin, error) { var u model.Checkin tx := GetDB().Table(d.TableName()) - tx = tx.Where("user_id = ?", userId) + tx = tx.Where("username = ?", userId) tx = tx.Where("day = ?", day) res := tx.First(&u) if res.Error == gorm.ErrRecordNotFound { diff --git a/common/dao/checkin_money.go b/common/dao/checkin_money.go index 0b6c111..16a508c 100644 --- a/common/dao/checkin_money.go +++ b/common/dao/checkin_money.go @@ -53,7 +53,7 @@ func (d *CheckinMoneyDao) Get(id int64) (*model.CheckinMoney, error) { func (d *CheckinMoneyDao) GetByDay(userId, day, checkinType string) (*model.CheckinMoney, error) { var u model.CheckinMoney tx := GetDB().Table(d.TableName()) - tx = tx.Where("userid = ?", userId) + tx = tx.Where("username = ?", userId) tx = tx.Where("checkin_type = ?", checkinType) tx = tx.Where("day = ?", day) res := tx.First(&u) diff --git a/common/model/checkin.go b/common/model/checkin.go index cf7f54b..31c8e04 100644 --- a/common/model/checkin.go +++ b/common/model/checkin.go @@ -2,7 +2,7 @@ package model type Checkin struct { Id int64 - UserId string + Username string Day string Exception string Rawdata string diff --git a/common/model/checkin_money.go b/common/model/checkin_money.go index 80e8458..9e2c027 100644 --- a/common/model/checkin_money.go +++ b/common/model/checkin_money.go @@ -3,7 +3,7 @@ package model type CheckinMoney struct { Id int64 Day string - Userid string + Username string CheckinId int64 CheckinType string BillNo string diff --git a/wechat/info.log b/wechat/info.log index b6b98fa..bfd204b 100644 --- a/wechat/info.log +++ b/wechat/info.log @@ -106,3 +106,7 @@ {"L":"INFO","timestamp":"2023-08-04T20:37:39+08:00","M":"------------------response content:HTTP/2.0 200 OK\r\nContent-Length: 124\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Fri, 04 Aug 2023 12:37:39 GMT\r\nError-Code: 0\r\nError-Msg: ok\r\nServer: nginx\r\n\r\n{\"errcode\":0,\"errmsg\":\"ok\",\"msgid\":\"Dv0oBVNA9p2BIWPODPqgktwXhcYb7kcDd7Z2ta8Zqcc9a3pPFNE2EIUjzzr4BJ5Sra7bU6A8ahRGfm1-WIb1iQ\"}"} {"L":"INFO","timestamp":"2023-08-04T20:37:58+08:00","M":"POST https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=nAuabeJOqc1PHjn0lCMX5uCxj3osUyg5q7wtH6Kn7J_FrJFNcgbWbfDn4O6TYgx_VadjZjbJ3hmxFBwazJAjhG0S-xkOKW5iPjWZHTNWv23hNmDZmAD95Sl6cWF-LDBwP1VWHVGpxNP5NU0yHT7Jf15derzTPW9R0iTc_v848liReFvyWgrfZ_kr80nUpsRUwmUz8AWiX2Xx04y5py1NqA request header: { Accept:*/*Content-Type:application/json} request body:{\"touser\":\"jiangyong\",\"toparty\":\"\",\"totag\":\"\",\"msgtype\":\"text\",\"agentid\":1000009,\"safe\":0,\"enable_id_trans\":0,\"enable_duplicate_check\":0,\"duplicate_check_interval\":0,\"text\":{\"content\":\"员工名称:zhengdaquan\\n考勤日期:2023-07-05\\n开始时间:2023-07-05 09:05:34\\n结束时间:2023-07-05 21:36:42\\n工作时长:12h31m8s\"}}\n"} {"L":"INFO","timestamp":"2023-08-04T20:37:58+08:00","M":"------------------response content:HTTP/2.0 200 OK\r\nContent-Length: 124\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Fri, 04 Aug 2023 12:37:58 GMT\r\nError-Code: 0\r\nError-Msg: ok\r\nServer: nginx\r\n\r\n{\"errcode\":0,\"errmsg\":\"ok\",\"msgid\":\"Dv0oBVNA9p2BIWPODPqgktwXhcYb7kcDd7Z2ta8ZqcfLmG5EqOZFqmKXL_mUad7VVnqa32Oux8MLMAa_8Gv-JQ\"}"} +{"L":"INFO","timestamp":"2023-08-09T22:04:07+08:00","M":"GET https://qyapi.weixin.qq.com/cgi-bin/gettoken?appid=ww43c49db2e88a17f8&corpid=ww43c49db2e88a17f8&corpsecret=oMB24UhKe50-XPTg7vhnwoTuhEXaq5XeiHPAUtF4hOs&neededText=&secret=oMB24UhKe50-XPTg7vhnwoTuhEXaq5XeiHPAUtF4hOs request header: { Accept:*/*} "} +{"L":"INFO","timestamp":"2023-08-09T22:04:08+08:00","M":"------------------response content:HTTP/2.0 200 OK\r\nContent-Length: 277\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Wed, 09 Aug 2023 14:04:15 GMT\r\nError-Code: 0\r\nError-Msg: ok\r\nServer: nginx\r\n\r\n{\"errcode\":0,\"errmsg\":\"ok\",\"access_token\":\"VABmBihsSVl7GgZ2C7yxe2u1k3wrSxgdjaLyx8PS_aXI3V6-SeOJ-cbBb6SEXxkzy6Ua_lOC3ZlP7wsJy0wx5jAyY20yJPXPYGdYZEhCSDOkgt2VdF8dnd9TSql-uceMf-c7h53osEx7v4kbeGXTyXH73CfRAxXLbrBhke8VJ2eosvrRtkrWj70SHgTajNboV2J5rv0gqewEU10hCmd74Q\",\"expires_in\":7200}"} +{"L":"INFO","timestamp":"2023-08-09T22:04:08+08:00","M":"POST https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=VABmBihsSVl7GgZ2C7yxe2u1k3wrSxgdjaLyx8PS_aXI3V6-SeOJ-cbBb6SEXxkzy6Ua_lOC3ZlP7wsJy0wx5jAyY20yJPXPYGdYZEhCSDOkgt2VdF8dnd9TSql-uceMf-c7h53osEx7v4kbeGXTyXH73CfRAxXLbrBhke8VJ2eosvrRtkrWj70SHgTajNboV2J5rv0gqewEU10hCmd74Q request header: { Content-Type:application/jsonAccept:*/*} request body:{\"touser\":\"jiangyong\",\"toparty\":\"\",\"totag\":\"\",\"msgtype\":\"text\",\"agentid\":1000009,\"safe\":0,\"enable_id_trans\":0,\"enable_duplicate_check\":0,\"duplicate_check_interval\":0,\"text\":{\"content\":\"【上班提醒】\\n员工名称:jiangyong\\n考勤日期:2023-08-09\\n开始时间:2023-08-09 09:59:18\"}}\n"} +{"L":"INFO","timestamp":"2023-08-09T22:04:08+08:00","M":"------------------response content:HTTP/2.0 200 OK\r\nContent-Length: 188\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Wed, 09 Aug 2023 14:04:15 GMT\r\nError-Code: 60020\r\nError-Msg: not allow to access from your ip, hint: [1691589855612133624589115], from ip: 113.249.227.9, more info at https://open.work.weixin.qq.com/devtool/query?e=60020\r\nServer: nginx\r\n\r\n{\"errcode\":60020,\"errmsg\":\"not allow to access from your ip, hint: [1691589855612133624589115], from ip: 113.249.227.9, more info at https://open.work.weixin.qq.com/devtool/query?e=60020\"}"} diff --git a/worker/autopay.go b/worker/autopay.go index 992777a..71a4978 100644 --- a/worker/autopay.go +++ b/worker/autopay.go @@ -31,7 +31,7 @@ func NotifyCheckinOffDuty(checkin *model.Checkin) { func NotifyCheckinOnDuty(checkin *model.Checkin) { message := make([]string, 0) message = append(message, "【上班提醒】") - message = append(message, fmt.Sprintf("员工名称:%s", checkin.UserId)) + message = append(message, fmt.Sprintf("员工名称:%s", checkin.Username)) message = append(message, fmt.Sprintf("考勤日期:%s", checkin.Day)) message = append(message, fmt.Sprintf("开始时间:%s", goutil.TimeToDateTime(checkin.StartTime))) @@ -44,7 +44,7 @@ func autoPayMoney(checkin *model.Checkin, checkinType string) error { cfg := config.GetConfig() checkinMoneyDao := dao.NewCheckinMoneyDao() - checkinMoney, err := checkinMoneyDao.GetByDay(checkin.UserId, checkin.Day, checkinType) + checkinMoney, err := checkinMoneyDao.GetByDay(checkin.Username, checkin.Day, checkinType) if err != nil { log.Errorf("db error :%s", err.Error()) return err @@ -66,7 +66,7 @@ func autoPayMoney(checkin *model.Checkin, checkinType string) error { message := make([]string, 0) duration := checkin.EndTime - checkin.StartTime message = append(message, "【下班提醒】") - message = append(message, fmt.Sprintf("员工名称:%s", checkin.UserId)) + message = append(message, fmt.Sprintf("员工名称:%s", checkin.Username)) message = append(message, fmt.Sprintf("考勤日期:%s", checkin.Day)) message = append(message, fmt.Sprintf("开始时间:%s", goutil.TimeToDateTime(checkin.StartTime))) message = append(message, fmt.Sprintf("结束时间:%s", goutil.TimeToDateTime(checkin.EndTime))) diff --git a/worker/checkin.go b/worker/checkin.go index b7408f9..30ffb10 100644 --- a/worker/checkin.go +++ b/worker/checkin.go @@ -29,7 +29,7 @@ func SyncCheckin(day string) error { if checkin == nil { checkin = new(model.Checkin) checkin.Day = day - checkin.UserId = user + checkin.Username = user isNew = true }