Skip to content

Company notice ce#585

Merged
iwanghc merged 4 commits intomainfrom
company-notice-ce
Mar 20, 2026
Merged

Company notice ce#585
iwanghc merged 4 commits intomainfrom
company-notice-ce

Conversation

@LordofAvernus
Copy link
Collaborator

@LordofAvernus LordofAvernus commented Mar 20, 2026

User description

关联的 issue

https://github.com/actiontech/dms-ee/issues/756

描述你的变更

公告功能优化

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 为公司公告新增起始与截止时间

  • 添加公告创建者显示字段

  • 更新 swagger API 定义和查询参数

  • 调整 controller、service 与 biz 层接口签名


Diagram Walkthrough

flowchart LR
  A["更新公告请求参数"]
  B["Controller层处理请求"]
  C["Service层传递参数"]
  D["Biz层处理公告实体"]
  A --> B
  B --> C
  C --> D
Loading

File Walkthrough

Relevant files
Enhancement
5 files
company_notice.go
增加公告起止时间、创建者名称及更新 swagger 参数                                                         
+19/-1   
dms_controller.go
调整公告查询逻辑,增加 include_latest_outside_period 参数                         
+27/-7   
company_notice.go
扩展公告实体,新增创建者 UID 和时间字段                                                                     
+7/-3     
company_notice_ce.go
修改企业版公告接口,更新函数签名参数                                                                             
+4/-3     
company_notice.go
更新公告服务接口,传递新增时间及查询参数                                                                         
+7/-5     
Documentation
2 files
swagger.json
更新 swagger json 定义,支持公告新字段及参数                                                       
+38/-0   
swagger.yaml
调整 swagger yaml 规范,增加公告相关的新字段                                                       
+30/-0   

@github-actions
Copy link

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

字段命名不一致

在公告相关的结构体中,新增加的字段在读取与更新接口中使用了不同的命名:读取返回的字段采用 "expire_time",而更新请求中使用 "end_time"。建议统一字段命名以减少混淆,并确保前后端逻辑一致。

	// notice show start time
	StartTime *time.Time `json:"start_time,omitempty"`
	// notice expire time
	ExpireTime *time.Time `json:"expire_time,omitempty"`
}

// swagger:model GetCompanyNoticeReply
type GetCompanyNoticeReply struct {
	Data CompanyNotice `json:"data"`

	// Generic reply
	base.GenericResp
}

// swagger:model
type UpdateCompanyNoticeReq struct {
	UpdateCompanyNotice UpdateCompanyNotice `json:"company_notice"  validate:"required"`
}

// A companynotice
type UpdateCompanyNotice struct {
	// companynotice info
	NoticeStr *string `json:"notice_str" validate:"required"`
	// notice show start time
	StartTime *time.Time `json:"start_time" validate:"required"`
	// notice show end time
	EndTime *time.Time `json:"end_time" validate:"required"`
时间校验缺失

在公告更新接口中直接将起始时间和截止时间传递给业务逻辑,建议增加时间范围的校验(例如确保起始时间早于截止时间),以防止潜在的业务错误。

func (d *DMSService) UpdateCompanyNotice(ctx context.Context, currentUserUID string, req *dmsV1.UpdateCompanyNoticeReq) (err error) {
	return d.CompanyNoticeUsecase.UpdateCompanyNotice(ctx, currentUserUID, req.UpdateCompanyNotice.NoticeStr, req.UpdateCompanyNotice.StartTime, req.UpdateCompanyNotice.EndTime)
}

@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
设置正确已读状态

建议根据实际业务逻辑设置 ReadByCurrentUser 的值,而不是直接固定为
false,以确保用户已读状态的准确性。请从正确的数据源获取已读标识,并将其赋值给返回数据。

internal/dms/service/company_notice.go [14-16]

+// 假设已经从业务逻辑中获取了 readStatus
+var readStatus bool = /* 通过业务逻辑判断用户是否已读 */
 data := dmsV1.CompanyNotice{
-    ReadByCurrentUser: false,
+    ReadByCurrentUser: readStatus,
 }
Suggestion importance[1-10]: 7

__

Why: 此建议改进了 ReadByCurrentUser 的赋值逻辑,确保它反映实际业务逻辑,而不是硬编码为 false,尽管改动较小,但能恢复原有基于业务判断的逻辑。

Medium

@iwanghc iwanghc merged commit d3362d0 into main Mar 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants