增加周报只能查看自己及发送给自己的

master
xiao.ming 2021-11-10 18:51:07 +08:00
parent 62b497bbf6
commit d87579b14c
4 changed files with 54 additions and 9 deletions

View File

@ -21,3 +21,23 @@ main.main
/Users/zero/work/mygithub/goweb-gin-demo/main.go:15 /Users/zero/work/mygithub/goweb-gin-demo/main.go:15
runtime.main runtime.main
/Users/zero/go/sdk/go1.16.9/src/runtime/proc.go:225 /Users/zero/go/sdk/go1.16.9/src/runtime/proc.go:225
[goweb-demo]2021/11/10 - 16:57:19.765 info /Users/zero/work/mygithub/run_goweb-gin-demo/initialize/router.go:49 router register success
[goweb-demo]2021/11/10 - 16:57:19.767 info /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"}
[goweb-demo]2021/11/10 - 17:26:39.999 info /Users/zero/work/mygithub/run_goweb-gin-demo/initialize/router.go:49 router register success
[goweb-demo]2021/11/10 - 17:26:40.001 info /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"}
[goweb-demo]2021/11/10 - 17:27:01.783 error /Users/zero/work/mygithub/run_goweb-gin-demo/api/wt/wt_reports.go:112 获取失败! {"err": "Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[ 1, 2, 5, 1 ] LIMIT ? OFFSET ?' at line 1; Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[ 1, 2, 5, 1 ] LIMIT ? OFFSET ?' at line 1"}
[goweb-demo]2021/11/10 - 17:29:35.409 error /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:38 accept tcp [::]:8888: use of closed network connection
[goweb-demo]2021/11/10 - 17:29:47.850 info /Users/zero/work/mygithub/run_goweb-gin-demo/initialize/router.go:49 router register success
[goweb-demo]2021/11/10 - 17:29:47.852 info /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"}
[goweb-demo]2021/11/10 - 17:33:16.947 error /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:38 accept tcp [::]:8888: use of closed network connection
[goweb-demo]2021/11/10 - 17:33:28.565 info /Users/zero/work/mygithub/run_goweb-gin-demo/initialize/router.go:49 router register success
[goweb-demo]2021/11/10 - 17:33:28.566 info /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"}
[goweb-demo]2021/11/10 - 18:07:58.172 info /Users/zero/work/mygithub/run_goweb-gin-demo/initialize/router.go:49 router register success
[goweb-demo]2021/11/10 - 18:07:58.174 info /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"}
[goweb-demo]2021/11/10 - 18:08:45.860 info /Users/zero/work/mygithub/run_goweb-gin-demo/initialize/router.go:49 router register success
[goweb-demo]2021/11/10 - 18:08:45.861 info /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"}
[goweb-demo]2021/11/10 - 18:45:34.852 info /Users/zero/work/mygithub/run_goweb-gin-demo/initialize/router.go:49 router register success
[goweb-demo]2021/11/10 - 18:45:34.853 info /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"}
[goweb-demo]2021/11/10 - 18:47:31.305 error /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:38 accept tcp [::]:8888: use of closed network connection
[goweb-demo]2021/11/10 - 18:47:42.710 info /Users/zero/work/mygithub/run_goweb-gin-demo/initialize/router.go:49 router register success
[goweb-demo]2021/11/10 - 18:47:42.711 info /Users/zero/work/mygithub/run_goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"}

View File

