Skip to content

Commit

Permalink
chore: deploy docs of project Nop Entropy via GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nop-cao committed Aug 12, 2024
1 parent aa8f611 commit 290254c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion projects/nop-entropy/docs/dev-guide/xlang/xmeta/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ <h2 id="prop配置"><a href="#prop配置" class="headerlink" title="prop配置">
<p>ui:filterOp实际对应前端生成的控件的name格式为 <code>filter_&#123;name&#125;__&#123;filterOp&#125;</code>,例如<code>filter_userStatus__in</code></p>
<h2 id="对象元数据"><a href="#对象元数据" class="headerlink" title="对象元数据"></a>对象元数据</h2><p>xmeta文件定义了后台服务对象的元数据,描述了对象具有哪些属性,以及这些属性是否可以修改,是否可以查询等信息。<br>NopGraphQL引擎返回的对象信息完全由XMeta来定义。如果一个属性在XMeta中没有定义,则即使实体上具有这个字段,前台GraphQL和REST请求也无法访问到该字段。</p>
<h2 id="定义关联属性"><a href="#定义关联属性" class="headerlink" title="定义关联属性"></a>定义关联属性</h2><p>实体模型中的关联对象生成到XMeta模型中体现为如下配置</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><code class="hljs plaintext">&lt;props&gt;<br> &lt;prop name=&quot;parent&quot;&gt;<br> &lt;schema bizObjName=&quot;NopAuthDepartment&quot; /&gt;<br> &lt;/prop&gt;<br><br> &lt;prop name=&quot;children&quot;&gt;<br> &lt;schema&gt;<br> &lt;item bizObjName=&quot;NopAuthDepartment&quot; /&gt;<br> &lt;/schema&gt;<br> &lt;/prop&gt;<br>&lt;/props&gt;<br></code></pre></td></tr></table></figure>
<figure class="highlight xml"><table><tr><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">props</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">prop</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;parent&quot;</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">schema</span> <span class="hljs-attr">bizObjName</span>=<span class="hljs-string">&quot;NopAuthDepartment&quot;</span> /&gt;</span><br> <span class="hljs-tag">&lt;/<span class="hljs-name">prop</span>&gt;</span><br><br> <span class="hljs-tag">&lt;<span class="hljs-name">prop</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;children&quot;</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">schema</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">item</span> <span class="hljs-attr">bizObjName</span>=<span class="hljs-string">&quot;NopAuthDepartment&quot;</span> /&gt;</span><br> <span class="hljs-tag">&lt;/<span class="hljs-name">schema</span>&gt;</span><br> <span class="hljs-tag">&lt;/<span class="hljs-name">prop</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">props</span>&gt;</span><br></code></pre></td></tr></table></figure>

<ul>
<li>schema如果具有item,则表示是集合属性,集合元素的类型由 item节点的bizObjName属性来指定。</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ <h2 id="三-在XMeta中为prop增加关联查询配置"><a href="#三-在XMeta
<figure class="highlight plaintext"><table><tr><td class="code"><pre><code class="hljs graphql">query($filter1:Map, $filter2: Map)&#123;<br> NopAuthSite_get(id:&quot;main&quot;)&#123;<br> id<br> displayName<br> activeResources: resourcesList(filter:$filter1,limit:10,offset:0)&#123;<br> items&#123;<br> id<br> displayName<br> &#125;<br> &#125;<br> inactiveResources: resourcesList(filter:$filter2,limit:10,offset:0)&#123;<br> items&#123;<br> id<br> displayName<br> &#125;<br> &#125;<br> &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<h2 id="四-根据子表属性过滤主表记录"><a href="#四-根据子表属性过滤主表记录" class="headerlink" title="四. 根据子表属性过滤主表记录"></a>四. 根据子表属性过滤主表记录</h2><p>可以在XMeta中增加一个自定义字段,然后通过<code>graphql:transFilter</code>将自定义字段条件翻译为子表查询条件所对应的SQL语句。<br>具体实现原理是利用QueryBean提供的transformFilter函数,对前台提交的查询条件进行结构变换,</p>
<p>例如对于<code>/r/NopAuthSite__findPage?filter__myCustomFilter=main</code>这种自定义查询条件,<br>我们在XMeta中通过prop节点的<code>graphql:transFilter</code>子节点配置来定义转换逻辑。</p>
<p>例如对于<code>/r/NopAuthSite__findPage?filter__myCustomFilter=1</code>这种自定义查询条件,<br>我们在XMeta中通过prop节点的<code>graphql:transFilter</code>子节点配置来定义转换逻辑。</p>
<figure class="highlight xml"><table><tr><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">prop</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;myCustomFilter&quot;</span> <span class="hljs-attr">queryable</span>=<span class="hljs-string">&quot;true&quot;</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">graphql:transFilter</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">filter:sql</span>&gt;</span><br> exists( select o2 from NopAuthResource o2 where o2.siteId= o.id<br> and o2.status &gt;= $&#123; filter.getAttr(&#x27;value&#x27;) &#125;<br> )<br> <span class="hljs-tag">&lt;/<span class="hljs-name">filter:sql</span>&gt;</span><br> <span class="hljs-tag">&lt;/<span class="hljs-name">graphql:transFilter</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">prop</span>&gt;</span><br></code></pre></td></tr></table></figure>

<ul>
Expand All @@ -1327,7 +1327,7 @@ <h2 id="四-根据子表属性过滤主表记录"><a href="#四-根据子表属
<li><code>&lt;filter:sql&gt;</code><code>filter.xlib</code>中定义的一个标签,它可以将一个动态生成的SQL语句包装为<code>$type=sql</code>的TreeBean对象,用于数据库查询条件。</li>
</ul>
<p>实际翻译得到的EQL语句为</p>
<figure class="highlight sql"><table><tr><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">select</span> o<br><span class="hljs-keyword">from</span> NopAuthSite o<br><span class="hljs-keyword">where</span><br> <span class="hljs-keyword">exists</span>( <span class="hljs-keyword">select</span> o2 <span class="hljs-keyword">from</span> NopAuthResource o2 <span class="hljs-keyword">where</span> o2.siteId<span class="hljs-operator">=</span> o.id<br> <span class="hljs-keyword">and</span> o2.status <span class="hljs-operator">&gt;=</span> <span class="hljs-string">&#x27;main&#x27;</span><br> )<br></code></pre></td></tr></table></figure>
<figure class="highlight sql"><table><tr><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">select</span> o<br><span class="hljs-keyword">from</span> NopAuthSite o<br><span class="hljs-keyword">where</span><br> <span class="hljs-keyword">exists</span>( <span class="hljs-keyword">select</span> o2 <span class="hljs-keyword">from</span> NopAuthResource o2 <span class="hljs-keyword">where</span> o2.siteId<span class="hljs-operator">=</span> o.id<br> <span class="hljs-keyword">and</span> o2.status <span class="hljs-operator">&gt;=</span> <span class="hljs-number">1</span><br> )<br></code></pre></td></tr></table></figure>

<h3 id="高级特性"><a href="#高级特性" class="headerlink" title="高级特性"></a>高级特性</h3><p><code>graphql:transFilter</code>的类型是<code>xpl-fn</code>,它的返回值要求是XNode类型,但是它不直接支持输出。要使用xpl来输出XNode时,需要使用一个节点包装一下,设置outputMode</p>
<figure class="highlight xml"><table><tr><td class="code"><pre><code class="hljs xml"> <span class="hljs-tag">&lt;<span class="hljs-name">graphql:transFilter</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">and</span> <span class="hljs-attr">xpl:outputMode</span>=<span class="hljs-string">&quot;node&quot;</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">alwaysTrue</span>/&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">filter:sql</span>&gt;</span><br> exists(select o2 from NopAuthResource o2 where o2.siteId= o.id<br> and o2.status &gt;= $&#123;filter.getAttr(&#x27;value&#x27;)&#125;)<br> <span class="hljs-tag">&lt;/<span class="hljs-name">filter:sql</span>&gt;</span><br> <span class="hljs-tag">&lt;/<span class="hljs-name">and</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">graphql:transFilter</span>&gt;</span><br></code></pre></td></tr></table></figure>
Expand Down

0 comments on commit 290254c

Please sign in to comment.