{"id":151384,"date":"2020-08-31T15:38:48","date_gmt":"2020-08-31T07:38:48","guid":{"rendered":"http:\/\/4563.org\/?p=151384"},"modified":"2020-08-31T15:38:48","modified_gmt":"2020-08-31T07:38:48","slug":"crud-%e6%a8%a1%e6%9d%bf%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=151384","title":{"rendered":"crud \u6a21\u677f\u65b9\u6cd5"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  crud \u6a21\u677f\u65b9\u6cd5               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : huifer <\/span>  <span><i><\/i> 20<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h1>crud template<\/h1>\n<p> <\/p>\n<ul>\n<li>\n<p>\u589e\u5220\u6539\u67e5\u6a21\u677f\u9879\u76ee,\u65e8\u5728\u51cf\u5c11\u91cd\u590d\u4ee3\u7801.<\/p>\n<\/li>\n<li>\n<p>\u6ce8\u610f: <strong>\u76ee\u524d\u53ea\u652f\u6301 redis-hash \u7684\u6570\u636e\u7c7b\u578b<\/strong><\/p>\n<\/li>\n<li>\n<p>\u9879\u76ee\u5730\u5740: https:\/\/github.com\/huifer\/crud<\/p>\n<\/li>\n<\/ul>\n<h2>\u529f\u80fd<\/h2>\n<ul>\n<li>\u5355\u4e2a\u8868\u7684\u6570\u636e\u5e93\u589e\u5220\u6539\u67e5\u64cd\u4f5c<\/li>\n<li>\u5355\u4e2a\u8868\u7684\u6570\u636e\u5e93+\u7f13\u5b58\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c<\/li>\n<li>\u5355\u4e2a\u5b9e\u4f53\u7684\u7f13\u5b58\u589e\u5220\u6539\u67e5\u64cd\u4f5c<\/li>\n<\/ul>\n<h2>\u5982\u4f55\u4f7f\u7528<\/h2>\n<ul>\n<li>\u5728\u542f\u52a8\u7c7b\u4e0a\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\n<ul>\n<li>daoType \u53ef\u9009\u9879\u6709 mybatis \u548c mybatis-plus<\/li>\n<li>scanPackages \u7528\u6765\u586b\u5199\u9700\u8981\u626b\u63cf\u7684\u5b9e\u4f53\u5305\u8def\u5f84,\u652f\u6301\u591a\u4e2a<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><code>@EnableCrudTemplate(daoType = DaoType.MYBATIS_PLUS, scanPackages = {     \"com.github.huifer.mybatis.plus.mybatis\"}) <\/code><\/pre>\n<h3>mybatis \u652f\u6301<\/h3>\n<ul>\n<li>\u6dfb\u52a0\u4f9d\u8d56<\/li>\n<\/ul>\n<pre><code>    &lt;dependency&gt;       &lt;groupId&gt;com.github.huifer&lt;\/groupId&gt;       &lt;artifactId&gt;for-mybatis&lt;\/artifactId&gt;       &lt;version&gt;0.0.4-SNAPSHOT&lt;\/version&gt;     &lt;\/dependency&gt; <\/code><\/pre>\n<ul>\n<li>\u5bf9 mapper \u8fdb\u884c\u4fee\u6539<\/li>\n<\/ul>\n<pre><code>@CacheKey(key = \"issues\", type = IssuesEntity.class) public interface IssuesMapper extends A&lt;Integer, IssuesEntity&gt; {} <\/code><\/pre>\n<ul>\n<li>\u5bf9\u5b9e\u4f53\u8fdb\u884c\u4fee\u6539<\/li>\n<\/ul>\n<pre><code>public class IssuesEntity implements BaseEntity {} <\/code><\/pre>\n<h3>mybatis plus \u652f\u6301<\/h3>\n<ul>\n<li>\u6dfb\u52a0\u4f9d\u8d56<\/li>\n<\/ul>\n<pre><code>    &lt;dependency&gt;       &lt;groupId&gt;com.github.huifer&lt;\/groupId&gt;       &lt;artifactId&gt;for-mybatis-plus&lt;\/artifactId&gt;       &lt;version&gt;0.0.4-SNAPSHOT&lt;\/version&gt;     &lt;\/dependency&gt; <\/code><\/pre>\n<ul>\n<li>\u5bf9 mapper \u8fdb\u884c\u4fee\u6539<\/li>\n<\/ul>\n<pre><code>@CacheKey(key = \"issues\", type = IssuesEntity.class) public interface IssuesMapper extends BaseMapper&lt;IssuesEntity&gt;,     AforMybatisPlus&lt;Integer, IssuesEntity&gt;  <\/code><\/pre>\n<ul>\n<li>\u5bf9\u5b9e\u4f53\u8fdb\u884c\u4fee\u6539<\/li>\n<\/ul>\n<pre><code>public class IssuesEntity implements BaseEntity {} <\/code><\/pre>\n<ul>\n<li>\u8c03\u7528\u5c42 mybatis \u548c mybatis-plus \u90fd\u662f\u540c\u4e00\u4e2a\u5165\u53e3<\/li>\n<\/ul>\n<pre><code>  @Autowired   private CrudFacade&lt;IssuesEntity, IntIdInterface&lt;Integer&gt;&gt; crudFacade; <\/code><\/pre>\n<ul>\n<li>\u53ea\u9700\u8981\u5f15\u5165<code>CrudFacade<\/code>\u7ec4\u4ef6\u5c31\u53ef\u4ee5\u62e5\u6709\u6570\u636e\u5e93+\u7f13\u5b58\u7684 crud \u64cd\u4f5c\u4e86. \u5982\u679c\u4e0d\u9700\u8981\u7f13\u5b58\u8bf7\u5c06 mapper \u4e0a\u7684<code>@CacheKey<\/code>\u5220\u6389<\/li>\n<\/ul>\n<h3>entity \u652f\u6301<\/h3>\n<ul>\n<li>\u7ed9\u5b9e\u4f53\u5bf9\u8c61\u6dfb\u52a0\u6ce8\u89e3 <code>@CacheKey<\/code>\n<ul>\n<li>redis-hash field \u53d6\u503c\u8bf4\u660e: idFiled=\u5b9e\u4f53\u7c7b\u7684\u67d0\u4e2a\u5b57\u6bb5, idMethod=\u5b9e\u4f53\u7c7b\u4e2d\u7684\u4e00\u4e2a\u65b9\u6cd5,\u5982\u679c\u4e24\u8005\u540c\u65f6\u5b58\u5728\u4ee5<code>idMethod<\/code>\u4e3a\u51c6, \u5efa\u8bae\u586b\u5199\u4e00\u4e2a<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><code>@CacheKey(key = \"tt\", type = IssuesEntity.class, idFiled = \"newTitle\", idMethod = \"ooo\") public class IssuesEntity  {     private Integer id;   private String newTitle;    private String ooo() {     return \"OOO\" + this.newTitle;   } } <\/code><\/pre>\n<h2>Contributers<\/h2>\n<ul>\n<li>@huifer<\/li>\n<\/ul>\n<ul>\n<li>\u5e0c\u671b\u5404\u4f4d\u53ef\u4ee5\u53d1\u8868\u4e00\u4e0b\u60f3\u6cd5\u3001\u770b\u6cd5<\/li>\n<\/ul><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>crud \u6a21\u677f\u65b9\u6cd5 \u8cc7\u6df1\u5927\u4f6c : &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\/151384"}],"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=151384"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/151384\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=151384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=151384"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=151384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}