@ -19,23 +19,21 @@ type WtOutputService struct {
// GetWtRule 根据id获取WtRule记录 // GetWtRule 根据id获取WtRule记录
func (wtOutputService *WtOutputService) GetStatResult(idInfo request.GetByUserID) (err error, wtRule wtRes.StatResult) { func (wtOutputService *WtOutputService) GetStatResult(idInfo request.GetByUserID) (err error, wtRule wtRes.StatResult) {
//首先查询要统计的人 //首先查询要统计的人
ruleInfo := wtReq.WtRuleSearch{}
ruleInfo.UserId = int(idInfo.UserId)
var WtServiceGroup WtServiceGroup var WtServiceGroup WtServiceGroup
err, wtRuleResultList, _ := WtServiceGroup.WtRuleService.GetWtRuleInfoList(ruleInfo) err, ruleResult := WtServiceGroup.WtRuleService.GetWtRuleByUserId(idInfo.UserId)
if err != nil { if err != nil {
return err, wtRes.StatResult{} return err, wtRes.StatResult{}
} }
wtRuleResult := wtRuleResultList[0]
//计算起始时间 起始时间是 5-0900 7-1000 //计算起始时间 起始时间是 5-0900 7-1000
startTime := utils.GetTimeFromWeek(wtRuleResult.StartWeek, wtRuleResult.StartHour) startTime := utils.GetTimeFromWeek(ruleResult.StartWeek, ruleResult.StartHour)
endTime := utils.GetTimeFromWeek(wtRuleResult.EndWeek, wtRuleResult.EndHour) endTime := utils.GetTimeFromWeek(ruleResult.EndWeek, ruleResult.EndHour)
//在周报表中进行统计 //在周报表中进行统计
reports := wtRuleResult.Reporters reports := ruleResult.Reporters
var reportSearch wtReq.WtReportsSearch var reportSearch wtReq.WtReportsSearch
reportSearch.StartTime = startTime reportSearch.StartTime = startTime
reportSearch.EndTime = endTime reportSearch.EndTime = endTime

View File

@ -62,14 +62,33 @@ func (wtReportsService *WtReportsService) GetWtReportsInfoList(info wtReq.WtRepo
//首选获取周报的ids //首选获取周报的ids
var reportIds []uint var reportIds []uint
reportTable.Select("`id`", offset, limit).Offset(offset).Limit(limit).Scan(&reportIds) reportTable.Select("id").Offset(offset).Limit(limit).Scan(&reportIds)
querySql := "SELECT id, user_name, send_to, header, contents, pictures, attachments, created_at, updated_at, cmc.comment_count " + querySql := "SELECT id, user_name, user_id, send_to, header, contents, pictures, attachments, created_at, updated_at, cmc.comment_count " +
"FROM wt_reports " + "FROM wt_reports " +
"left join (SELECT report_id, count(report_id) as comment_count FROM wt_comments WHERE report_id in ? GROUP BY report_id) as cmc " + "left join (SELECT report_id, count(report_id) as comment_count FROM wt_comments WHERE report_id in ? GROUP BY report_id) as cmc " +
"on cmc.report_id = wt_reports.id " + "on cmc.report_id = wt_reports.id " +
"WHERE 1=1 " "WHERE 1=1 "
if info.CurrUserId > 0 {
//查询当前user的统计规则
var WtServiceGroup WtServiceGroup
err, ruleRes := WtServiceGroup.WtRuleService.GetWtRuleByUserId(info.CurrUserId)
reportUserIds := " ( "
if err == nil {
reportUserList := ruleRes.Reporters
for _, report := range reportUserList {
reportUserIds += strconv.Itoa(int(report.ID)) + ", "
}
}
reportUserIds += strconv.Itoa(int(info.CurrUserId)) + " ) "
querySql += " and user_id in " + reportUserIds
}
// 条件高级查询 // 条件高级查询
if info.UserId > 0 { if info.UserId > 0 {
querySql += " and id = " + strconv.Itoa(int(info.UserId)) querySql += " and id = " + strconv.Itoa(int(info.UserId))

View File

@ -38,6 +38,14 @@ func (wtRuleService *WtRuleService) GetWtRule(id uint) (err error, wtRule wt.WtR
return return
} }
// GetWtRule 根据user_id获取WtRule记录
func (wtRuleService *WtRuleService) GetWtRuleByUserId(userId uint) (err error, result wtRes.WtRuleResult) {
var wtRule wt.WtRule
err = global.GLOBAL_DB.Where("user_id = ?", userId).First(&wtRule).Error
result = ruleToResult(wtRule)
return
}
// GetWtRuleInfoList 分页获取WtRule记录 // GetWtRuleInfoList 分页获取WtRule记录
func (wtRuleService *WtRuleService) GetWtRuleInfoList(info wtReq.WtRuleSearch) (err error, list []wtRes.WtRuleResult, total int64) { func (wtRuleService *WtRuleService) GetWtRuleInfoList(info wtReq.WtRuleSearch) (err error, list []wtRes.WtRuleResult, total int64) {
limit := info.PageSize limit := info.PageSize