Jelajahi Sumber

Merge branch 'dev' of licailing/wenlvju into master

licailing 5 tahun lalu
induk
melakukan
723f2efcb8
27 mengubah file dengan 241 tambahan dan 27 penghapusan
  1. 14 1
      src/main/java/com/izouma/wenlvju/domain/MessageRecord.java
  2. 19 0
      src/main/java/com/izouma/wenlvju/repo/MessageRecordRepo.java
  3. 1 0
      src/main/java/com/izouma/wenlvju/repo/OrganizationRepo.java
  4. 5 0
      src/main/java/com/izouma/wenlvju/repo/RateAuditRepo.java
  5. 5 0
      src/main/java/com/izouma/wenlvju/repo/RateExpertAuditRepo.java
  6. 10 0
      src/main/java/com/izouma/wenlvju/repo/RateRepo.java
  7. 26 1
      src/main/java/com/izouma/wenlvju/service/OrganizationService.java
  8. 16 0
      src/main/java/com/izouma/wenlvju/service/UserService.java
  9. 0 4
      src/main/java/com/izouma/wenlvju/service/sms/NjwlSmsService.java
  10. 1 1
      src/main/java/com/izouma/wenlvju/web/OrganizationController.java
  11. 87 0
      src/main/vue/src/App.vue
  12. 1 1
      src/main/vue/src/components/CropUpload.vue
  13. 1 1
      src/main/vue/src/components/FileUpload.vue
  14. 1 1
      src/main/vue/src/components/FileUpload2.vue
  15. 1 1
      src/main/vue/src/components/MultiUpload.vue
  16. 1 1
      src/main/vue/src/components/SingleUpload.vue
  17. 1 1
      src/main/vue/src/components/VideoUpload.vue
  18. 1 1
      src/main/vue/src/router.js
  19. 2 2
      src/main/vue/src/views/Admin.vue
  20. 1 1
      src/main/vue/src/views/Api.vue
  21. 2 2
      src/main/vue/src/views/Login.vue
  22. 1 0
      src/main/vue/src/views/organization/OrganizationEdit.vue
  23. 5 5
      src/main/vue/src/views/organization/OrganizationList.vue
  24. 17 1
      src/main/vue/src/views/user/ExpertList.vue
  25. 17 1
      src/main/vue/src/views/user/UserList.vue
  26. 0 1
      src/test/java/com/izouma/wenlvju/repo/RateExpertAuditRepoTest.java
  27. 5 0
      src/test/java/com/izouma/wenlvju/service/RateServiceTest.java

+ 14 - 1
src/main/java/com/izouma/wenlvju/domain/MessageRecord.java

@@ -1,19 +1,32 @@
 package com.izouma.wenlvju.domain;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import javax.persistence.Entity;
+import java.time.LocalDateTime;
+
 
 @Data
 @Builder
+@Entity
 @AllArgsConstructor
 @NoArgsConstructor
-public class MessageRecord extends BaseEntity{
+public class MessageRecord extends BaseEntity {
     private String phone;
 
+    private String token;
+
+    @ApiModelProperty(value = "过期时间戳")
+    private String expiryDate;
+
     private String requestContent;
 
     private String responseContent;
+
+    @ApiModelProperty(value = "过期时间", name = "expiresAt")
+    private LocalDateTime expiresAt;
 }

+ 19 - 0
src/main/java/com/izouma/wenlvju/repo/MessageRecordRepo.java

@@ -0,0 +1,19 @@
+package com.izouma.wenlvju.repo;
+
+import com.izouma.wenlvju.domain.MessageRecord;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+
+import javax.transaction.Transactional;
+import java.time.LocalDateTime;
+
+public interface MessageRecordRepo extends JpaRepository<MessageRecord, Long>, JpaSpecificationExecutor<MessageRecord> {
+    @Query("update MessageRecord t set t.del = true where t.id = ?1")
+    @Modifying
+    @Transactional
+    void softDelete(Long id);
+
+    MessageRecord findFirstByExpiresAtBefore(LocalDateTime expiresAt);
+}

+ 1 - 0
src/main/java/com/izouma/wenlvju/repo/OrganizationRepo.java

@@ -21,4 +21,5 @@ public interface OrganizationRepo extends JpaRepository<Organization, Long>, Jpa
     int nextSort();
 
     Organization findByUscc(String uscc);
+
 }

+ 5 - 0
src/main/java/com/izouma/wenlvju/repo/RateAuditRepo.java

@@ -13,4 +13,9 @@ public interface RateAuditRepo extends JpaRepository<RateAudit, Long>, JpaSpecif
     @Modifying
     @Transactional
     void softDelete(Long id);
