{"id":152611,"date":"2020-09-07T03:10:27","date_gmt":"2020-09-06T19:10:27","guid":{"rendered":"http:\/\/4563.org\/?p=152611"},"modified":"2020-09-07T03:10:27","modified_gmt":"2020-09-06T19:10:27","slug":"%e6%96%b0%e6%89%8b%e6%8f%90%e9%97%ae%ef%bc%9a-gingorm-%e4%b8%ad%e5%a4%a7%e5%9e%8b%e9%a1%b9%e7%9b%ae%e5%88%86%e5%b1%82%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=152611","title":{"rendered":"\u65b0\u624b\u63d0\u95ee\uff1a gin+gorm \u4e2d\u5927\u578b\u9879\u76ee\u5206\u5c42\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u65b0\u624b\u63d0\u95ee\uff1a gin+gorm \u4e2d\u5927\u578b\u9879\u76ee\u5206\u5c42\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mzmxcvbn <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u6700\u8fd1\u5728\u770b gin\uff0c\u611f\u89c9\u5bf9\u4e2d\u5927\u578b\u9879\u76ee\u7684\u7ed3\u6784\u89c4\u5212\u6709\u70b9\u6a21\u7cca\u3002<br \/>\u5728 github \u4e0a\u770b\u4e86\u4e00\u4e9b\u4f8b\u5b50\uff0c\u6309\u6211\u73b0\u5728\u7684\u7406\u89e3\u5206\u5c42\uff1a<\/p>\n<p>controller &#8212; \u8bf7\u6c42\u5165\u53e3\uff0c\u53c2\u6570\u6821\u9a8c\uff0c\u8c03\u7528 server\uff0c\u8fd4\u56de\u9519\u8bef\u6216\u54cd\u5e94<br \/>server &#8212; \u63a5\u6536\u5df2\u9a8c\u8bc1\u53c2\u6570\uff0c\u5b9e\u73b0\u5177\u4f53\u4e1a\u52a1\u903b\u8f91\uff0c\u8c03\u7528 dao\uff0c\u8fd4\u56de\u7ed3\u679c<br \/>dao &#8212; \u6240\u6709\u4e0e\u6570\u636e\u5e93\u76f8\u5173\u7684\u64cd\u4f5c<br \/>model &#8212; \u5b9a\u4e49 struct \u4ee5\u7528\u4e8e orm \u6620\u5c04<\/p>\n<p>\u4e0d\u77e5\u9053\u6211\u7684\u7406\u89e3\u662f\u5426\u6b63\u786e\uff0c\u540c\u65f6\uff0c\u6211\u8fd8\u6709\u4e0b\u9762\u4e00\u4e9b\u7591\u60d1\uff1a<br \/>1\uff1adao \u5c42\u7684\u4f5c\u7528\uff1f\u6211\u5728\u7f51\u4e0a\u770b\u7684\u4f8b\u5b50\u6709\u4e00\u4e9b\u6709 dao \u5c42\uff0c\u540c\u65f6\u4e5f\u6709\u5f88\u5927\u4e00\u90e8\u5206\u6ca1\u6709\u8fd9\u5c42\uff0cserver \u5c42\u7684\u4ee3\u7801\u4e2d\u76f4\u63a5\u8c03\u7528 orm \u589e\u5220\u6539\u67e5\u7684\u65b9\u6cd5\u3002\u5982\u679c server \u4e2d\u6bcf\u6b21\u8981\u7528\u5230\u6570\u636e\u5e93\u7684\u5730\u65b9\u751a\u81f3\u53ea\u662f\u53c2\u6570\u7a0d\u6709\u4e0d\u540c\uff0c\u5c31\u8981\u5728 dao \u4e2d\u5199\u4e00\u4e2a\u5bf9\u5e94\u7684\u51fd\u6570\uff0c\u5c82\u4e0d\u662f\u4f1a\u5f88\u7e41\u7410\u3002\u800c\u4e14\u6211\u89c9\u5f97\u5bf9\u4e8e\u50cf CreateTag \u8fd9\u79cd\u7b80\u5355\u65b9\u6cd5\uff0corm \u4e5f\u662f\u76f4\u63a5\u4e00\u884c\u8bed\u53e5\u5c31\u80fd\u5b9e\u73b0\uff0c\u518d\u5355\u72ec\u5305 dao \u8fd9\u4e00\u5c42\u4ed6\u7684\u4f18\u52bf\u662f\u4ec0\u4e48\u3002<br \/>2\uff1aserver \u5c42\u7684\u5199\u6cd5\uff1f\u6211\u73b0\u5728\u7684\u7406\u89e3\u662f\u6709\u51e0\u4e2a controller \u5c31\u8981\u5199\u51e0\u4e2a\u5bf9\u5e94\u7684 server\uff0c\u6bd4\u5982\u6709 CreateTag, ListTag, UpdateTag, DeleteTag, CreatePost, ListPost, UpdatePost, DeletePost \u8fd9 8 \u4e2a controller \u662f\u4e0d\u662f\u5c31\u8981\u5199 8 \u4e2a\u5bf9\u5e94\u7684 server\uff0c\u90a3\u62c6\u5206\u51fa server \u5c42\u7684\u76ee\u7684\u4ec5\u4ec5\u5c31\u662f\u4e0d\u8ba9\u4e1a\u52a1\u903b\u8f91\u90fd\u5806\u5728 controller \u5417\uff0c\u6211\u5728\u7f51\u4e0a\u6709\u770b\u5230\u8bf4 server \u5c42\u53ef\u4ee5\u91cd\u7528\u4ee3\u7801\uff0c\u4f46\u8fd9\u6837\u6bcf\u52a0\u4e00\u4e2a controller \u5c31\u8981\u52a0\u4e00\u4e2a server \u7684\uff0c\u8be5\u600e\u4e48\u4f53\u73b0\u91cd\u7528<\/p>\n<p>\u521a\u770b\u5b8c\u4ee3\u7801\uff0c\u8111\u5b50\u6709\u70b9\u4e71\uff0c\u8fd8\u5e0c\u671b\u6709\u5927\u795e\u80fd\u89e3\u7b54\u6211\u7684\u7591\u60d1      <\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>23<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3198117\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xkeyideal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bf7\u628a Java \u90a3\u5957\u574f\u4e60\u60ef\u6539\u6389\u5427\uff0cgo \u4e0d\u9002\u5408\u8fd9\u5957                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198118\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rimutuyuan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/github.com\/whjstc\/openbilibili-go-common-1                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198119\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : mzmxcvbn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xkeyideal \u6211\u4e5f\u6ca1\u5199\u8fc7 JAVA\uff0c\u53ea\u662f\u770b\u7f51\u4e0a\u5927\u90e8\u5206\u4f8b\u5b50\u90fd\u662f\u8fd9\u4e48\u5212\u5206\uff0c\u6709\u4ec0\u4e48\u597d\u7684 gin \u7684\u9879\u76ee\u7ed3\u6784\u63a8\u8350\u7684\u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198120\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vipppppp <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u8981\u4ec0\u4e48\u90fd\u5e26\u5165 java\uff0c\u8981\u8fd9\u4e48\u5199\u7528 java \u4e0d\u597d\u5417<br \/>go \u7684\u5927\u591a\u6570\u4eba\u8ba4\u53ef\u7684\u9879\u76ee\u89c4\u8303\uff1a<br \/>https:\/\/github.com\/golang-standards\/project-layout                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198121\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : bintianbaihua <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u53c2\u8003\u4e0b\u8fd9\u4e2a https:\/\/github.com\/bxcodec\/go-clean-arch                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198122\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gowk <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6b63\u5728\u63a2\u7d22\u4e2d\uff0c\u5173\u6ce8\u4e00\u4e0b\u8fd9\u4e2a\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198123\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : mzmxcvbn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @vipppppp \u8c22\u8c22\u56de\u590d\uff0c\u6211\u6ca1\u5199\u8fc7 JAVA\uff0c\u6211\u4e4b\u524d\u7528 python\/flask \u5199\u5c0f\u9879\u76ee\u7684\u65f6\u5019\u662f\u6700\u7b80\u5355\u7684\u53ea\u5206\u4e86 model \u548c controller\uff0c\u4f46\u6211\u611f\u89c9\u5bf9\u4e8e\u5927\u578b\u9879\u76ee\uff0c\u8fd9\u6837\u53ef\u80fd\u4e0d\u592a\u597d\uff0c\u6240\u4ee5\u73b0\u5728\u8f6c\u5230 go \u5e0c\u671b\u80fd\u627e\u5230\u66f4\u597d\u7684\u9879\u76ee\u7ed3\u6784\u65b9\u6848\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198124\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xkeyideal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @mzmxcvbn go \u6bd4\u8f83\u968f\u610f\uff0c\u5199 web \u9879\u76ee\u6211\u4e00\u822c\u5f00 config, engine, httphandle, service, storage \u51e0\u4e2a\u76ee\u5f55\uff0c\u4e5f\u4e0d\u7edd\u5bf9\uff0c\u6839\u636e\u9879\u76ee\u6765\uff0c\u7f51\u4e0a\u6709\u4e00\u4e9b\u5efa\u8bae\u7684\u76ee\u5f55\u7ec4\u7ec7\u65b9\u5f0f\uff0c\u627e\u4e00\u4e2a\u9002\u5408\u81ea\u5df1\u7684\u5c31\u884c\uff0c\u9879\u76ee\u5199\u591a\u4e86\uff0c\u5c31\u80fd\u627e\u5230\u4e00\u4e2a\u6bd4\u8f83\u5408\u9002\u81ea\u5df1\u7684\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198125\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xgfan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1\uff0c\u662f Service\uff0c\u800c\u4e0d\u662f Server<br \/>2\uff0c\u4e09\u5c42\u67b6\u6784\u4e0d\u662f Java \u72ec\u6709\u7684\uff0c\u800c\u4e14\u8c08\u4e0d\u4e0a\u81c3\u80bf\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198126\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : windyboy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5c42\u592a\u591a\uff0c\u5fd8\u8bb0\u4e86\u8bfb\u6570\u636e\u5e93\u5176\u5b9e\u53ea\u9700\u8981\u5199\u597d sql                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198127\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dongisking <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u5230 dao \u5c31\u77e5\u9053\u4e0b\u9762\u6709\u5565\u8bc4\u8bba                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198128\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : basefas <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f9b\u53c2\u8003 https:\/\/github.com\/basefas\/service-gin                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198129\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dongisking <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/github.com\/eddycjy\/go-gin-example                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198130\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : linxl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u51e0\u4e4e\u4e5f\u662f\u8fd9\u4e48\u5206\u76ee\u5f55\u7684, \u4e3b\u8981\u662f\u6ca1\u89c9\u5f97\u6709\u5565\u95ee\u9898&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198131\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lix7 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             dao \u8fd8\u662f\u8981\u6709\u7684\uff0c\u672a\u6765\u5982\u679c\u9700\u8981\u5728 data load \u8fd9\u4e2a\u5207\u9762\u505a\u4e8b\u60c5\u7684\u8bdd\uff0c\u6ca1\u6709\u5355\u72ec\u5206\u5c42\u800c\u662f\u201cserver \u5c42\u7684\u4ee3\u7801\u4e2d\u76f4\u63a5\u8c03\u7528 orm \u589e\u5220\u6539\u67e5\u7684\u65b9\u6cd5\u3002\u201d\u4f1a\u5bfc\u81f4\u6539\u8d77\u6765\u5f88\u9ebb\u70e6\u3002\u5f53\u4e1a\u52a1\u5927\u5230\u4e00\u5b9a\u7a0b\u5ea6\u5c31\u6ca1\u6cd5\u6539\u4e86\u3002<br \/>\u5176\u5b9e\u5982\u679c\u8fd8\u5904\u4e8e\u5bf9\u6027\u80fd\u8981\u6c42\u4e0d\u9ad8\u7684\u9636\u6bb5\uff0cdao \u5c42\u53ef\u4ee5\u5f88\u7b80\u5355\uff0c\u53ea\u6709 list \u3001load \u3001save \u4e09\u4e2a\u65b9\u6cd5\u3002<\/p>\n<p>\u81f3\u4e8e controller \u548c service\uff0c\u6211\u89c9\u7740\u786e\u5b9e\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u53ef\u4ee5\u5408\u5e76\u3002\u73b0\u9636\u6bb5\u5927\u90e8\u5206\u5199\u4e8b\u52a1\u811a\u672c\u7684\u4e1a\u52a1\uff0cservice \u590d\u7528\u7684\u673a\u4f1a\u4e0d\u591a\u3002\u80fd\u590d\u7528\u7684\u8bdd\u4e5f\u90fd\u4f1a\u62bd\u6210\u5355\u72ec\u7684\u5b50\u51fd\u6570\u3002<\/p>\n<p>\u5efa\u8bae\u4e3b\u5b9e\u8df5\u4e0b ddd\uff0c\u4ee3\u7801\u5199\u51fa\u6765\u4f1a\u5f88\u6e05\u6670\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198132\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : pigzzz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5efa\u8bae\u4e3b\u628a dao \u6362\u6210 repository \u5173\u952e\u5b57\uff0c\u5c31\u4e0d\u4f1a\u88ab\u90a3\u4e9b\u53cd java \u7684\u4eba\u55b7\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198133\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Yoock <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709 dao \u6ca1\u6bdb\u75c5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198134\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vipppppp <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5efa\u8bae\u4e3b\u4e0d\u8981\u6309 java \u7684\u5199\u6cd5\u5c31\u88ab\u6253\u6210\u53cd java \u548c\u55b7\u4e3b\uff0c\u6211\u662f\u670d\u4e86<br \/>\u6211\u60f3\u6ca1\u51e0\u4e2a\u5f00\u6e90\u5927\u9879\u76ee\u7684 go \u6216\u8005 python \u6309\u7167\u8fd9\u6837\u5199\u7684<br \/>\u53ea\u662f\u89c9\u5f97\u8bed\u8a00\u7684\u7279\u6027\u4e0d\u540c\uff0c\u6709\u65f6\u5957\u7740\u5199\u4f1a\u663e\u5f97\u5f88\u7d2f\u8d58                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198135\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : frozenshadow <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @mzmxcvbn 5L @bintianbaihua \u63a8\u8350\u7684\u8fd9\u4e2a\u7ed3\u6784\u5f88\u68d2\uff0c\u8fd9\u4e2a\u8001\u54e5\u7684\u51e0\u7bc7\u76f8\u5173\u535a\u5ba2\u4e5f\u503c\u5f97\u4e00\u8bfb                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198136\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Yuiham <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5355\u4f53\u5e94\u7528\u7684\u9879\u76ee\u4e0a\u6574\u6d01\u67b6\u6784                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198137\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : EminemW <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u5206 controller \u8ddf service \u7684\u8bdd\uff0ccontroller \u5c42\u505a\u53c2\u6570\u6821\u9a8c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198138\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : mzmxcvbn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lix7 \u8c22\u8c22\u56de\u590d\uff01\u6211\u8fd8\u60f3\u8bf7\u6559\u4e00\u4e0b\u6709\u5173 dao \u5c42\u7684\u95ee\u9898\uff1a1.\u5982\u679c\u540e\u7eed\u9879\u76ee\u9664\u4e86 mysql \u8fd8\u8981\u7528\u5230 mongodb \u6216\u8005 redis \u7684\u8bdd\uff0c\u662f\u4e0d\u662f\u76f8\u5173\u64cd\u4f5c\u4e5f\u90fd\u653e\u5728 dao \u5c42\u30022.dao \u5c42\u91cc\u5177\u4f53\u5b9e\u73b0\u662f\u5bf9\u6bcf\u4e00\u4e2a model \u90fd\u8981\u5199\u81ea\u5df1\u7684 list \u3001load \u3001save \u51fd\u6570\u5417\uff0c\u800c\u4e14\u5bf9\u4e0e list\uff0c\u6211\u53ef\u80fd\u4f1a\u6709\u597d\u591a\u5730\u65b9\u7528\u5230\uff0c\u4f46\u53c2\u6570\u6761\u4ef6\u53ef\u80fd\u90fd\u4e0d\u540c\uff0c\u6bd4\u5982\u6709\u4e9b\u8981\u591a\u4e2a where\uff0c\u6709\u4e9b\u8981 order by\uff0c\u6709\u4e9b\u8981 limit\uff0c\u8fd9\u662f\u4e0d\u662f\u6bcf\u7528\u5230\u4e00\u4e2a\u4e0d\u4e00\u6837\u7684\uff0c\u867d\u7136\u90fd\u662f list\uff0c\u4f46\u90fd\u8981\u518d\u52a0\u4e00\u4e2a\u51fd\u6570\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3198139\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lix7 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @mzmxcvbn <br \/>1. \u90fd\u653e\u5728\u4e00\u5c42 dao \u91cc\uff0c\u53eb\u4ec0\u4e48\u4e0d\u91cd\u8981\uff0c\u91cd\u8981\u7684\u8fd9\u5c42\u53ea\u8d1f\u8d23\u6570\u636e\u7684\u52a0\u8f7d\u548c\u4fdd\u5b58\uff0c\u4f60\u53ea\u9700\u8981\u8c03\u7528\u6807\u51c6\u63a5\u53e3\uff0c\u4e0d\u9700\u8981\u5173\u5fc3\u5b58\u50a8\u7ec6\u8282\uff1b<br \/>2. \u4ece DDD \u7684\u89d2\u5ea6\u6765\u8bb2\uff0c\u6bcf\u4e00\u4e2a\u805a\u5408\u6839\u5bf9\u5e94\u4e00\u4e2a DAO \uff08 DDD \u91cc\u53eb repository \uff09\u3002\u4f46\u5982\u679c\u53ea\u4ece\u5206\u5c42\u89d2\u5ea6\u6765\u8003\u8651\u7684\u8bdd\uff0c\u662f\u7684\uff0c\u6bcf\u4e00\u4e2a model \u5bf9\u5e94\u4e00\u4e2a dao \uff1b<br \/>3. \u5bf9\u4e8e list \u63a5\u53e3\uff0c\u4f60\u81ea\u5df1\u5df2\u7ecf\u63d0\u5230\u4e86\uff0cwhere\/order by\/limit \u90fd\u53ea\u662f\u201c\u53c2\u6570\u6761\u4ef6\u201d\uff0c\u6240\u4ee5\u4ed6\u4eec\u53ea\u662f\u4e00\u4e2a\u5927\u63a5\u53e3\u7684\u53c2\u6570\u800c\u5df2\uff0c\u8fd9\u4e2a\u63a5\u53e3\u7684\u57fa\u7840\u529f\u80fd\uff0c\u5c31\u53ea\u662f list\uff0c\u81f3\u4e8e\u600e\u4e48 list \u3001list \u591a\u5c11\u4e2a\u4e1c\u897f\u51fa\u6765\u3001\u987a\u5e8f\u662f\u5565\u6837\u7684\uff0c\u53ea\u662f\u53c2\u6570\u800c\u5df2                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u624b\u63d0\u95ee\uff1a gin+gorm \u4e2d\u5927&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/152611"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152611"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/152611\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152611"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}