Skip to content

Company notice#584

Closed
LordofAvernus wants to merge 7 commits intomainfrom
company_notice_dev
Closed

Company notice#584
LordofAvernus wants to merge 7 commits intomainfrom
company_notice_dev

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文档及接口说明

  • 修正公告读取标识与过期时间传递


Diagram Walkthrough

flowchart LR
  A["新增公告时间字段"]
  B["更新接口参数传递"]
  C["更新Swagger文档"]
  A --> B
  B --> C
Loading

File Walkthrough

Relevant files
Enhancement
7 files
company_notice.go
更新公告接口增加时间字段参数                                                                                     
+17/-1   
dms_controller.go
更新控制器处理公告请求新增时间参数                                                                               
+22/-6   
company_notice.go
增加公告业务模型中的时间字段                                                                                     
+3/-0     
company_notice_ce.go
更新企业版公告接口增加时间参数                                                                                   
+4/-3     
company_notice.go
更新公告服务层传递时间字段                                                                                       
+6/-4     
convert.go
转换函数中增加公告时间字段转换                                                                                   
+4/-0     
model.go
模型中增加公告开始与结束时间字段                                                                                 
+2/-0     
Documentation
2 files
swagger.json
Swagger JSON中增加公告时间及参数说明                                                                 
+35/-2   
swagger.yaml
Swagger YAML中增加公告时间及参数定义                                                                 
+28/-2   

- Updated the CompanyNotice struct to include StartTime and EndTime fields for better notice management.
- Modified conversion functions to handle the new fields when converting between biz and model representations.
- Modified UpdateCompanyNotice to accept startTime and endTime parameters for enhanced notice management.
- Adjusted GetCompanyNotice to return only the notice and error, removing the exist boolean for clarity.
…clude ExpireTime

- Adjusted GetCompanyNotice to always set ReadByCurrentUser to false.
- Added ExpireTime to the response data from GetCompanyNotice.
- Updated UpdateCompanyNotice to accept startTime and endTime parameters for improved notice management.
- Added ExpireTime field to CompanyNotice for notice expiration management.
- Updated UpdateCompanyNotice to require StartTime and EndTime fields for better validation and notice display control.
…nyNotice

- Introduced StartTime field to the CompanyNotice struct for better notice management.
- Updated GetCompanyNotice to include StartTime in the response data.
- Added IncludeLatestOutsidePeriod query parameter to GetCompanyNotice for returning the latest notice regardless of display time window.
- Updated GetCompanyNotice method to handle the new parameter and modified related service and usecase methods accordingly.
- Improved Swagger documentation to reflect the changes in the API endpoint.
@github-actions github-actions bot changed the title Company notice Company notice Mar 20, 2026
@github-actions
Copy link

PR Reviewer Guide 🔍

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

字段命名不一致

在公告相关代码中,API 层的公告结构体采用了 start_timeexpire_time 字段,而业务逻辑和存储层中则使用了 start_timeend_time。建议统一时间字段的命名(比如统一为 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"`

@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
校验公告时间顺序

在新增的公告更新接口中,StartTimeEndTime 字段未进行时间先后校验,可能会导致错误的时间配置并引发系统异常。建议在调用业务逻辑前增加判断,确保
StartTimeEndTime 之前,以避免数据错误和意外的运行时错误。

internal/dms/service/company_notice.go [28]

+if req.UpdateCompanyNotice.StartTime.After(*req.UpdateCompanyNotice.EndTime) {
+	return errors.New("start time must be before end time")
+}
 return d.CompanyNoticeUsecase.UpdateCompanyNotice(ctx, req.UpdateCompanyNotice.NoticeStr, req.UpdateCompanyNotice.StartTime, req.UpdateCompanyNotice.EndTime)
Suggestion importance[1-10]: 6

__

Why: The suggestion adds a validation to ensure StartTime is before EndTime before calling the update logic, which can prevent runtime errors due to incorrect time configurations. However, it is an incremental improvement rather than addressing a critical bug.

Low

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.

1 participant