Files
ticket-workbench/backend/internal/dto/common.go
绝尘 e94f160782 修复: 代码审查4个必改项+4个建议改进
- 工单编号改为业务格式 TK-yyMMdd-NNN
- 类型断言加 comma-ok 防 panic
- priority 用指针区分未传/P0
- json.Marshal 错误处理
- 提取 ParseID 公共函数消除重复
- HTTP client 包级别复用
- LIKE 查询特殊字符转义
- interface{} → any
- auth 中间件用 dto.Fail 统一响应
2026-05-13 19:01:06 +08:00

29 lines
697 B
Go

package dto
type Response struct {
Success bool `json:"success"`
Retcode int `json:"retcode"`
Retinfo string `json:"retinfo"`
Result any `json:"result,omitempty"`
}
func Success(data any) Response {
return Response{Success: true, Retcode: 0, Retinfo: "", Result: data}
}
func Error(code int, msg string) Response {
return Response{Success: false, Retcode: code, Retinfo: msg}
}
func Fail(msg string) Response {
return Response{Success: false, Retcode: -1, Retinfo: msg}
}
type UserSession struct {
Userid int `json:"userid"`
Username string `json:"username"`
Account string `json:"account"`
Role int16 `json:"role"`
Team string `json:"team"`
}