فهرست منبع

Merge branch 'dev' of xiongzhu/raex_back into master

熊竹 4 سال پیش
والد
کامیت
81bde97d06

+ 6 - 0
pom.xml

@@ -400,6 +400,12 @@
             <artifactId>adapay-java-sdk</artifactId>
             <version>1.2.10</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+            <version>1.1.21</version>
+        </dependency>
     </dependencies>
 
 </project>

+ 4 - 0
src/main/java/com/izouma/nineth/repo/UserBankCardRepo.java

@@ -3,11 +3,15 @@ package com.izouma.nineth.repo;
 import com.izouma.nineth.dto.UserBankCard;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
 
+import javax.transaction.Transactional;
 import java.util.List;
 
 public interface UserBankCardRepo extends JpaRepository<UserBankCard, Long>, JpaSpecificationExecutor<UserBankCard> {
     List<UserBankCard> findByUserId(Long userId);
 
+    @Transactional
+    @Modifying
     int deleteByUserId(Long userId);
 }

+ 1 - 0
src/main/java/com/izouma/nineth/security/WebSecurityConfig.java

@@ -97,6 +97,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/activity/all").permitAll()
                 .antMatchers("/activity/get/*").permitAll()
                 .antMatchers("/appVersion/checkIosReview").permitAll()
+                .antMatchers("/druid/**").permitAll()
                 // all other requests need to be authenticated
                 .anyRequest().authenticated().and()
                 // make sure we use stateless session; session won't be used to

+ 9 - 0
src/main/java/com/izouma/nineth/service/UserService.java

@@ -476,6 +476,15 @@ public class UserService {
         }
     }
 