+
+    @Query("update RateAudit t set t.del = true where t.rateId in ?1")
+    @Modifying
+    @Transactional
+    void softDeleteByRateIdIn(Iterable<Long> rateIds);
 }

+ 5 - 0
src/main/java/com/izouma/wenlvju/repo/RateExpertAuditRepo.java

@@ -17,5 +17,10 @@ public interface RateExpertAuditRepo extends JpaRepository<RateExpertAudit, Long
 
     List<RateExpertAudit> findAllByRateId(Long rateId);
 
+    @Query("update RateExpertAudit t set t.del = true where t.rateId in ?1")
+    @Modifying
+    @Transactional
+    void softDeleteByRateIdIn(Iterable<Long> rateId);
+
     RateExpertAudit findByRateIdAndType(Long rateId, String type);
 }

+ 10 - 0
src/main/java/com/izouma/wenlvju/repo/RateRepo.java

@@ -17,7 +17,17 @@ public interface RateRepo extends JpaRepository<Rate, Long>, JpaSpecificationExe
     @Transactional
     void softDelete(Long id);
 
+    @Query("update Rate t set t.del = true where t.organizationId = ?1")
+    @Modifying
+    @Transactional
+    void softDeleteByOrganizationId(Long organizationId);
+
+    List<Rate> findAllByOrganizationId(@NonNull Long organizationId);
+
     Long countAllByOrganizationIdAndYearAndStatusNot(@NonNull Long organizationId, String year, RateStatus status);
 
     Long countAllByOrganizationIdAndYear(@NonNull Long organizationId, String year);
+
+    @Query(nativeQuery = true, value = "select count(1) from rate where expert_user_id = ?1 or find_in_set(?1,expert_member_user_id)")
+    Long countByExpertId(Long userId);
 }

+ 26 - 1
src/main/java/com/izouma/wenlvju/service/OrganizationService.java

@@ -1,21 +1,31 @@
 package com.izouma.wenlvju.service;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.izouma.wenlvju.domain.Organization;
 import com.izouma.wenlvju.domain.Rate;
 import com.izouma.wenlvju.dto.PageQuery;
 import com.izouma.wenlvju.exception.BusinessException;
 import com.izouma.wenlvju.repo.OrganizationRepo;
+import com.izouma.wenlvju.repo.RateAuditRepo;
+import com.izouma.wenlvju.repo.RateExpertAuditRepo;
+import com.izouma.wenlvju.repo.RateRepo;
 import com.izouma.wenlvju.utils.JpaUtils;
 import lombok.AllArgsConstructor;
 import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 @Service
 @AllArgsConstructor
 public class OrganizationService {
 
-    private OrganizationRepo organizationRepo;
+    private final OrganizationRepo    organizationRepo;
+    private final RateRepo            rateRepo;
+    private final RateAuditRepo       rateAuditRepo;
+    private final RateExpertAuditRepo rateExpertAuditRepo;
 
     public Page<Organization> all(PageQuery pageQuery) {
         return organizationRepo.findAll(JpaUtils.toSpecification(pageQuery, Organization.class), JpaUtils.toPageRequest(pageQuery));
@@ -41,4 +51,19 @@ public class OrganizationService {
             organizationRepo.save(organization);
         }
     }
+
+    public void del(Long id) {
+        List<Rate> rates = rateRepo.findAllByOrganizationId(id);
+        List<Long> rateIds = rates.stream().map(Rate::getId).collect(Collectors.toList());
+        if (CollUtil.isNotEmpty(rateIds)) {
+            // 评分审核记录
+            rateAuditRepo.softDeleteByRateIdIn(rateIds);
+            // 评分细则
+            rateExpertAuditRepo.softDeleteByRateIdIn(rateIds);
+        }
+
+        // 评定申请
+        rateRepo.softDeleteByOrganizationId(id);
+        organizationRepo.softDelete(id);
+    }
 }

+ 16 - 0
src/main/java/com/izouma/wenlvju/service/UserService.java

