瀏覽代碼

feat: 表格外层数据查询功能,增加页面py文件的格式校验

zhangyuantao 1 年之前
父節點
當前提交
59e0d77dbd

+ 1 - 0
pom.xml

@@ -82,6 +82,7 @@
                     <source>8</source>
                     <target>8</target>
                     <encoding>UTF-8</encoding>
+                    <skip>true</skip>
                 </configuration>
             </plugin>
         </plugins>

+ 17 - 7
src/main/java/com/tao/controller/AppElementController.java

@@ -60,14 +60,24 @@ public class AppElementController {
 
     @GetMapping("/data")
     @ResponseBody
-    public AjaxResult getElements(AppElement appElement) {
-        // 前端传elemenType为3,则需要返回个人的数据,即type为1或2的数据
-        if (appElement.getElementType() != null && appElement.getElementType() == 3) {
-            List<AppElement> appElements = appElementService.selectAppElementListByType(1l);
-            appElements.addAll(appElementService.selectAppElementListByType(2l));
-            return AjaxResult.success("成功查询", appElements);
+    public AjaxResult getElements(String selectType, AppElement appElement) {
+        if ("fuzzy".equals(selectType)) {
+            if (appElement.getElementType() != null && appElement.getElementType() == 3) {
+                appElement.setElementType(1l);
+                List<AppElement> appElements = appElementService.selectAppElementListFuzzy(appElement);
+                appElement.setElementType(2l);
+                return AjaxResult.success("成功查询", appElements.addAll(appElementService.selectAppElementListFuzzy(appElement)));
+            }
+            return AjaxResult.success("成功查询", appElementService.selectAppElementListFuzzy(appElement));
+        } else {
+            // 前端传elemenType为3,则需要返回个人的数据,即type为1或2的数据
+            if (appElement.getElementType() != null && appElement.getElementType() == 3) {
+                List<AppElement> appElements = appElementService.selectAppElementListByType(1l);
+                appElements.addAll(appElementService.selectAppElementListByType(2l));
+                return AjaxResult.success("成功查询", appElements);
+            }
+            return AjaxResult.success("成功查询", appElementService.selectAppElementList(appElement));
         }
-        return AjaxResult.success("成功查询", appElementService.selectAppElementList(appElement));
     }
 
 }

+ 7 - 0
src/main/java/com/tao/mapper/AppElementMapper.java

@@ -42,6 +42,13 @@ public interface AppElementMapper {
      */
     public List<AppElement> selectAppElementList(AppElement appElement);
 
+    /**
+     * @param appElement
+     * @return java.util.List<com.tao.pojo.AppElement>
+     * @Description 根据字符属性字段模糊查找元素集合
+     */
+    public List<AppElement> selectAppElementListFuzzy(AppElement appElement);
+
     /**
      * @param appElement
      * @return int

+ 7 - 0
src/main/java/com/tao/service/AppElementService.java

@@ -42,6 +42,13 @@ public interface AppElementService {
      */
     public List<AppElement> selectAppElementList(AppElement appElement);
 
+    /**
+     * @param appElement
+     * @return java.util.List<com.tao.pojo.AppElement>
+     * @Description 根据字符属性字段模糊查找元素集合
+     */
+    public List<AppElement> selectAppElementListFuzzy(AppElement appElement);
+
     /**
      * @param appElement
      * @return int

+ 11 - 1
src/main/java/com/tao/service/impl/AppElementServiceImpl.java

@@ -41,7 +41,7 @@ public class AppElementServiceImpl implements AppElementService {
                 @Override
                 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                     String filePath = file.toString();
-                    if (!filePath.contains("element.py") && !filePath.contains("__init__.py")) {
+                    if (!filePath.contains("element.py") && !filePath.contains("__init__.py") && filePath.endsWith(".py")) {
                         // 创建一个页面对象,一个page.py文件对应一个对象
                         AppPage appPage = new AppPage();
                         appPage.setPageName(FileUtil.getPrefix(filePath));
@@ -186,6 +186,16 @@ public class AppElementServiceImpl implements AppElementService {
         return appElementMapper.selectAppElementList(appElement);
     }
 
+    /**
+     * @param appElement
+     * @return java.util.List<com.tao.pojo.AppElement>
+     * @Description 根据字符属性字段模糊查找元素集合
+     */
+    @Override
+    public List<AppElement> selectAppElementListFuzzy(AppElement appElement) {
+        return appElementMapper.selectAppElementListFuzzy(appElement);
+    }
+
     /**
      * @param appElement
      * @return int

+ 14 - 0
src/main/resources/mybatis/mapper/AppElementMapper.xml

@@ -58,6 +58,20 @@
             <if test="elementName != null  and elementName != ''">and e.element_name = #{elementName}</if>
             <if test="elementAndroidLocate != null  and elementAndroidLocate != ''">and e.element_android_locate = #{elementAndroidLocate}</if>
             <if test="elementIOSLocate != null  and elementIOSLocate != ''">and e.element_iOS_locate = #{elementIOSLocate}</if>
+            <if test="elementRemark != null  and elementRemark != ''">and e.element_remark = #{elementRemark}</if>
+            <if test="elementType != null">and e.element_type = #{elementType}</if>
+            <if test="pageID != null  and pageID != ''">and e.page_id = #{pageID}</if>
+        </where>
+    </select>
+
+    <select id="selectAppElementListFuzzy" parameterType="AppElement" resultMap="AppElementResult">
+        <include refid="selectAppElementVo"/>
+        <where>
+            <if test="elementID != null  and elementID != ''">and e.element_id = #{elementID}</if>
+            <if test="elementName != null  and elementName != ''">and e.element_name like '%'||#{elementName}||'%'</if>
+            <if test="elementAndroidLocate != null  and elementAndroidLocate != ''">and e.element_android_locate like '%'||#{elementAndroidLocate}||'%'</if>
+            <if test="elementIOSLocate != null  and elementIOSLocate != ''">and e.element_iOS_locate like '%'||#{elementIOSLocate}||'%'</if>
+            <if test="elementRemark != null  and elementRemark != ''">and e.element_remark like '%'||#{elementRemark}||'%'</if>
             <if test="elementType != null">and e.element_type = #{elementType}</if>
             <if test="pageID != null  and pageID != ''">and e.page_id = #{pageID}</if>
         </where>

+ 95 - 16
src/main/resources/templates/index.html

@@ -18,9 +18,10 @@
             <div class="layui-row">
                 <form class="layui-form layui-form-pane" action="" style="margin-left: 190px;padding: 10px">
                     <div class="layui-form-item">
-                        <label class="layui-form-label layui-hide-xs" style="width: 13%">请输入页面对象根目录</label>
+                        <label class="layui-form-label layui-hide-xs" style="width: 180px">请输入页面对象根目录</label>
                         <div class="layui-input-inline layui-hide-xs" style="width: 45%">
-                            <input type="text" name="rootPath" lay-verify="required" placeholder="请输入页面对象根目录" autocomplete="off" class="layui-input">
+                            <input type="text" name="rootPath" lay-verify="required" placeholder="请输入页面对象根目录"
+                                   autocomplete="off" class="layui-input">
                         </div>
                         <div class="layui-form-mid" style="padding: 0!important;">
                             <button type="button" class="layui-btn" lay-submit lay-filter="formSubmit">立即同步</button>
@@ -38,8 +39,9 @@
                 <li class="layui-nav-item layui-nav-itemed">
                     <a href="#">特殊分组</a>
                     <dl class="layui-nav-child">
-                        <dd><a class="pageRequest" href="#" data-param="{&quot;elementType&quot;: &quot;&quot;}">全部数据</a></dd>
-                        <dd><a class="pageRequest" href="#" data-param="{&quot;elementType&quot;: 3}">个人数据</a></dd>
+                        <dd><a class="pageRequest" href="#"
+                               data-param="{&quot;elementType&quot;: &quot;&quot;,&quot;pageID&quot;: &quot;&quot;}">全部数据</a></dd>
+                        <dd><a class="pageRequest" href="#" data-param="{&quot;elementType&quot;: 3,&quot;pageID&quot;: &quot;&quot;}">个人数据</a></dd>
                     </dl>
                 </li>
                 <li class="layui-nav-item">
@@ -50,7 +52,9 @@
         </div>
         <script id="itemData" type="text/html">
             {{# layui.each(d, function(index, item){ }}
-            <dd><a class="pageRequest" href="#" data-param="{&quot;elementType&quot;: 0, &quot;pageID&quot;: &quot;{{ item.pageID }}&quot;}">{{ item.pageName }}</a></dd>
+            <dd><a class="pageRequest" href="#"
+                   data-param="{&quot;elementType&quot;: 0, &quot;pageID&quot;: &quot;{{ item.pageID }}&quot;}">{{
+                item.pageName }}</a></dd>
             {{# }); }}
             {{# if(d.length === 0){ }}
             <dd><a href="#">未加载到数据</a></dd>
@@ -61,12 +65,48 @@
     <div class="layui-body">
         <!-- 内容主体区域 -->
         <div style="margin: 20px">
+            <form class="layui-row layui-form layui-form-pane" action="">
+                <div class="layui-hide layui-form-item">
+                    <input type="text" name="selectType" value="fuzzy">
+                </div>
+                <div class="layui-col-sm12 layui-form-item">
+                    <div class="layui-inline" style="display: inline">
+                        <label class="layui-form-label" style="width: 60px;">名称</label>
+                        <div class="layui-input-inline" style="width: 12%;">
+                            <input type="text" name="elementName" class="layui-input" placeholder="请输入元素名称">
+                        </div>
+                    </div>
+                    <div class="layui-inline" style="display: inline">
+                        <label class="layui-form-label" style="width: 90px;">Android</label>
+                        <div class="layui-input-inline" style="width: 18%;">
+                            <input type="text" name="elementAndroidLocate" class="layui-input" placeholder="请输入Android定位关键值">
+                        </div>
+                    </div>
+                    <div class="layui-inline" style="display: inline">
+                        <label class="layui-form-label" style="width: 60px;">IOS</label>
+                        <div class="layui-input-inline" style="width: 18%;">
+                            <input type="text" name="elementIOSLocate" class="layui-input" placeholder="请输入IOS定位关键值">
+                        </div>
+                    </div>
+                    <div class="layui-inline" style="display: inline">
+                        <label class="layui-form-label" style="width: 60px;">备注</label>
+                        <div class="layui-input-inline" style="width: 12%;">
+                            <input type="text" name="elementRemark" class="layui-input" placeholder="请输入备注">
+                        </div>
+                    </div>
+                    <div class="layui-inline" style="display: inline">
+                        <button type="button" class="layui-btn mgl-20" lay-submit lay-filter="search"><i class="layui-icon">&#xe615;</i>查询</button>
+                        <button class="layui-btn layui-btn-primary" type="reset" lay-active="reset">重置</button>
+                    </div>
+                </div>
+            </form>
             <table id="myTable" lay-filter="myTable"></table>
             <script type="text/html" id="expandAll">
                 <div class="layui-card" style="margin: 10px;border: 1px solid #f1f2f6;">
                     <div class="layui-card-header" style="background-color: #ced6e0">
                         <h3 style="display: inline">Python代码</h3>
-                        <button data-clipboard-target="#{{d.elementName}}" style="display: inline;margin-bottom: 5px;" type="button" class="js-clipboard layui-btn layui-btn-radius layui-btn-primary">
+                        <button data-clipboard-target="#{{d.elementName}}" style="display: inline;margin-bottom: 5px;"
+                                type="button" class="js-clipboard layui-btn layui-btn-radius layui-btn-primary">
                             一键复制
                         </button>
                     </div>
@@ -75,18 +115,25 @@
                             # {{d.elementRemark}}<br>
                             <span style="color: #90548c">self</span><span style="color: #a2b1bd">.{{d.elementName}}_locator ={</span><br>
                             {{# if(typeof d.elementAndroidLocate == 'string' && d.elementAndroidLocate.length > 0){ }}
-                            <div style="text-indent: 1em"><span style="color: #638655">'Android'</span><span style="color: #a2b1bd">: {</span></div>
-                            <div style="text-indent: 2em"><span style="color: #638655">{{d.elementAndroidLocate}}</span></div>
-                            <div style="text-indent: 1em"><span style="color: #a2b1bd">}</span><span style="color: #cb7530">,</span></div>
+                            <div style="text-indent: 1em"><span style="color: #638655">'Android'</span><span
+                                    style="color: #a2b1bd">: {</span></div>
+                            <div style="text-indent: 2em"><span style="color: #638655">{{d.elementAndroidLocate}}</span>
+                            </div>
+                            <div style="text-indent: 1em"><span style="color: #a2b1bd">}</span><span
+                                    style="color: #cb7530">,</span></div>
                             {{# } }}
                             {{# if(typeof d.elementIOSLocate == 'string' && d.elementIOSLocate.length > 0){ }}
-                            <div style="text-indent: 1em"><span style="color: #638655">'iOS'</span><span style="color: #a2b1bd">: {</span></div>
-                            <div style="text-indent: 2em"><span style="color: #638655">{{d.elementIOSLocate}}</span></div>
+                            <div style="text-indent: 1em"><span style="color: #638655">'iOS'</span><span
+                                    style="color: #a2b1bd">: {</span></div>
+                            <div style="text-indent: 2em"><span style="color: #638655">{{d.elementIOSLocate}}</span>
+                            </div>
                             <div style="text-indent: 1em"><span style="color: #a2b1bd">}</span></div>
                             {{# } }}
                             <span style="color: #a2b1bd">}</span><br>
-                            <span style="color: #90548c">self</span><span style="color: #a2b1bd">.{{d.elementName}} = Element(</span><span style="color: #90548c">self</span><span
-                                style="color: #a2b1bd">.d</span><span style="color: #cb7530">,</span> <span style="color: #90548c">self</span><span
+                            <span style="color: #90548c">self</span><span style="color: #a2b1bd">.{{d.elementName}} = Element(</span><span
+                                style="color: #90548c">self</span><span
+                                style="color: #a2b1bd">.d</span><span style="color: #cb7530">,</span> <span
+                                style="color: #90548c">self</span><span
                                 style="color: #a2b1bd">.{{d.elementName}}_locator)</span><br>
                         </h3>
                     </div>
@@ -142,12 +189,16 @@
             , $ = layui.$;
 
         let clipboard;
+        let elementType = "";
+        let pageID = "";
 
         function menuClick() {
             $(".pageRequest").click(function (data) {
-                const param = data.target.getAttribute("data-param");
+                const param = JSON.parse(data.target.getAttribute("data-param"));
+                elementType = param.elementType;
+                pageID = param.pageID;
                 table.reload('myTable', {
-                    where: JSON.parse(param)
+                    where: param
                 })
             });
         }
@@ -216,6 +267,26 @@
             return false;
         });
 
+        form.on('submit(search)', function (data) {
+            data.field["elementType"] = elementType;
+            data.field["pageID"] = pageID;
+            table.reload('myTable', {
+                where: data.field
+            })
+        });
+
+        //处理属性 为 lay-active 的所有元素事件
+        util.event('lay-active', {
+            reset: function(othis){
+                table.reload('myTable', {
+                    where: {
+                        elementType : elementType,
+                        pageID : pageID
+                    }
+                })
+            }
+        });
+
         table.render({
             elem: '#myTable'
             , id: 'myTable'
@@ -237,7 +308,14 @@
             , cols: [
                 [
                     {title: '#', width: 50, children: '#expandAll', childWidth: 'full'},
-                    {field: 'elementType', title: '元素状态', width: 140, sort: true, filter: true, templet: '#elementTypeTpl'},
+                    {
+                        field: 'elementType',
+                        title: '元素状态',
+                        width: 140,
+                        sort: true,
+                        filter: true,
+                        templet: '#elementTypeTpl'
+                    },
                     {field: 'elementName', title: '元素名', width: 200, sort: true, filter: true},
                     {field: 'elementAndroidLocate', title: '元素Android端定位值', width: 485, sort: true, filter: true},
                     {field: 'elementIOSLocate', title: '元素IOS端定位值', width: 485, sort: true, filter: true},
@@ -260,6 +338,7 @@
 
     });
 
+
 </script>
 </body>
 </html>

+ 5 - 2
src/test/java/com/tao/ElementSyncApplicationTests.java

@@ -17,11 +17,14 @@ import java.util.regex.Pattern;
 @SpringBootTest
 class ElementSyncApplicationTests {
 
+    @Autowired
+    AppElementService appElementService;
+
     @Test
     void contextLoads() {
-
+        // List<AppElement> agree = appElementService.selectAppElementListFuzzy(new AppElement(null, "agree", null, null, null, null, null, null));
+        // System.out.println("agree = " + agree);
         System.out.println("测试代码");
-
     }
 
 }