Skip to content

Conversation

@7ac9d42
Copy link
Contributor

@7ac9d42 7ac9d42 commented Sep 29, 2025

欸 拉了一坨大的,操作失误了本地搞的一团遭
可以的话需要仔细审计(本地跑了单元测试看起来没有问题)
另外是你改了错误描述吗?我不能确定每一个错误用对地方了,不确定的地方留了TODO,可以的话看一眼
欸 这波真是写了一坨屎😨

@dsx137 dsx137 force-pushed the workspace/7ac9d42 branch 2 times, most recently from 3905a38 to 4dadfc0 Compare September 29, 2025 09:03
Copy link
Contributor

@dsx137 dsx137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看一下


// NewMultiStatusResponse 创建207 Multi-Status响应
// 这不是真正的错误,而是用来通过gggin框架返回207状态码的机制
func NewMultiStatusResponse[T any](data T) *gggin.HttpError {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样,不用这个
返回200和207的时候只有statuscode的不同
返回的对象都统一改成更改失败的对象列表

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果有你写的这个需求我选择更改gggin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果有你写的这个需求我选择更改gggin

你有更好的改法了吗?spring怎么写的?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果有你写的这个需求我选择更改gggin

你有更好的改法了吗?spring怎么写的?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是,我意思是把这个json序列化写进gggin
哦哦我知道你迷茫在哪了,就是说gggin固定返回200改不了是吧,你看把httpcode存进gin context怎么样

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image image

或者是这样,你觉得哪种好?

Copy link
Contributor Author

@7ac9d42 7ac9d42 Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉 哪个简洁哪个好(
都是泛型差不了多少

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我推了,你看一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

别急 家里来亲戚我都没地儿睡了,环境太恶劣之后再看😰

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我推了,你看一下

感觉可以

@7ac9d42 7ac9d42 force-pushed the workspace/7ac9d42 branch from 4dadfc0 to 20bf96b Compare October 1, 2025 07:15
@7ac9d42
Copy link
Contributor Author

7ac9d42 commented Oct 1, 2025

现在再看看呢?207返回那一块儿还没想好怎么改

Copy link
Contributor

@dsx137 dsx137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看一下


// NewMultiStatusResponse 创建207 Multi-Status响应
// 这不是真正的错误,而是用来通过gggin框架返回207状态码的机制
func NewMultiStatusResponse[T any](data T) *gggin.HttpError {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


如何?

@dsx137
Copy link
Contributor

dsx137 commented Oct 15, 2025

不是啊bro怎么又interface代替思考了,NewResponseWithStatusCode没用吗?
另外尽量在这个框架下少些不兼容的特性,比如说datawitherror这种,如果实在有需求再写到gggin。
尽量保证成功返回只有一种类型
你实在难受可以定义一个
{
result
data
}

类型然后作为responsetype返回嘛

哎哟真是interface代替思考了

@7ac9d42
Copy link
Contributor Author

7ac9d42 commented Oct 15, 2025

不是啊bro怎么又interface代替思考了,NewResponseWithStatusCode没用吗? 另外尽量在这个框架下少些不兼容的特性,比如说datawitherror这种,如果实在有需求再写到gggin。 尽量保证成功返回只有一种类型 你实在难受可以定义一个 {结果数据 }

类型然后作为responsetype返回嘛

哎呀真是用 interface 代替思考了

什么跟什么这是 我只说是gggin感觉可以 别的我啥都还没改啊

@dsx137
Copy link
Contributor

dsx137 commented Oct 15, 2025

哦那没事了

revert:恢复dev分支错误相关提交

新增支持通过 CSV 文件批量注册用户的功能,以及批量修改用户账号类型和角色的功能。
- 添加接口用于批量注册用户,并使用Content-Type区分单个与批量注册请求
- 添加 `/api/users/category` 和 `/api/users/role` 接口用于批量修改用户属性
- 引入 207 Multi-Status 响应机制处理部分失败的批量操作
- 更新错误处理逻辑,细化多种业务错误类型
- 完善 Swagger 文档,补充新接口的定义和说明
- README 中增加新功能使用说明及快速上手示例
Copy link
Contributor

@dsx137 dsx137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

}

// handleBatchRegisterFromCSV 处理CSV文件批量注册
func (ctl *ControllerUser) handleBatchRegisterFromCSV(c *gin.Context) (*gggin.Response[any], *gggin.HttpError) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这东西放service

var result BatchModifyResult
result.Total = len(req.UserIds)

for _, uid := range req.UserIds {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这也是,放service,所有稍微复杂的逻辑处理都放service

g.PUT("/:uid/category", security.GuardMiddleware(security.RoleAdmin), gggin.ToGinHandler(ctl.HandleModifyCategory))
g.PUT("/:uid/role", security.GuardMiddleware(security.RoleAdmin), gggin.ToGinHandler(ctl.HandleModifyRole))
g.PATCH("/category", security.GuardMiddleware(security.RoleAdmin), gggin.ToGinHandler(ctl.HandleBatchModifyCategory))
g.PATCH("/role", security.GuardMiddleware(security.RoleAdmin), gggin.ToGinHandler(ctl.HandleBatchModifyRole))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我想了一下,现在这么写还是要写any,然后go又没有协变,子函数也不好写返回类型,要拆包
那不如这样

/users/_bulk 代表批量操作根
POST /users/_bulk 批量注册
PATCH /users/_bulk/category 批量修改种类

如果,假如说以后如果users属性多了,那直接PATCH /users/_bulk,传user对象好了,现在暂时先一个属性一个属性的写着

合适吗

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.

3 participants