@@ -54,6 +54,8 @@ public class UserService {
     private final OrganizationRepo        organizationRepo;
     private final CollaborateRepo         collaborateRepo;
     private final GradingOrganizationRepo gradingOrganizationRepo;
+    private final RateRepo                rateRepo;
+    private final OrganizationService     organizationService;
 
     public Page<User> all(PageQuery pageQuery) {
         return userRepo.findAll(JpaUtils.toSpecification(pageQuery, User.class), JpaUtils.toPageRequest(pageQuery));
@@ -76,6 +78,18 @@ public class UserService {
 
     public void del(Long id) {
         User user = userRepo.findById(id).orElseThrow(new BusinessException("用户不存在"));
+        Set<Authority> authorities = user.getAuthorities();
+        if (authorities.contains(Authority.get(AuthorityName.ROLE_EXPERT)) || authorities
+                .contains(Authority.get(AuthorityName.ROLE_DISTRICT_STAFF))) {
+            // 市政专家
+            if (rateRepo.countByExpertId(id) > 0) {
+                throw new BusinessException("参与的等级评定的专家不能删除!");
+            }
+        } else if (authorities.contains(Authority.get(AuthorityName.ROLE_ORGANIZER))) {
+            // 承办单位
+            organizationRepo.findByUserId(id).ifPresent(organization -> organizationService.del(organization.getId()));
+        }
+
         user.setDel(true);
         if (StringUtils.isNoneEmpty(user.getOpenId())) {
             user.setOpenId(user.getOpenId() + "###" + RandomStringUtils.randomAlphabetic(8));
@@ -84,6 +98,8 @@ public class UserService {
             user.setPhone(user.getPhone() + "###" + RandomStringUtils.randomAlphabetic(8));
         }
         userRepo.save(user);
+
+
     }
 
     public User loginByPhone(String phone) {

+ 0 - 4
src/main/java/com/izouma/wenlvju/service/sms/NjwlSmsService.java

@@ -1,10 +1,7 @@
 package com.izouma.wenlvju.service.sms;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.parser.Feature;
 import com.github.kevinsawicki.http.HttpRequest;
-import com.izouma.wenlvju.domain.MessageRecord;
 import com.izouma.wenlvju.domain.SmsRecord;
 import com.izouma.wenlvju.exception.BusinessException;
 import com.izouma.wenlvju.repo.SmsRecordRepo;
@@ -20,7 +17,6 @@ import java.io.StringWriter;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 import java.util.HashMap;
-import java.util.LinkedHashMap;
 import java.util.Map;
 
 @Service

+ 1 - 1
src/main/java/com/izouma/wenlvju/web/OrganizationController.java

@@ -72,7 +72,7 @@ public class OrganizationController extends BaseController {
 
     @PostMapping("/del/{id}")
     public void del(@PathVariable Long id) {
-        organizationRepo.softDelete(id);
+        organizationService.del(id);
     }
 
     @GetMapping("/excel")

+ 87 - 0
src/main/vue/src/App.vue

@@ -2,6 +2,93 @@
     <router-view></router-view>
 </template>
 
+<script>
+import { mapState } from 'vuex';
+export default {
+    data() {
+        return {
+            timer: null,
+            x: null,
+            y: null,
+            count: 0,
+            outTime: 60
+        };
+    },
+    computed: {
+        ...mapState(['userInfo'])
+    },
+    watch: {
+        userInfo() {
+            if (!this.timer) {
+                this.timer = setInterval(this.go, 1000);
+            }
+        }
+    },
+    mounted() {
+        // window.addEventListener('visibilitychange', this.focusChange);
+        document.onmousemove = event => {
+            /* Act on the event */
+            var x1 = event.clientX;
+            var y1 = event.clientY;
+            if (this.x != x1 || this.y != y1) {
+                this.count = 0;
+            }
+            this.x = x1;
+            this.y = y1;
+        };
+        document.onkeydown = event => {
+            this.count = 0;
+        };
+        this.timer = setInterval(this.go, 1000);
+    },
+    destroyed() {
+        // window.removeEventListener('visibilitychange');
+        if (this.timer) {
+            clearInterval(this.timer);
+        }
+    },
+    methods: {
+        go() {
+            this.count++;
+            if (this.count == this.outTime * 60 && this.$route.name !== 'login') {
+                sessionStorage.removeItem('token');
+                clearInterval(this.timer);
+                this.$alert('网站由于长时间未访问,已经下线账号', '提示', {
+                    confirmButtonText: '确定',
+                    callback: action => {
+                        this.$router.push('/login');
+                    }
+                });
+            }
+        },
+        focusChange() {
+            if (document.hidden) {
+                // 失去焦点
+                console.log('失去焦点');
+
+                if (this.timer) {
+                    clearTimeout(this.timer);
+                }
+
+                this.timer = setTimeout(() => {
+                    if (this.$route.name !== 'login' && document.hidden) {
+                        sessionStorage.removeItem('token');
+                        this.$alert('网站由于长时间未访问,已经下线账号', '提示', {
+                            confirmButtonText: '确定',
+                            callback: action => {
+                                this.$router.push('/login');
+                            }
+                        });
+                    }
+                }, 1000 * 60 * this.outTime);
+            } else {
+                // 获取焦点
+            }
+        }
+    }
+};
+</script>
+
 <style lang="less">
 @import url(./styles/app.less);
 </style>

+ 1 - 1
src/main/vue/src/components/CropUpload.vue

@@ -55,7 +55,7 @@ export default {
             },
             loading: false,
             headers: {
-                Authorization: 'Bearer ' + localStorage.getItem('token')
+                Authorization: 'Bearer ' + sessionStorage.getItem('token')
             }
         };
     },

+ 1 - 1
src/main/vue/src/components/FileUpload.vue

@@ -84,7 +84,7 @@ export default {
     computed: {
         headers() {
             return {
-                Authorization: 'Bearer ' + localStorage.getItem('token')
+                Authorization: 'Bearer ' + sessionStorage.getItem('token')
             };
         },
         filesLimit() {

+ 1 - 1
src/main/vue/src/components/FileUpload2.vue

@@ -83,7 +83,7 @@ export default {
     computed: {
         headers() {
             return {
-                Authorization: 'Bearer ' + localStorage.getItem('token')
+                Authorization: 'Bearer ' + sessionStorage.getItem('token')
             };
         },
         filesLimit() {

+ 1 - 1
src/main/vue/src/components/MultiUpload.vue

@@ -58,7 +58,7 @@ export default {
     computed: {
         headers() {
             return {
-                Authorization: 'Bearer ' + localStorage.getItem('token')
+                Authorization: 'Bearer ' + sessionStorage.getItem('token')
             };
         }
     },

+ 1 - 1
src/main/vue/src/components/SingleUpload.vue

@@ -47,7 +47,7 @@ export default {
     computed: {
         headers() {
             return {
-                Authorization: 'Bearer ' + localStorage.getItem('token')
+                Authorization: 'Bearer ' + sessionStorage.getItem('token')
             };
         }
     },

+ 1 - 1
src/main/vue/src/components/VideoUpload.vue

@@ -42,7 +42,7 @@ export default {
     computed: {
         headers() {
             return {
-                Authorization: 'Bearer ' + localStorage.getItem('token')
+                Authorization: 'Bearer ' + sessionStorage.getItem('token')
             };
         }
     },

+ 1 - 1
src/main/vue/src/router.js

@@ -521,7 +521,7 @@ router.beforeEach((to, from, next) => {
                     });
             })
             .catch(() => {
-                localStorage.removeItem('token');
+                sessionStorage.removeItem('token');
                 next('/login');
             });
     } else if (!to.matched.length) {

+ 2 - 2
src/main/vue/src/views/Admin.vue

@@ -228,7 +228,7 @@ export default {
         },
         onCommand(command) {
             if (command === 'logout') {
-                localStorage.removeItem('token');
+                sessionStorage.removeItem('token');
                 this.$store.commit('updateUserInfo', null);
                 this.$store.commit('updateOrganization', null);
                 this.$router.replace('/login');
@@ -261,7 +261,7 @@ export default {
                             console.log(res);
                             this.pwdLoading = false;
                             this.showPwdDialog = false;
-                            localStorage.removeItem('token');
+                            sessionStorage.removeItem('token');
                             this.$store.commit('updateUserInfo', null);
                             this.$router.replace('/login');
                             this.$message.success('修改成功,请重新登录');

+ 1 - 1
src/main/vue/src/views/Api.vue

@@ -184,7 +184,7 @@ export default {
                         method: this.formData.method,
                         url: this.formData.url,
                         headers: {
-                            Authorization: 'Bearer ' + localStorage.getItem('token')
+                            Authorization: 'Bearer ' + sessionStorage.getItem('token')
                         }
                     };
                     if (this.formData.method === 'get') {

+ 2 - 2
src/main/vue/src/views/Login.vue

@@ -325,7 +325,7 @@ export default {
                             remember: this.rememberMe
                         })
                         .then(res => {
-                            localStorage.setItem('token', res);
+                            sessionStorage.setItem('token', res);
                             return this.$store.dispatch('getUserInfo');
                         })
                         .then(res => {
@@ -363,7 +363,7 @@ export default {
                             return Promise.reject(e);
                         })
                         .then(res => {
-                            localStorage.setItem('token', res);
+                            sessionStorage.setItem('token', res);
                             return this.$store.dispatch('getUserInfo');
                         })
                         .then(res => {

+ 1 - 0
src/main/vue/src/views/organization/OrganizationEdit.vue

@@ -133,6 +133,7 @@
                 <!-- <el-button @click="readonly = false" :loading="saving" type="success">编辑</el-button> -->
                 <div style="margin: 10px">
                     <!-- <el-button @click="onSave" :loading="saving" type="primary">保存</el-button> -->
+                    <el-button @click="onDelete" type="danger" size="mini">删除</el-button>
                     <el-button @click="$router.go(-1)">返回</el-button>
                 </div>
             </el-form-item>

+ 5 - 5
src/main/vue/src/views/organization/OrganizationList.vue

@@ -26,8 +26,8 @@
         >
             <el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
             <el-table-column prop="id" label="ID" width="80"> </el-table-column>
-            <el-table-column prop="name" label="承办单位名称"> </el-table-column>
-            <el-table-column prop="uscc" label="统一社会信用代码"></el-table-column>
+            <el-table-column prop="name" label="承办单位名称" show-overflow-tooltip> </el-table-column>
+            <el-table-column prop="uscc" label="统一社会信用代码" show-overflow-tooltip></el-table-column>
             <el-table-column prop="district" label="所属区县"> </el-table-column>
             <el-table-column prop="businessLicense" label="营业执照">
                 <template slot-scope="{ row }">
@@ -41,12 +41,12 @@
             </el-table-column>
             <el-table-column prop="owner" label="负责人"> </el-table-column>
             <el-table-column prop="privacyPolicy" label="法人姓名"> </el-table-column>
-            <el-table-column prop="idNo" label="证件号码"> </el-table-column>
+            <el-table-column prop="idNo" label="证件号码" show-overflow-tooltip> </el-table-column>
             <el-table-column prop="businessScope" label="经营范围" min-width="150"> </el-table-column>
             <el-table-column label="操作" align="center" fixed="right" min-width="150">
                 <template slot-scope="{ row }">
-                    <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
-                    <!-- <el-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button> -->
+                    <el-button @click="editRow(row)" type="primary" size="mini" plain>查看</el-button>
+                    <el-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button>
                 </template>
             </el-table-column>
         </el-table>

+ 17 - 1
src/main/vue/src/views/user/ExpertList.vue

@@ -41,9 +41,10 @@
                     ></el-image>
                 </template>
             </el-table-column> -->
-            <el-table-column label="操作" align="center" fixed="right">
+            <el-table-column label="操作" align="center" fixed="right" min-width="150">
                 <template slot-scope="{ row }">
                     <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
+                    <el-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button>
                 </template>
             </el-table-column>
         </el-table>
@@ -171,6 +172,21 @@ export default {
                         this.$message.error(e.error);
                     });
             }
+        },
+        deleteRow(row) {
+            this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+                .then(() => {
+                    return this.$http.post(`/user/del/${row.id}`);
+                })
+                .then(() => {
+                    this.$message.success('删除成功');
+                    this.getData();
+                })
+                .catch(e => {
+                    if (e !== 'cancel') {
+                        this.$message.error(e.error);
+                    }
+                });
         }
     }
 };

+ 17 - 1
src/main/vue/src/views/user/UserList.vue

@@ -48,9 +48,10 @@
             <el-table-column prop="phone" label="手机号" min-width="100"> </el-table-column>
             <el-table-column prop="work" label="工作单位" min-width="100"> </el-table-column>
             <el-table-column prop="position" label="职位" min-width="100"> </el-table-column>
-            <el-table-column label="操作" align="center" fixed="right">
+            <el-table-column label="操作" align="center" fixed="right" min-width="150">
                 <template slot-scope="{ row }">
                     <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
+                    <el-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button>
                 </template>
             </el-table-column>
         </el-table>
@@ -196,6 +197,21 @@ export default {
                 }
             });
             return flag;
+        },
+        deleteRow(row) {
+            this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+                .then(() => {
+                    return this.$http.post(`/user/del/${row.id}`);
+                })
+                .then(() => {
+                    this.$message.success('删除成功');
+                    this.getData();
+                })
+                .catch(e => {
+                    if (e !== 'cancel') {
+                        this.$message.error(e.error);
+                    }
+                });
         }
     }
 };

+ 0 - 1
src/test/java/com/izouma/wenlvju/repo/RateExpertAuditRepoTest.java

@@ -21,5 +21,4 @@ public class RateExpertAuditRepoTest extends ApplicationTests {
                         "https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/image/2021-04-08-14-45-42CvVMClla.jpg"))
                 .build());
     }
-
 }

+ 5 - 0
src/test/java/com/izouma/wenlvju/service/RateServiceTest.java

@@ -169,4 +169,9 @@ public class RateServiceTest extends ApplicationTests {
 //        wb.saveToFile("output/ToPDF.pdf", FileFormat.PDF);
     }
 
+
+    @Test
+    public void test10() {
+        System.out.println(rateRepo.countByExpertId(700l));
+    }
 }