Przeglądaj źródła

1.优化
2.添加学校删除验证

liuyuqiang 2 lat temu
rodzic
commit
33c362ecbe

+ 6 - 0
sooka-admin/src/main/java/com/sooka/web/controller/schooldistrict/BtpPolicestationVillageController.java

@@ -38,8 +38,14 @@ public class BtpPolicestationVillageController extends BaseController {
         mmap.put("parentId", parentId);
         if (0 == parentId) {
             mmap.put("pageMark", "派出所");
+            BtpPolicestationVillage temp = new BtpPolicestationVillage();
+            temp.setPvId(0L);
+            mmap.put("policestations", Arrays.asList(temp));
         } else {
             mmap.put("pageMark", "委(村)");
+            BtpPolicestationVillage temp = new BtpPolicestationVillage();
+            temp.setParentId(0L);
+            mmap.put("policestations", btpPolicestationVillageService.selectBtpPolicestationVillageList(temp));
         }
         return prefix + "/policestationvillage";
     }

+ 13 - 3
sooka-admin/src/main/java/com/sooka/web/controller/schooldistrict/BtpSchoolController.java

@@ -1,13 +1,16 @@
 package com.sooka.web.controller.schooldistrict;
 
-import com.sooka.schooldistrict.domain.BtpSchool;
-import com.sooka.schooldistrict.service.IBtpSchoolService;
 import com.sooka.common.annotation.Log;
 import com.sooka.common.core.controller.BaseController;
 import com.sooka.common.core.domain.AjaxResult;
 import com.sooka.common.core.page.TableDataInfo;
 import com.sooka.common.enums.BusinessType;
+import com.sooka.common.utils.StringUtils;
 import com.sooka.common.utils.poi.ExcelUtil;
