更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -12,10 +12,8 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// 日报补写窗口:含今天在内的最近 7 天。
|
||||
const BackfillDays = 7
|
||||
|
||||
// 业务错误:控制器按 Code 决定 HTTP 状态码与提示。
|
||||
type Error struct {
|
||||
Code int
|
||||
Msg string
|
||||
@@ -27,7 +25,6 @@ func errBad(msg string) error { return &Error{Code: 400, Msg: msg} }
|
||||
func errForbidden(msg string) error { return &Error{Code: 403, Msg: msg} }
|
||||
func errNotFound(msg string) error { return &Error{Code: 404, Msg: msg} }
|
||||
|
||||
// StatusOf 取业务错误的 HTTP 状态码,非业务错误回退 fallback。
|
||||
func StatusOf(err error, fallback int) int {
|
||||
var e *Error
|
||||
if errors.As(err, &e) {
|
||||
@@ -36,11 +33,6 @@ func StatusOf(err error, fallback int) int {
|
||||
return fallback
|
||||
}
|
||||
|
||||
// UserContext 当前操作人在日报模块内的身份与可见范围。
|
||||
//
|
||||
// UID 是 yz_system_tenant_user.uid(老 uid),不是 JWT 的 identity_id。
|
||||
// TeamOrgIDs 是「当前用户作为负责人的部门」及其全部下级部门;
|
||||
// 为空且非管理员时,只能查看/操作自己的日报。
|
||||
type UserContext struct {
|
||||
Tid uint64
|
||||
UID uint64
|
||||
@@ -52,7 +44,6 @@ type UserContext struct {
|
||||
CanViewTeam bool
|
||||
}
|
||||
|
||||
// InTeamOrg 判断部门是否落在当前用户的团队范围内。
|
||||
func (u *UserContext) InTeamOrg(orgID uint64) bool {
|
||||
for _, id := range u.TeamOrgIDs {
|
||||
if id == orgID {
|
||||
@@ -62,22 +53,18 @@ func (u *UserContext) InTeamOrg(orgID uint64) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Today 本地日期 "YYYY-MM-DD"。
|
||||
func Today() string {
|
||||
return time.Now().Format("2006-01-02")
|
||||
}
|
||||
|
||||
// WindowStart 补写窗口起点(今天往前 BackfillDays-1 天)。
|
||||
func WindowStart() string {
|
||||
return time.Now().AddDate(0, 0, -(BackfillDays - 1)).Format("2006-01-02")
|
||||
}
|
||||
|
||||
// InWindow 判断日期是否在补写窗口内。
|
||||
func InWindow(date string) bool {
|
||||
return date >= WindowStart() && date <= Today()
|
||||
}
|
||||
|
||||
// ParseDate 校验 "YYYY-MM-DD" 并返回规范化的字符串。
|
||||
func ParseDate(date string) (string, error) {
|
||||
date = strings.TrimSpace(date)
|
||||
if date == "" {
|
||||
@@ -90,10 +77,6 @@ func ParseDate(date string) (string, error) {
|
||||
return t.Format("2006-01-02"), nil
|
||||
}
|
||||
|
||||
// dateOnly 把驱动返回的 DATE 值统一成 "YYYY-MM-DD"。
|
||||
// go-sql-driver 在 parseTime=true 时把 DATE 读成 time.Time,
|
||||
// Beego ORM 赋给 string 字段后会得到 "2026-10-21 00:00:00 +0800 CST",
|
||||
// 直接参与 InWindow 的字符串比较会误判为“不在窗口内”。
|
||||
func dateOnly(s string) string {
|
||||
s = strings.TrimSpace(s)
|
||||
if len(s) >= 10 {
|
||||
@@ -102,8 +85,6 @@ func dateOnly(s string) string {
|
||||
return s
|
||||
}
|
||||
|
||||
// BuildContext 组装当前用户的日报身份与团队范围。
|
||||
// identityUserID 为 JWT 中的 UserID,platformAdmin 表示平台端管理员。
|
||||
func BuildContext(tid uint64, identityUserID uint64, fallbackName string, platformAdmin bool) (*UserContext, error) {
|
||||
if models.Orm == nil || tid == 0 {
|
||||
return nil, errBad("缺少租户信息")
|
||||
@@ -164,12 +145,6 @@ func BuildContext(tid uint64, identityUserID uint64, fallbackName string, platfo
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// tenantAdmin 与 controllers.isTenantAdmin 判定口径一致:
|
||||
// 未分配角色 / 租户管理员角色 / 角色未配置权限,均视为全权限。
|
||||
//
|
||||
// 角色查询额外兼容全局预置角色:「租户管理员」「租户用户」在
|
||||
// yz_system_admin_role 中是 cid=2 且 tenant_id=0 的全局记录,
|
||||
// 只有租户自建角色才带自己的 tenant_id,因此这里同时接受 0 与本租户。
|
||||
func tenantAdmin(tid uint64, tu *models.SystemTenantUser) bool {
|
||||
if tu.GroupID == 0 {
|
||||
return true
|
||||
@@ -192,8 +167,6 @@ func tenantAdmin(tid uint64, tu *models.SystemTenantUser) bool {
|
||||
return rights == "" || rights == "[]" || rights == "null"
|
||||
}
|
||||
|
||||
// leaderKeys 负责人在库里可能存员工ID,也可能存租户用户 uid / 认证中心 uid,
|
||||
// 这里把三种可能都收进来,避免因历史数据差异漏判主管身份。
|
||||
func leaderKeys(tid uint64, tu *models.SystemTenantUser, identityUserID, uid uint64) []uint64 {
|
||||
keys := []uint64{uid}
|
||||
if identityUserID > 0 && identityUserID != uid {
|
||||
@@ -217,7 +190,6 @@ func leaderKeys(tid uint64, tu *models.SystemTenantUser, identityUserID, uid uin
|
||||
return keys
|
||||
}
|
||||
|
||||
// loadOrgs 读取租户内未删除的部门。
|
||||
func loadOrgs(tid uint64) ([]models.BackendOrganization, error) {
|
||||
var orgs []models.BackendOrganization
|
||||
_, err := models.Orm.QueryTable(new(models.BackendOrganization)).
|
||||
@@ -231,7 +203,6 @@ func loadOrgs(tid uint64) ([]models.BackendOrganization, error) {
|
||||
return orgs, nil
|
||||
}
|
||||
|
||||
// collectSubtree 返回 roots 及其全部下级部门 ID。
|
||||
func collectSubtree(roots []uint64, orgs []models.BackendOrganization) []uint64 {
|
||||
if len(roots) == 0 {
|
||||
return nil
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// Attachment 日报附件,与 PC / 小程序上传接口返回的文件信息对齐。
|
||||
type Attachment struct {
|
||||
ID uint64 `json:"id"`
|
||||
URL string `json:"url"`
|
||||
@@ -20,7 +19,6 @@ type Attachment struct {
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
// ReportItem 日报列表/详情中的主体。
|
||||
type ReportItem struct {
|
||||
ID uint64 `json:"id"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
@@ -39,7 +37,6 @@ type ReportItem struct {
|
||||
CommentCount int `json:"comment_count"`
|
||||
}
|
||||
|
||||
// Comment 日报评论(两级回复)。
|
||||
type Comment struct {
|
||||
ID uint64 `json:"id"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
@@ -52,7 +49,6 @@ type Comment struct {
|
||||
CanDelete bool `json:"can_delete"`
|
||||
}
|
||||
|
||||
// Detail 日报详情:主体 + 评论 + 修改痕迹 + 当前用户可执行的操作。
|
||||
type Detail struct {
|
||||
Report ReportItem `json:"report"`
|
||||
Comments []Comment `json:"comments"`
|
||||
@@ -64,10 +60,9 @@ type Detail struct {
|
||||
CanWithdraw bool `json:"can_withdraw"`
|
||||
}
|
||||
|
||||
// HistoryItem 日报修改痕迹:撤销提交 / 撤销后重新提交时的内容快照。
|
||||
type HistoryItem struct {
|
||||
ID uint64 `json:"id"`
|
||||
Action int8 `json:"action"` // 1撤销提交 2重新提交
|
||||
Action int8 `json:"action"`
|
||||
UserName string `json:"user_name"`
|
||||
TodayDone string `json:"today_done"`
|
||||
TomorrowPlan string `json:"tomorrow_plan"`
|
||||
@@ -77,7 +72,6 @@ type HistoryItem struct {
|
||||
CreateTime string `json:"create_time"`
|
||||
}
|
||||
|
||||
// SaveInput 保存日报入参;Submit=true 表示提交,否则保存草稿。
|
||||
type SaveInput struct {
|
||||
Date string `json:"date"`
|
||||
TodayDone string `json:"today_done"`
|
||||
@@ -87,7 +81,6 @@ type SaveInput struct {
|
||||
Submit bool `json:"submit"`
|
||||
}
|
||||
|
||||
// MineQuery 我的日报列表查询。
|
||||
type MineQuery struct {
|
||||
StartDate string
|
||||
EndDate string
|
||||
@@ -95,25 +88,21 @@ type MineQuery struct {
|
||||
PageSize int
|
||||
}
|
||||
|
||||
// MineSummary 我的日报页头统计。
|
||||
type MineSummary struct {
|
||||
MonthTotal int `json:"month_total"`
|
||||
MonthSubmitted int `json:"month_submitted"`
|
||||
TodayStatus int8 `json:"today_status"` // -1=今天未填写
|
||||
TodayStatus int8 `json:"today_status"`
|
||||
TodayReportID uint64 `json:"today_report_id"`
|
||||
WindowStart string `json:"window_start"`
|
||||
WindowEnd string `json:"window_end"`
|
||||
}
|
||||
|
||||
// MineResult 我的日报列表结果。
|
||||
type MineResult struct {
|
||||
List []ReportItem `json:"list"`
|
||||
Total int64 `json:"total"`
|
||||
Summary MineSummary `json:"summary"`
|
||||
}
|
||||
|
||||
// Save 新建或更新一条日报(同一人同一天唯一)。
|
||||
// 已提交的日报处于锁定状态,必须先撤销提交退回草稿才能修改。
|
||||
func Save(u *UserContext, in SaveInput) (*ReportItem, error) {
|
||||
date, err := ParseDate(in.Date)
|
||||
if err != nil {
|
||||
@@ -183,11 +172,9 @@ func Save(u *UserContext, in SaveInput) (*ReportItem, error) {
|
||||
return nil, findErr
|
||||
}
|
||||
|
||||
// 已提交的日报锁定:必须先撤销提交退回草稿,才能修改内容。
|
||||
if existing.Status == 1 {
|
||||
return nil, errBad("日报已提交并锁定,如需修改请先撤销提交")
|
||||
}
|
||||
// 撤销过提交的日报再次提交时,留下重新提交痕迹。
|
||||
resubmit := false
|
||||
if in.Submit {
|
||||
if existing.SubmitTime != nil {
|
||||
@@ -241,7 +228,6 @@ func Save(u *UserContext, in SaveInput) (*ReportItem, error) {
|
||||
return buildItem(&existing, count), nil
|
||||
}
|
||||
|
||||
// ListMine 我的日报分页列表 + 页头统计。
|
||||
func ListMine(u *UserContext, q MineQuery) (*MineResult, error) {
|
||||
if q.Page < 1 {
|
||||
q.Page = 1
|
||||
@@ -296,14 +282,12 @@ func ListMine(u *UserContext, q MineQuery) (*MineResult, error) {
|
||||
return &MineResult{List: list, Total: total, Summary: *summary}, nil
|
||||
}
|
||||
|
||||
// CalendarDay 我的日报日历热力图单日状态。
|
||||
type CalendarDay struct {
|
||||
Date string `json:"date"`
|
||||
Status int8 `json:"status"` // 0草稿 1已提交
|
||||
Status int8 `json:"status"`
|
||||
ID uint64 `json:"id"`
|
||||
}
|
||||
|
||||
// CalendarResult 近期热力图数据(默认近三个月)。
|
||||
type CalendarResult struct {
|
||||
StartDate string `json:"start_date"`
|
||||
EndDate string `json:"end_date"`
|
||||
@@ -312,8 +296,6 @@ type CalendarResult struct {
|
||||
Days []CalendarDay `json:"days"`
|
||||
}
|
||||
|
||||
// Calendar 返回最近 months 个月(含本月)本人日报的逐日状态,供热力图按月/周渲染。
|
||||
// months 越界时回落到 3 个月。
|
||||
func Calendar(u *UserContext, months int) (*CalendarResult, error) {
|
||||
if months < 1 || months > 12 {
|
||||
months = 3
|
||||
@@ -343,8 +325,6 @@ func Calendar(u *UserContext, months int) (*CalendarResult, error) {
|
||||
}
|
||||
for i := range rows {
|
||||
res.Days = append(res.Days, CalendarDay{
|
||||
// DATE 列在 parseTime=true 下会带上时间与时区,必须归一化为 YYYY-MM-DD,
|
||||
// 否则前端按日期匹配热力图格子时永远匹配不到。
|
||||
Date: dateOnly(rows[i].ReportDate),
|
||||
Status: rows[i].Status,
|
||||
ID: rows[i].ID,
|
||||
@@ -357,7 +337,6 @@ func Calendar(u *UserContext, months int) (*CalendarResult, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// mineSummary 本月提交统计与今天的状态。
|
||||
func mineSummary(u *UserContext) (*MineSummary, error) {
|
||||
now := time.Now()
|
||||
monthStart := now.Format("2006-01") + "-01"
|
||||
@@ -386,7 +365,6 @@ func mineSummary(u *UserContext) (*MineSummary, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// GetDetail 读取日报详情;无权限时返回 403。
|
||||
func GetDetail(u *UserContext, id uint64) (*Detail, error) {
|
||||
report, err := loadReport(u.Tid, id)
|
||||
if err != nil {
|
||||
@@ -407,15 +385,12 @@ func GetDetail(u *UserContext, id uint64) (*Detail, error) {
|
||||
author := report.UserID == u.UID
|
||||
canEdit := author && report.Status == 0 && InWindow(report.ReportDate)
|
||||
canWithdraw := author && report.Status == 1 && InWindow(report.ReportDate)
|
||||
// 删除仅限草稿:已提交日报需先撤销提交才能删除。
|
||||
canDelete := report.Status == 0 && (u.IsAdmin || (author && InWindow(report.ReportDate)))
|
||||
|
||||
// 修改痕迹只对作者本人与租户管理员可见。
|
||||
histories := make([]HistoryItem, 0)
|
||||
if author || u.IsAdmin {
|
||||
histories, err = loadHistories(u.Tid, report.ID)
|
||||
if err != nil {
|
||||
// 痕迹表缺失或查询异常时降级为空,避免详情整体 500(部署时需执行 create_oa_dailyreport_history.sql)。
|
||||
histories = make([]HistoryItem, 0)
|
||||
}
|
||||
}
|
||||
@@ -431,8 +406,6 @@ func GetDetail(u *UserContext, id uint64) (*Detail, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Withdraw 撤销提交:把已提交日报退回草稿,并把本次提交的内容快照写入修改痕迹。
|
||||
// 仅作者本人、且日报在补写窗口内时可操作;撤销后需修改并重新提交。
|
||||
func Withdraw(u *UserContext, id uint64) (*ReportItem, error) {
|
||||
report, err := loadReport(u.Tid, id)
|
||||
if err != nil {
|
||||
@@ -484,16 +457,11 @@ func Withdraw(u *UserContext, id uint64) (*ReportItem, error) {
|
||||
return buildItem(report, count), nil
|
||||
}
|
||||
|
||||
// Delete 软删除日报及其评论:作者限补写窗口内,管理员不受限。
|
||||
//
|
||||
// 日报的 is_deleted 写入记录 ID(而非 1),既标记删除,又让唯一键
|
||||
// (tid, user_id, report_date, is_deleted) 在「删除后同一天重新填写」时不冲突。
|
||||
func Delete(u *UserContext, id uint64) error {
|
||||
report, err := loadReport(u.Tid, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 已提交日报锁定:不允许直接删除,需先撤销提交退回草稿。
|
||||
if report.Status == 1 {
|
||||
return errBad("日报已提交并锁定,请先撤销提交后再删除")
|
||||
}
|
||||
@@ -525,7 +493,6 @@ func Delete(u *UserContext, id uint64) error {
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
// AddComment 对已提交日报发表评论或回复;replyToID=0 表示直接评论。
|
||||
func AddComment(u *UserContext, reportID uint64, content string, replyToID uint64) (*Comment, error) {
|
||||
content = strings.TrimSpace(content)
|
||||
if content == "" {
|
||||
@@ -573,7 +540,6 @@ func AddComment(u *UserContext, reportID uint64, content string, replyToID uint6
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
// DeleteComment 软删除评论:评论作者本人或管理员。
|
||||
func DeleteComment(u *UserContext, commentID uint64) error {
|
||||
var row models.OaDailyReportComment
|
||||
if err := models.Orm.QueryTable(new(models.OaDailyReportComment)).
|
||||
@@ -589,8 +555,6 @@ func DeleteComment(u *UserContext, commentID uint64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// ========================== 内部工具 ==========================
|
||||
|
||||
func loadReport(tid, id uint64) (*models.OaDailyReport, error) {
|
||||
var report models.OaDailyReport
|
||||
if err := models.Orm.QueryTable(new(models.OaDailyReport)).
|
||||
@@ -600,12 +564,10 @@ func loadReport(tid, id uint64) (*models.OaDailyReport, error) {
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
// 统一成 YYYY-MM-DD,保证 InWindow 与前端日期比较正确。
|
||||
report.ReportDate = dateOnly(report.ReportDate)
|
||||
return &report, nil
|
||||
}
|
||||
|
||||
// canViewReport 本人 / 管理员 / 作者所在部门的主管;草稿仅本人与管理员可见。
|
||||
func canViewReport(u *UserContext, r *models.OaDailyReport) bool {
|
||||
if r.UserID == u.UID || u.IsAdmin {
|
||||
return true
|
||||
@@ -648,7 +610,6 @@ func buildComment(u *UserContext, r *models.OaDailyReportComment) Comment {
|
||||
}
|
||||
}
|
||||
|
||||
// hasWithdrawHistory 判断一条日报是否被撤销过提交,用于识别“重新提交”。
|
||||
func hasWithdrawHistory(tid, reportID uint64) bool {
|
||||
n, err := models.Orm.QueryTable(new(models.OaDailyReportHistory)).
|
||||
Filter("tid", tid).Filter("report_id", reportID).Filter("action", 1).
|
||||
@@ -656,7 +617,6 @@ func hasWithdrawHistory(tid, reportID uint64) bool {
|
||||
return err == nil && n > 0
|
||||
}
|
||||
|
||||
// loadHistories 读取一条日报的全部修改痕迹,按写入顺序返回。
|
||||
func loadHistories(tid, reportID uint64) ([]HistoryItem, error) {
|
||||
var rows []models.OaDailyReportHistory
|
||||
if _, err := models.Orm.QueryTable(new(models.OaDailyReportHistory)).
|
||||
@@ -720,7 +680,6 @@ func formatTime(t *time.Time) string {
|
||||
return t.Format("2006-01-02 15:04")
|
||||
}
|
||||
|
||||
// normalizeAttachments 校验并规范化附件 JSON,最多 20 个。
|
||||
func normalizeAttachments(raw string) (string, []Attachment, error) {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" || raw == "null" {
|
||||
@@ -752,7 +711,6 @@ func optionalDate(v string) (string, error) {
|
||||
return ParseDate(v)
|
||||
}
|
||||
|
||||
// countWhere 依次应用列值条件后计数。
|
||||
func countWhere(qs orm.QuerySeter, kv ...string) int64 {
|
||||
for i := 0; i+1 < len(kv); i += 2 {
|
||||
qs = qs.Filter(kv[i], kv[i+1])
|
||||
@@ -766,7 +724,6 @@ func commentCount(tid, reportID uint64) int {
|
||||
return counts[reportID]
|
||||
}
|
||||
|
||||
// commentCounts 批量统计评论数,避免列表逐条查询。
|
||||
func commentCounts(tid uint64, ids []uint64) map[uint64]int {
|
||||
out := make(map[uint64]int, len(ids))
|
||||
if len(ids) == 0 {
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// TeamQuery 团队日报汇总查询。
|
||||
type TeamQuery struct {
|
||||
Date string
|
||||
OrgID uint64
|
||||
@@ -19,15 +18,13 @@ type TeamQuery struct {
|
||||
PageSize int
|
||||
}
|
||||
|
||||
// TeamStats 团队提交统计。
|
||||
type TeamStats struct {
|
||||
Total int `json:"total"`
|
||||
Submitted int `json:"submitted"`
|
||||
Missing int `json:"missing"`
|
||||
Rate float64 `json:"rate"` // 提交率百分比,保留一位小数
|
||||
Rate float64 `json:"rate"`
|
||||
}
|
||||
|
||||
// TeamRow 团队汇总中的一名成员(仅包含当日已提交日报的成员)。
|
||||
type TeamRow struct {
|
||||
UserID uint64 `json:"user_id"`
|
||||
UserName string `json:"user_name"`
|
||||
@@ -36,13 +33,12 @@ type TeamRow struct {
|
||||
OrgName string `json:"org_name"`
|
||||
Submitted bool `json:"submitted"`
|
||||
ReportID uint64 `json:"report_id"`
|
||||
Status int8 `json:"status"` // 0草稿 1已提交(团队列表只返回 1)
|
||||
Status int8 `json:"status"`
|
||||
SubmitTime string `json:"submit_time"`
|
||||
HasIssue bool `json:"has_issue"`
|
||||
Summary string `json:"summary"` // 日报内容摘要(优先今日完成)
|
||||
Summary string `json:"summary"`
|
||||
}
|
||||
|
||||
// TeamResult 团队汇总结果。
|
||||
type TeamResult struct {
|
||||
Date string `json:"date"`
|
||||
List []TeamRow `json:"list"`
|
||||
@@ -50,7 +46,6 @@ type TeamResult struct {
|
||||
Stats TeamStats `json:"stats"`
|
||||
}
|
||||
|
||||
// OrgOption 团队筛选用的部门选项(前端按 parent_id 组装树)。
|
||||
type OrgOption struct {
|
||||
ID uint64 `json:"id"`
|
||||
ParentID uint64 `json:"parent_id"`
|
||||
@@ -58,9 +53,6 @@ type OrgOption struct {
|
||||
MemberCount int `json:"member_count"`
|
||||
}
|
||||
|
||||
// TeamStatus 团队日报日志池:只返回当日已提交的日报,未提交(含仅存草稿)的成员不展示。
|
||||
// 列表按提交时间倒序排列(按“谁发布了内容”展示,不按人分组),右侧根据选中项展示日报内容。
|
||||
// 管理员不选部门时统计全租户(含未分配部门的成员)。
|
||||
func TeamStatus(u *UserContext, q TeamQuery) (*TeamResult, error) {
|
||||
if !u.CanViewTeam {
|
||||
return nil, errForbidden("无权查看团队日报")
|
||||
@@ -104,7 +96,6 @@ func TeamStatus(u *UserContext, q TeamQuery) (*TeamResult, error) {
|
||||
return nil, errForbidden("你还没有管辖的部门")
|
||||
}
|
||||
|
||||
// 管辖范围内的成员:用于姓名/部门补全与提交统计,不受关键词与分页影响。
|
||||
memberCond := orm.NewCondition().
|
||||
And("tid", u.Tid).
|
||||
And("delete_time__isnull", true).
|
||||
@@ -147,8 +138,6 @@ func TeamStatus(u *UserContext, q TeamQuery) (*TeamResult, error) {
|
||||
rows = append(rows, row)
|
||||
}
|
||||
|
||||
// 作者不在成员表(成员已删除 / 组织映射异常)时用日报快照补齐,
|
||||
// 保证已提交的内容不会因人员变动而看不到。
|
||||
for uid, r := range reports {
|
||||
if r.Status != 1 {
|
||||
continue
|
||||
@@ -166,7 +155,6 @@ func TeamStatus(u *UserContext, q TeamQuery) (*TeamResult, error) {
|
||||
rows = append(rows, row)
|
||||
}
|
||||
|
||||
// 日志池排序:按发布时间(提交时间)倒序,最新提交排在最前。
|
||||
sort.SliceStable(rows, func(i, j int) bool {
|
||||
if rows[i].SubmitTime != rows[j].SubmitTime {
|
||||
return rows[i].SubmitTime > rows[j].SubmitTime
|
||||
@@ -182,7 +170,6 @@ func TeamStatus(u *UserContext, q TeamQuery) (*TeamResult, error) {
|
||||
stats.Rate = math.Round(float64(stats.Submitted)*1000/float64(stats.Total)) / 10
|
||||
}
|
||||
|
||||
// 列表分页:只对已提交的日报分页。
|
||||
total := len(rows)
|
||||
start := (q.Page - 1) * q.PageSize
|
||||
if start > total {
|
||||
@@ -195,7 +182,6 @@ func TeamStatus(u *UserContext, q TeamQuery) (*TeamResult, error) {
|
||||
return &TeamResult{Date: date, List: rows[start:end], Total: int64(total), Stats: stats}, nil
|
||||
}
|
||||
|
||||
// buildTeamRow 组装一条团队日报行;摘要取日报正文。
|
||||
func buildTeamRow(r *models.OaDailyReport, orgID uint64, userName, account, orgName string) TeamRow {
|
||||
return TeamRow{
|
||||
UserID: r.UserID,
|
||||
@@ -212,7 +198,6 @@ func buildTeamRow(r *models.OaDailyReport, orgID uint64, userName, account, orgN
|
||||
}
|
||||
}
|
||||
|
||||
// reportSummary 生成团队列表用的内容摘要(优先今日完成),超长截断。
|
||||
func reportSummary(r *models.OaDailyReport) string {
|
||||
for _, text := range []string{r.TodayDone, r.TomorrowPlan, r.Issues} {
|
||||
s := strings.TrimSpace(text)
|
||||
@@ -228,14 +213,12 @@ func reportSummary(r *models.OaDailyReport) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// matchTeamKeyword 按姓名/账号模糊匹配团队筛选项。
|
||||
func matchTeamKeyword(name, account, kw string) bool {
|
||||
kw = strings.ToLower(kw)
|
||||
return strings.Contains(strings.ToLower(name), kw) ||
|
||||
strings.Contains(strings.ToLower(account), kw)
|
||||
}
|
||||
|
||||
// TeamOrgs 返回团队筛选可选部门;管理员为全租户,主管仅自己管辖的部门子树。
|
||||
func TeamOrgs(u *UserContext) ([]OrgOption, error) {
|
||||
if !u.CanViewTeam {
|
||||
return nil, errForbidden("无权查看团队日报")
|
||||
@@ -287,7 +270,6 @@ func TeamOrgs(u *UserContext) ([]OrgOption, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// loadReportsByDate 一次取回某日全部已提交/草稿日报,按作者 uid 建索引。
|
||||
func loadReportsByDate(tid uint64, date string) (map[uint64]*models.OaDailyReport, error) {
|
||||
var rows []models.OaDailyReport
|
||||
if _, err := models.Orm.QueryTable(new(models.OaDailyReport)).
|
||||
|
||||
Reference in new issue
Block a user