Code Monkey home page Code Monkey logo

Comments (5)

LyricTian avatar LyricTian commented on May 18, 2024

这个不是bug,像你说的,为了解决gorm批量更新字段时,零值字段不更新的问题。你说的用户密码的情况是种特殊情况,类似这种特殊情况可以不指定指针,这块可以按照具体业务需求来确定。

from gin-admin.

lchjczw avatar lchjczw commented on May 18, 2024

哦,这样哈,我使用的场景下,有很多会涉及到只修改其中一两个字段,我这边新增的业务逻辑里面,已经改成update可以只传其中任意字段,只修改传的这部分参数,有些字段不希望在前端展示

from gin-admin.

lchjczw avatar lchjczw commented on May 18, 2024

还有个bll中和model中,的接口部分,参数都不用指针,返回值用指针,这个为啥,都用指针不是更好吗

from gin-admin.

LyricTian avatar LyricTian commented on May 18, 2024

参数作为指针,我考虑的原因有两个,一是传递指针你需要在使用参数值时进行空指针判定,否则会引起panic,而是指针作为引用传递,函数内部更改指针的值会引起外部的数据变化,外部使用时可能会出现数据混乱的情况;返回值作为指针就好理解了,如果出现错误,我们都希望以nil作为返回值输出,而不是空的结构体。

from gin-admin.

lchjczw avatar lchjczw commented on May 18, 2024

嗯,谢谢

from gin-admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.