{"id":56226,"date":"2025-08-14T15:04:49","date_gmt":"2025-08-14T07:04:49","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/56226.html"},"modified":"2025-08-14T15:04:49","modified_gmt":"2025-08-14T07:04:49","slug":"mapper%e5%92%8cservice%e7%9a%84%e5%b7%a5%e4%bd%9c%e6%b5%81%e7%a8%8b%e6%98%af%e6%80%8e%e6%a0%b7%e7%9a%84%ef%bc%9f%ef%bc%88%e9%80%9a%e4%bf%97%e6%98%93%e6%87%82%e7%89%88%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/56226.html","title":{"rendered":"Mapper\u548cService\u7684\u5de5\u4f5c\u6d41\u7a0b\u662f\u600e\u6837\u7684\uff1f\uff08\u901a\u4fd7\u6613\u61c2\u7248\uff09"},"content":{"rendered":"<p>Mapper \u548c Service \u7684\u5de5\u4f5c\u6d41\u7a0b\u5c31\u50cf\u5de5\u5382\u91cc\u7684\u201c\u539f\u6750\u6599\u91c7\u8d2d\u201d\u548c\u201c\u4ea7\u54c1\u52a0\u5de5\u201d\u73af\u8282&#xff0c;\u914d\u5408\u8d77\u6765\u5b8c\u6210\u4ece\u201c\u6570\u636e\u83b7\u53d6\u201d\u5230\u201c\u4e1a\u52a1\u5b9e\u73b0\u201d\u7684\u5168\u6d41\u7a0b&#xff0c;\u5177\u4f53\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u51e0\u6b65&#xff1a;<\/p>\n<h4>\u5b8c\u6574\u5de5\u4f5c\u6d41\u7a0b&#xff08;\u4ee5\u201c\u7528\u6237\u5206\u9875\u67e5\u8be2\u201d\u4e3a\u4f8b&#xff09;&#xff1a;<\/h4>\n<h5>1. \u524d\u7aef\u53d1\u8d77\u8bf7\u6c42<\/h5>\n<p>\u7528\u6237\u5728\u7f51\u9875\u4e0a\u70b9\u51fb\u201c\u67e5\u770b\u7b2c2\u9875\u7528\u6237&#xff0c;\u6bcf\u987510\u6761\u201d&#xff0c;\u524d\u7aef\u628a\u8bf7\u6c42&#xff08;pageNum&#061;2&amp;pageSize&#061;10&#xff09;\u53d1\u7ed9\u540e\u7aef\u7684 Controller&#xff08;\u63a7\u5236\u5668&#xff09;\u3002<\/p>\n<h5>2. Controller \u63a5\u6536\u8bf7\u6c42&#xff0c;\u8c03\u7528 Service<\/h5>\n<p>Controller \u50cf\u201c\u8c03\u5ea6\u5458\u201d&#xff0c;\u6536\u5230\u8bf7\u6c42\u540e\u4e0d\u505a\u5177\u4f53\u5904\u7406&#xff0c;\u76f4\u63a5\u628a\u4efb\u52a1\u4ea4\u7ed9 Service&#xff08;\u4e1a\u52a1\u5c42&#xff09;&#xff1a;<\/p>\n<p><span class=\"token annotation punctuation\">&#064;Controller<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">UserController<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">UserService<\/span> userService<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u63a5\u6536\u5206\u9875\u67e5\u8be2\u8bf7\u6c42<\/span><br \/>\n    <span class=\"token annotation punctuation\">&#064;GetMapping<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\/users&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token class-name\">String<\/span> <span class=\"token function\">getUsers<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">Integer<\/span> pageNum<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">Integer<\/span> pageSize<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">Model<\/span> model<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u8c03\u7528 Service \u5904\u7406\u4e1a\u52a1<\/span><br \/>\n        <span class=\"token class-name\">PageInfo<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">User<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> pageInfo <span class=\"token operator\">&#061;<\/span> userService<span class=\"token punctuation\">.<\/span><span class=\"token function\">findByPage<\/span><span class=\"token punctuation\">(<\/span>pageNum<span class=\"token punctuation\">,<\/span> pageSize<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u628a\u7ed3\u679c\u4f20\u7ed9\u89c6\u56fe\u5c55\u793a<\/span><br \/>\n        model<span class=\"token punctuation\">.<\/span><span class=\"token function\">addAttribute<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;pageInfo&#034;<\/span><span class=\"token punctuation\">,<\/span> pageInfo<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token string\">&#034;userList&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h5>3. Service \u5904\u7406\u4e1a\u52a1\u903b\u8f91&#xff0c;\u8c03\u7528 Mapper \u83b7\u53d6\u539f\u59cb\u6570\u636e<\/h5>\n<p>Service \u50cf\u201c\u52a0\u5de5\u8f66\u95f4\u201d&#xff0c;\u5148\u505a\u4e1a\u52a1\u5224\u65ad&#xff0c;\u518d\u8c03\u7528 Mapper \u62ff\u201c\u539f\u6750\u6599\u201d&#xff08;\u6570\u636e\u5e93\u539f\u59cb\u6570\u636e&#xff09;&#xff1a;<\/p>\n<p><span class=\"token annotation punctuation\">&#064;Service<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">UserServiceImpl<\/span> <span class=\"token keyword\">implements<\/span> <span class=\"token class-name\">UserService<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">UserMapper<\/span> userMapper<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u4f9d\u8d56 Mapper<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Override<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token class-name\">PageInfo<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">User<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> <span class=\"token function\">findByPage<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">Integer<\/span> pageNum<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">Integer<\/span> pageSize<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u4e1a\u52a1\u5904\u74061&#xff1a;\u6821\u9a8c\u53c2\u6570&#xff08;\u6bd4\u5982\u9875\u7801\u4e0d\u80fd\u5c0f\u4e8e1&#xff09;<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>pageNum <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token keyword\">null<\/span> <span class=\"token operator\">||<\/span> pageNum <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            pageNum <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>pageSize <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token keyword\">null<\/span> <span class=\"token operator\">||<\/span> pageSize <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            pageSize <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u4e1a\u52a1\u5904\u74062&#xff1a;\u521d\u59cb\u5316\u5206\u9875\u63d2\u4ef6<\/span><br \/>\n        <span class=\"token class-name\">PageHelper<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">startPage<\/span><span class=\"token punctuation\">(<\/span>pageNum<span class=\"token punctuation\">,<\/span> pageSize<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u8c03\u7528 Mapper \u83b7\u53d6\u539f\u59cb\u6570\u636e&#xff08;\u4ece\u6570\u636e\u5e93\u67e5\u6240\u6709\u7528\u6237&#xff09;<\/span><br \/>\n        <span class=\"token class-name\">List<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">User<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> userList <span class=\"token operator\">&#061;<\/span> userMapper<span class=\"token punctuation\">.<\/span><span class=\"token function\">selectAll<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u4e1a\u52a1\u5904\u74063&#xff1a;\u5305\u88c5\u6210\u5206\u9875\u7ed3\u679c&#xff08;\u542b\u603b\u9875\u6570\u3001\u603b\u6761\u6570\u7b49&#xff09;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">PageInfo<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token punctuation\">(<\/span>userList<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h5>4. Mapper \u6267\u884c SQL&#xff0c;\u4ece\u6570\u636e\u5e93\u53d6\u6570\u636e<\/h5>\n<p>Mapper \u50cf\u201c\u91c7\u8d2d\u5458\u201d&#xff0c;\u63a5\u5230 Service \u7684\u6307\u4ee4\u540e&#xff0c;\u76f4\u63a5\u53bb\u6570\u636e\u5e93\u201c\u91c7\u8d2d\u201d\u539f\u59cb\u6570\u636e&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u63a5\u53e3\u5b9a\u4e49&#xff08;UserMapper.java&#xff09;&#xff1a;\u58f0\u660e\u8981\u6267\u884c\u7684\u64cd\u4f5c<\/p>\n<p><span class=\"token annotation punctuation\">&#064;Mapper<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">interface<\/span> <span class=\"token class-name\">UserMapper<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u58f0\u660e\u201c\u67e5\u8be2\u6240\u6709\u7528\u6237\u201d\u7684\u64cd\u4f5c<\/span><br \/>\n    <span class=\"token class-name\">List<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">User<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> <span class=\"token function\">selectAll<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<\/li>\n<li>\n<p>SQL \u5b9e\u73b0&#xff08;UserMapper.xml&#xff09;&#xff1a;\u6267\u884c\u5177\u4f53\u7684 SQL<\/p>\n<p><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>mapper<\/span> <span class=\"token attr-name\">namespace<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>com.example.mapper.UserMapper<span class=\"token punctuation\">&#034;<\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token comment\">&lt;!&#8211; \u6267\u884c\u201c\u67e5\u6240\u6709\u7528\u6237\u201d\u7684 SQL&#xff0c;\u8fd4\u56de\u539f\u59cb\u6570\u636e &#8211;&gt;<\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>select<\/span> <span class=\"token attr-name\">id<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>selectAll<span class=\"token punctuation\">&#034;<\/span><\/span> <span class=\"token attr-name\">resultType<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>User<span class=\"token punctuation\">&#034;<\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n        select * from user<br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>select<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>mapper<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u6267\u884c\u540e&#xff0c;\u6570\u636e\u5e93\u8fd4\u56de\u6240\u6709\u7528\u6237\u7684\u539f\u59cb\u5217\u8868&#xff08;\u6bd4\u5982100\u6761\u6570\u636e&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<h5>5. \u6570\u636e\u4ece Mapper \u56de\u5230 Service&#xff0c;\u5b8c\u6210\u4e1a\u52a1\u52a0\u5de5<\/h5>\n<p>Mapper \u628a\u4ece\u6570\u636e\u5e93\u67e5\u5230\u7684 100 \u6761\u7528\u6237\u6570\u636e\u8fd4\u56de\u7ed9 Service&#xff0c;Service \u7528\u5206\u9875\u63d2\u4ef6\u5904\u7406\u540e&#xff0c;\u53ea\u4fdd\u7559\u7b2c2\u9875\u768410\u6761\u6570\u636e&#xff08;\u7b2c11-20\u6761&#xff09;&#xff0c;\u5e76\u8ba1\u7b97\u51fa\u603b\u9875\u6570&#xff08;10\u9875&#xff09;\u3001\u603b\u6761\u6570&#xff08;100\u6761&#xff09;\u7b49\u4fe1\u606f&#xff0c;\u5305\u88c5\u6210 PageInfo \u5bf9\u8c61\u3002<\/p>\n<h5>6. Service \u628a\u7ed3\u679c\u8fd4\u56de\u7ed9 Controller&#xff0c;\u6700\u7ec8\u5c55\u793a\u7ed9\u7528\u6237<\/h5>\n<p>Service \u628a\u5904\u7406\u597d\u7684\u5206\u9875\u7ed3\u679c&#xff08;PageInfo&#xff09;\u8fd4\u56de\u7ed9 Controller&#xff0c;Controller \u518d\u4f20\u7ed9\u524d\u7aef\u89c6\u56fe&#xff0c;\u6700\u7ec8\u7f51\u9875\u4e0a\u5c55\u793a\u201c\u7b2c2\u9875\u768410\u6761\u7528\u6237\u6570\u636e\u201d\u548c\u5206\u9875\u6309\u94ae&#xff08;\u4e0a\u4e00\u9875\u3001\u4e0b\u4e00\u9875\u7b49&#xff09;\u3002<\/p>\n<h4>\u6d41\u7a0b\u603b\u7ed3&#xff1a;<\/h4>\n<p>\u524d\u7aef\u8bf7\u6c42 \u2192 Controller&#xff08;\u8c03\u5ea6&#xff09;\u2192 Service&#xff08;\u4e1a\u52a1\u5904\u7406&#xff09;\u2192 Mapper&#xff08;\u67e5\u6570\u636e\u5e93&#xff09;\u2192 \u6570\u636e\u5e93<br \/>\n                                                                 \u2193<br \/>\n\u524d\u7aef\u5c55\u793a \u2190 Controller&#xff08;\u4f20\u7ed3\u679c&#xff09;\u2190 Service&#xff08;\u52a0\u5de5\u6570\u636e&#xff09;\u2190 Mapper&#xff08;\u8fd4\u56de\u539f\u59cb\u6570\u636e&#xff09;<\/p>\n<ul>\n<li>Mapper \u53ea\u505a\u4e00\u4ef6\u4e8b&#xff1a;\u6267\u884c SQL \u4ece\u6570\u636e\u5e93\u62ff\u539f\u59cb\u6570\u636e&#xff0c;\u662f\u201c\u6570\u636e\u5165\u53e3\u201d\u3002<\/li>\n<li>Service \u6838\u5fc3\u804c\u8d23&#xff1a;\u8c03\u7528 Mapper \u62ff\u6570\u636e&#xff0c;\u7136\u540e\u6309\u4e1a\u52a1\u89c4\u5219\u52a0\u5de5&#xff08;\u9a8c\u8bc1\u3001\u8ba1\u7b97\u3001\u8fc7\u6ee4\u7b49&#xff09;&#xff0c;\u662f\u201c\u4e1a\u52a1\u6838\u5fc3\u201d\u3002<\/li>\n<li>\u4e24\u8005\u914d\u5408&#xff1a;\u901a\u8fc7\u201cService \u8c03\u7528 Mapper\u201d\u7684\u65b9\u5f0f&#xff0c;\u5b9e\u73b0\u201c\u6570\u636e\u83b7\u53d6\u2192\u4e1a\u52a1\u5904\u7406\u201d\u7684\u5b8c\u6574\u6d41\u7a0b&#xff0c;\u65e2\u5206\u5de5\u660e\u786e\u53c8\u534f\u540c\u5de5\u4f5c\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb22\u6b21\u3002\u524d\u7aef\u8bf7\u6c42 \u2192 Controller\uff08\u8c03\u5ea6\uff09\u2192 Service\uff08\u4e1a\u52a1\u5904\u7406\uff09\u2192 Mapper\uff08\u67e5\u6570\u636e\u5e93\uff09\u2192 \u6570\u636e\u5e93\u2193\u524d\u7aef\u5c55\u793a \u2190 Controller\uff08\u4f20\u7ed3\u679c\uff09\u2190 Service\uff08\u52a0\u5de5\u6570\u636e\uff09\u2190 Mapper\uff08\u8fd4\u56de\u539f\u59cb\u6570\u636e\uff09Mapper \u53ea\u505a\u4e00\u4ef6\u4e8b\uff1a\u6267\u884c SQL \u4ece\u6570\u636e\u5e93\u62ff\u539f\u59cb\u6570\u636e\uff0c\u662f\u201c\u6570\u636e\u5165\u53e3\u201d\u3002Service \u6838\u5fc3\u804c\u8d23\uff1a\u8c03\u7528 Mapper \u62ff\u6570\u636e\uff0c\u7136\u540e\u6309\u4e1a\u52a1\u89c4\u5219\u52a0\u5de5\uff08\u9a8c\u8bc1\u3001\u8ba1\u7b97\u3001\u8fc7\u6ee4\u7b49\uff09\uff0c\u662f\u201c\u4e1a\u52a1\u6838\u5fc3\u201d\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[50],"topic":[],"class_list":["post-56226","post","type-post","status-publish","format-standard","hentry","category-server","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Mapper\u548cService\u7684\u5de5\u4f5c\u6d41\u7a0b\u662f\u600e\u6837\u7684\uff1f\uff08\u901a\u4fd7\u6613\u61c2\u7248\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/56226.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mapper\u548cService\u7684\u5de5\u4f5c\u6d41\u7a0b\u662f\u600e\u6837\u7684\uff1f\uff08\u901a\u4fd7\u6613\u61c2\u7248\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb22\u6b21\u3002\u524d\u7aef\u8bf7\u6c42 \u2192 Controller\uff08\u8c03\u5ea6\uff09\u2192 Service\uff08\u4e1a\u52a1\u5904\u7406\uff09\u2192 Mapper\uff08\u67e5\u6570\u636e\u5e93\uff09\u2192 \u6570\u636e\u5e93\u2193\u524d\u7aef\u5c55\u793a \u2190 Controller\uff08\u4f20\u7ed3\u679c\uff09\u2190 Service\uff08\u52a0\u5de5\u6570\u636e\uff09\u2190 Mapper\uff08\u8fd4\u56de\u539f\u59cb\u6570\u636e\uff09Mapper \u53ea\u505a\u4e00\u4ef6\u4e8b\uff1a\u6267\u884c SQL \u4ece\u6570\u636e\u5e93\u62ff\u539f\u59cb\u6570\u636e\uff0c\u662f\u201c\u6570\u636e\u5165\u53e3\u201d\u3002Service \u6838\u5fc3\u804c\u8d23\uff1a\u8c03\u7528 Mapper \u62ff\u6570\u636e\uff0c\u7136\u540e\u6309\u4e1a\u52a1\u89c4\u5219\u52a0\u5de5\uff08\u9a8c\u8bc1\u3001\u8ba1\u7b97\u3001\u8fc7\u6ee4\u7b49\uff09\uff0c\u662f\u201c\u4e1a\u52a1\u6838\u5fc3\u201d\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/56226.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-14T07:04:49+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/56226.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/56226.html\",\"name\":\"Mapper\u548cService\u7684\u5de5\u4f5c\u6d41\u7a0b\u662f\u600e\u6837\u7684\uff1f\uff08\u901a\u4fd7\u6613\u61c2\u7248\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-14T07:04:49+00:00\",\"dateModified\":\"2025-08-14T07:04:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/56226.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/56226.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/56226.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mapper\u548cService\u7684\u5de5\u4f5c\u6d41\u7a0b\u662f\u600e\u6837\u7684\uff1f\uff08\u901a\u4fd7\u6613\u61c2\u7248\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mapper\u548cService\u7684\u5de5\u4f5c\u6d41\u7a0b\u662f\u600e\u6837\u7684\uff1f\uff08\u901a\u4fd7\u6613\u61c2\u7248\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/56226.html","og_locale":"zh_CN","og_type":"article","og_title":"Mapper\u548cService\u7684\u5de5\u4f5c\u6d41\u7a0b\u662f\u600e\u6837\u7684\uff1f\uff08\u901a\u4fd7\u6613\u61c2\u7248\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb22\u6b21\u3002\u524d\u7aef\u8bf7\u6c42 \u2192 Controller\uff08\u8c03\u5ea6\uff09\u2192 Service\uff08\u4e1a\u52a1\u5904\u7406\uff09\u2192 Mapper\uff08\u67e5\u6570\u636e\u5e93\uff09\u2192 \u6570\u636e\u5e93\u2193\u524d\u7aef\u5c55\u793a \u2190 Controller\uff08\u4f20\u7ed3\u679c\uff09\u2190 Service\uff08\u52a0\u5de5\u6570\u636e\uff09\u2190 Mapper\uff08\u8fd4\u56de\u539f\u59cb\u6570\u636e\uff09Mapper \u53ea\u505a\u4e00\u4ef6\u4e8b\uff1a\u6267\u884c SQL \u4ece\u6570\u636e\u5e93\u62ff\u539f\u59cb\u6570\u636e\uff0c\u662f\u201c\u6570\u636e\u5165\u53e3\u201d\u3002Service \u6838\u5fc3\u804c\u8d23\uff1a\u8c03\u7528 Mapper \u62ff\u6570\u636e\uff0c\u7136\u540e\u6309\u4e1a\u52a1\u89c4\u5219\u52a0\u5de5\uff08\u9a8c\u8bc1\u3001\u8ba1\u7b97\u3001\u8fc7\u6ee4\u7b49\uff09\uff0c\u662f\u201c\u4e1a\u52a1\u6838\u5fc3\u201d\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/56226.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-14T07:04:49+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/56226.html","url":"https:\/\/www.wsisp.com\/helps\/56226.html","name":"Mapper\u548cService\u7684\u5de5\u4f5c\u6d41\u7a0b\u662f\u600e\u6837\u7684\uff1f\uff08\u901a\u4fd7\u6613\u61c2\u7248\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-14T07:04:49+00:00","dateModified":"2025-08-14T07:04:49+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/56226.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/56226.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/56226.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Mapper\u548cService\u7684\u5de5\u4f5c\u6d41\u7a0b\u662f\u600e\u6837\u7684\uff1f\uff08\u901a\u4fd7\u6613\u61c2\u7248\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/56226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=56226"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/56226\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=56226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=56226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=56226"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=56226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}