+import com.sooka.schooldistrict.domain.BtpSchool;
+import com.sooka.schooldistrict.domain.BtpSchoolPv;
+import com.sooka.schooldistrict.service.IBtpSchoolPvService;
+import com.sooka.schooldistrict.service.IBtpSchoolService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -31,6 +34,9 @@ public class BtpSchoolController extends BaseController {
     @Autowired
     private IBtpSchoolService btpSchoolService;
 
+    @Autowired
+    private IBtpSchoolPvService btpSchoolPvService;
+
     @RequiresPermissions("schooldistrict:school:view")
     @GetMapping()
     public String school() {
@@ -111,6 +117,10 @@ public class BtpSchoolController extends BaseController {
     @PostMapping("/remove")
     @ResponseBody
     public AjaxResult remove(String ids) {
-        return toAjax(btpSchoolService.deleteBtpSchoolBySchoolIds(ids));
+        List<BtpSchoolPv> schoolPvs = btpSchoolPvService.selectBtpSchoolPvInSchoolId(ids);
+        if (StringUtils.isEmpty(schoolPvs)) {
+            return toAjax(btpSchoolService.deleteBtpSchoolBySchoolIds(ids));
+        }
+        return AjaxResult.error();
     }
 }

+ 1 - 1
sooka-admin/src/main/resources/templates/schooldistrict/policestationvillage/add.html

@@ -40,7 +40,7 @@
     $(function() {
         $('#parentId').select2({
             placeholder: "请选择所属派出所",
-            allowClear: true
+            allowClear: false
         });
         if ("0" == [[${parentId}]]) {
             $("#parentId").select2("val", [0]);

+ 2 - 2
sooka-admin/src/main/resources/templates/schooldistrict/policestationvillage/edit.html

@@ -17,7 +17,7 @@
         <div class="form-group" th:style="'display:' + ${display}">
             <label class="col-sm-3 control-label is-required">所属派出所:</label>
             <div class="col-sm-8">
-                <select id="parentId" name="parentId" class="form-control select2-multiple" required>
+                <select id="parentId" name="parentId" th:field="*{parentId}" class="form-control select2-multiple" required>
                     <option th:each="policestation:${policestations}" th:value="${policestation.pvId}" th:text="${policestation.pvName}"></option>
                 </select>
             </div>
@@ -41,7 +41,7 @@
     $(function() {
         $('#parentId').select2({
             placeholder: "请选择所属派出所",
-            allowClear: true
+            allowClear: false
         });
     })
 </script>

+ 35 - 29
sooka-admin/src/main/resources/templates/schooldistrict/policestationvillage/policestationvillage.html

@@ -14,6 +14,13 @@
                             [[${pageMark}]]名称:
                             <input type="text" name="pvName"/>
                         </li>
+                        <li id="parentName" style="display: none">
+                            所属派出所:
+                            <select name="parentName">
+                                <option value="">所有</option>
+                                <option th:each="policestation:${policestations}" th:text="${policestation.pvName}" th:value="${policestation.pvId}"></option>
+                            </select>
+                        </li>
                         <li>
                             <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                             <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
@@ -47,6 +54,9 @@
     var editFlag = [[${@permission.hasPermi('schooldistrict:policestationvillage:edit')}]];
     var removeFlag = [[${@permission.hasPermi('schooldistrict:policestationvillage:remove')}]];
     var prefix = ctx + "schooldistrict/policestationvillage", parentId = '[[${parentId}]]';
+    if (parentId != 0) {
+        $("#parentName").show();
+    }
 
     $(function() {
         var options = {
@@ -59,36 +69,32 @@
             columns: [{
                 checkbox: true
             },
-                {
-                    field: 'pvId',
-                    title: '派出所、委(村)id',
-                    visible: false
-                },
-                {
-                    field: 'pvName',
-                    title: [[${pageMark}]] + '名称'
-                },
-                {
-                    field: 'parentId',
-                    title: '上级id,0为派出所,其他为委(村)',
-                    visible: false
-                },
-                {
-                    field: 'parentName',
-                    title: '所属派出所',
-                    visible: 0 != parentId
-                },
-                {
-                    title: '操作',
-                    align: 'center',
-                    formatter: function(value, row, index) {
-                        var actions = [];
-                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.pvId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
-                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.pvId + '\')"><i class="fa fa-remove"></i>删除</a>');
-                        return actions.join('');
-                    }
-                }]
+            {
+                field: 'pvId',
+                title: [[${pageMark}]] + '主键',
+                visible: false
+            },
+            {
+                field: 'pvName',
+                title: [[${pageMark}]] + '名称'
+            }]
         };
+        if (0 != parentId) {
+            options.columns.push({
+                field: 'parentName',
+                title: '所属派出所'
+            });
+        }
+        options.columns.push({
+            title: '操作',
+            align: 'center',
+            formatter: function(value, row, index) {
+                var actions = [];
+                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.pvId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
+                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.pvId + '\')"><i class="fa fa-remove"></i>删除</a>');
+                return actions.join('');
+            }
+        });
         $.table.init(options);
     });
 </script>

+ 1 - 1
sooka-admin/src/main/resources/templates/schooldistrict/school/school.html

@@ -69,7 +69,7 @@
                 },
                 {
                     field: 'schoolId',
-                    title: '学校id',
+                    title: '学校主键',
                     visible: false
                 },
                 {

+ 2 - 0
sooka-schooldistrict/src/main/java/com/sooka/schooldistrict/mapper/BtpSchoolPvMapper.java

@@ -59,4 +59,6 @@ public interface BtpSchoolPvMapper {
      * @return 结果
      */
     public int deleteBtpSchoolPvByVIds(String[] vIds);
+
+    public List<BtpSchoolPv> selectBtpSchoolPvInSchoolId(String[] schoolIds);
 }

+ 2 - 0
sooka-schooldistrict/src/main/java/com/sooka/schooldistrict/service/IBtpSchoolPvService.java

@@ -59,4 +59,6 @@ public interface IBtpSchoolPvService {
      * @return 结果
      */
     public int deleteBtpSchoolPvByPId(Long pId);
+
+    public List<BtpSchoolPv> selectBtpSchoolPvInSchoolId(String schoolIds);
 }

+ 6 - 1
sooka-schooldistrict/src/main/java/com/sooka/schooldistrict/service/impl/BtpSchoolPvServiceImpl.java

@@ -1,9 +1,9 @@
 package com.sooka.schooldistrict.service.impl;
 
+import com.sooka.common.core.text.Convert;
 import com.sooka.schooldistrict.domain.BtpSchoolPv;
 import com.sooka.schooldistrict.mapper.BtpSchoolPvMapper;
 import com.sooka.schooldistrict.service.IBtpSchoolPvService;
-import com.sooka.common.core.text.Convert;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -94,4 +94,9 @@ public class BtpSchoolPvServiceImpl implements IBtpSchoolPvService {
     public int deleteBtpSchoolPvByPId(Long pId) {
         return btpSchoolPvMapper.deleteBtpSchoolPvByPId(pId);
     }
+
+    @Override
+    public List<BtpSchoolPv> selectBtpSchoolPvInSchoolId(String schoolIds) {
+        return btpSchoolPvMapper.selectBtpSchoolPvInSchoolId(Convert.toStrArray(schoolIds));
+    }
 }

+ 1 - 0
sooka-schooldistrict/src/main/resources/mapper/schooldistrict/BtpPolicestationVillageMapper.xml

@@ -27,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </choose>
         <where>
             <if test="pvName != null  and pvName != ''"> and a.pv_name like concat('%', #{pvName}, '%')</if>
+            <if test="parentName != null  and parentName != ''"> and a.parent_id = #{parentName}</if>
             <choose>
                 <when test="parentId != null and parentId == 0">
                     and a.parent_id = 0

+ 8 - 0
sooka-schooldistrict/src/main/resources/mapper/schooldistrict/BtpSchoolPvMapper.xml

@@ -79,4 +79,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
 
+    <select id="selectBtpSchoolPvInSchoolId" parameterType="String" resultMap="BtpSchoolPvResult">
+        <include refid="selectBtpSchoolPvVo"/>
+        where school_id in
+        <foreach item="schoolId" collection="array" open="(" separator="," close=")">
+            #{schoolId}
+        </foreach>
+    </select>
+
 </mapper>