+    public void removeAuth(Long userId) {
+        User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
+        if (user.getAuthStatus() == AuthStatus.SUCCESS) {
+            user.setAuthStatus(AuthStatus.NOT_AUTH);
+            userRepo.save(user);
+            identityAuthRepo.deleteAll(identityAuthRepo.findByUserIdAndDelFalse(userId));
+        }
+    }
+
     public Map<String, Object> batchRegister(String phones, String defaultPassword) {
         List<String> exist = new ArrayList<>();
         List<String> err = new ArrayList<>();

+ 12 - 0
src/main/java/com/izouma/nineth/web/UserController.java

@@ -226,6 +226,18 @@ public class UserController extends BaseController {
         userService.removeBankCard(SecurityUtils.getAuthenticatedUser().getId());
     }
 
+    @PostMapping("/removeBankCardAdmin")
+    @PreAuthorize("hasAnyRole('ADMIN')")
+    public void removeBankCardAdmin(@RequestParam Long userId) throws BaseAdaPayException {
+        userService.removeBankCard(userId);
+    }
+
+    @PostMapping("/removeAuthAdmin")
+    @PreAuthorize("hasAnyRole('ADMIN')")
+    public void removeAuthAdmin(@RequestParam Long userId) {
+        userService.removeAuth(userId);
+    }
+
     @PreAuthorize("hasAnyRole('ADMIN')")
     @PostMapping("/batchRegister")
     public Map<String, Object> batchRegister(@RequestParam String phones, @RequestParam String defaultPassword) {

+ 48 - 4
src/main/resources/application.yaml

@@ -16,13 +16,57 @@ spring:
     username: raex
     password: K@SdS7e6NTw4CK
     hikari:
-      minimum-idle: 5
-      maximum-pool-size: 30
+      minimum-idle: 20
+      maximum-pool-size: 300
       auto-commit: true
-      idle-timeout: 30000
+      idle-timeout: 7200
       max-lifetime: 1800000
-      connection-timeout: 30000
+      connection-timeout: 5000
       connection-test-query: SELECT 1
+    druid:
+      # 连接池的配置信息
+      # 初始化大小,最小,最大
+      initial-size: 10
+      min-idle: 10
+      maxActive: 300
+      # 配置获取连接等待超时的时间
+      maxWait: 10000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      validationQuery: SELECT 1
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      # 打开PSCache,并且指定每个连接上PSCache的大小
+      poolPreparedStatements: true
+      maxPoolPreparedStatementPerConnectionSize: 20
+      # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+      filters: stat,wall,slf4j
+      # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
+      connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
+      remove-abandoned: true
+      remove-abandoned-timeout: 1800
+      log-abandoned: true
+      # 配置DruidStatFilter
+      web-stat-filter:
+        enabled: true
+        url-pattern: "/*"
+        exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
+      # 配置DruidStatViewServlet
+      stat-view-servlet:
+        enabled: true
+        url-pattern: "/druid/*"
+        login-username: admin
+        login-password: 3edc#EDC
+      filter:
+        wall:
+          enabled: true
+          config:
+            condition-and-alway-false-allow: true
+            condition-and-alway-true-allow: true
+            select-where-alway-true-check: false
   jpa:
     database: MySQL
     database_platform: org.hibernate.dialect.MySQL5InnoDBDialect

+ 90 - 4
src/main/vue/src/views/UserList.vue

@@ -8,7 +8,7 @@
                 导出
             </el-button>
         </page-title>
-        <div class="filters-container">
+        <div class="filters-container" @keyup.enter="getData">
             <el-input placeholder="搜索..." v-model="search" clearable class="filter-item search">
                 <el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
             </el-input>
@@ -43,9 +43,15 @@
             </el-table-column>
             <el-table-column label="手机" prop="phone"></el-table-column>
             <el-table-column label="创建时间" prop="createdAt" width="150"></el-table-column>
-            <el-table-column label="操作" align="center" fixed="right">
+            <el-table-column label="操作" align="center" fixed="right" width="200">
                 <template slot-scope="{ row }">
-                    <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
+                    <el-button @click="editRow(row)" type="text">编辑</el-button>
+                    <el-button @click="removeCard(row)" size="mini" type="text" :disabled="!row.settleAccountId"
+                        >解绑卡</el-button
+                    >
+                    <el-button @click="removeAuth(row)" size="mini" type="text" :disabled="row.authStatus !== 'SUCCESS'"
+                        >取消认证</el-button
+                    >
                 </template>
             </el-table-column>
         </el-table>
@@ -165,7 +171,7 @@ export default {
                     .then(res => {
                         let el = document.createElement('div');
                         new ClipboardJS(el, {
-                            text: function (trigger) {
+                            text: function(trigger) {
                                 return res;
                             }
                         });
@@ -177,6 +183,86 @@ export default {
                         this.$message.error(e.error);
                     });
             }
+        },
+        removeCard(row) {
+            this.$msgbox({
+                title: '确认解绑吗?',
+                message: '该操作无法撤回,请谨慎操作',
+                showCancelButton: true,
+                confirmButtonText: '确认',
+                cancelButtonText: '取消',
+                type: 'warning',
+                beforeClose: (action, instance, done) => {
+                    if (action === 'confirm') {
+                        instance.confirmButtonLoading = true;
+                        instance.showCancelButton = false;
+                        instance.closeOnClickModal = false;
+                        instance.showClose = false;
+                        this.$http
+                            .post('/user/removeBankCardAdmin', { userId: row.id })
+                            .then(res => {
+                                done();
+                                this.getData();
+                                this.$message.success('解绑成功');
+                                instance.confirmButtonLoading = false;
+                                instance.showCancelButton = true;
+                                instance.closeOnClickModal = true;
+                                instance.showClose = true;
+                            })
+                            .catch(e => {
+                                done();
+                                this.getData();
+                                this.$message.error(e.error || '解绑失败');
+                                instance.confirmButtonLoading = false;
+                                instance.showCancelButton = true;
+                                instance.closeOnClickModal = true;
+                                instance.showClose = true;
+                            });
+                    } else {
+                        done();
+                    }
+                }
+            }).then(_ => {});
+        },
+        removeAuth(row) {
+            this.$msgbox({
+                title: '确认取消认证吗?',
+                message: '该操作无法撤回,请谨慎操作',
+                showCancelButton: true,
+                confirmButtonText: '确认',
+                cancelButtonText: '取消',
+                type: 'warning',
+                beforeClose: (action, instance, done) => {
+                    if (action === 'confirm') {
+                        instance.confirmButtonLoading = true;
+                        instance.showCancelButton = false;
+                        instance.closeOnClickModal = false;
+                        instance.showClose = false;
+                        this.$http
+                            .post('/user/removeAuthAdmin', { userId: row.id })
+                            .then(res => {
+                                done();
+                                this.getData();
+                                this.$message.success('取消认证成功');
+                                instance.confirmButtonLoading = false;
+                                instance.showCancelButton = true;
+                                instance.closeOnClickModal = true;
+                                instance.showClose = true;
+                            })
+                            .catch(e => {
+                                done();
+                                this.getData();
+                                this.$message.error(e.error || '取消认证失败');
+                                instance.confirmButtonLoading = false;
+                                instance.showCancelButton = true;
+                                instance.closeOnClickModal = true;
+                                instance.showClose = true;
+                            });
+                    } else {
+                        done();
+                    }
+                }
+            }).then(_ => {});
         }
     }
 };