Procházet zdrojové kódy

Merge branch 'dev'

# Conflicts:
#	src/main/resources/application.yaml
wangqifan před 3 roky
rodič
revize
4699e9286a
57 změnil soubory, kde provedl 917 přidání a 1914 odebrání
  1. 19 29
      pom.xml
  2. 0 2
      src/main/java/com/izouma/nineth/Application.java
  3. 1 1
      src/main/java/com/izouma/nineth/config/CacheConfig.java
  4. 3 1
      src/main/java/com/izouma/nineth/config/RedisKeys.java
  5. 1 0
      src/main/java/com/izouma/nineth/config/WebMvcConfig.java
  6. 8 1
      src/main/java/com/izouma/nineth/domain/Showroom.java
  7. 12 1
      src/main/java/com/izouma/nineth/domain/TestClass.java
  8. 17 2
      src/main/java/com/izouma/nineth/domain/User.java
  9. 0 20
      src/main/java/com/izouma/nineth/domain/UserToken.java
  10. 9 1
      src/main/java/com/izouma/nineth/exception/GlobalExceptionHandler.java
  11. 3 0
      src/main/java/com/izouma/nineth/repo/NewsLikeRepo.java
  12. 3 1
      src/main/java/com/izouma/nineth/repo/ShowCollectionRepo.java
  13. 5 0
      src/main/java/com/izouma/nineth/repo/ShowroomRepo.java
  14. 3 2
      src/main/java/com/izouma/nineth/repo/TestClassRepo.java
  15. 10 10
      src/main/java/com/izouma/nineth/repo/UserRepo.java
  16. 0 14
      src/main/java/com/izouma/nineth/repo/UserTokenRepo.java
  17. 11 13
      src/main/java/com/izouma/nineth/security/JwtAuthorizationTokenFilter.java
  18. 13 14
      src/main/java/com/izouma/nineth/security/JwtTokenUtil.java
  19. 3 2
      src/main/java/com/izouma/nineth/security/JwtUser.java
  20. 2 1
      src/main/java/com/izouma/nineth/security/JwtUserDetailsService.java
  21. 23 16
      src/main/java/com/izouma/nineth/security/WebSecurityConfig.java
  22. 41 0
      src/main/java/com/izouma/nineth/service/AirDropService.java
  23. 3 2
      src/main/java/com/izouma/nineth/service/AssetMintService.java
  24. 5 3
      src/main/java/com/izouma/nineth/service/BlindBoxItemService.java
  25. 11 11
      src/main/java/com/izouma/nineth/service/CacheService.java
  26. 0 8
      src/main/java/com/izouma/nineth/service/CollectionService.java
  27. 3 2
      src/main/java/com/izouma/nineth/service/IdentityAuthService.java
  28. 5 1
      src/main/java/com/izouma/nineth/service/OrderService.java
  29. 64 16
      src/main/java/com/izouma/nineth/service/ShowroomService.java
  30. 50 100
      src/main/java/com/izouma/nineth/service/UserService.java
  31. 6 7
      src/main/java/com/izouma/nineth/service/sms/AliSmsService.java
  32. 0 4
      src/main/java/com/izouma/nineth/web/AppErrorController.java
  33. 8 32
      src/main/java/com/izouma/nineth/web/AuthenticationController.java
  34. 1 0
      src/main/java/com/izouma/nineth/web/BannerController.java
  35. 9 8
      src/main/java/com/izouma/nineth/web/BlindBoxItemController.java
  36. 19 1
      src/main/java/com/izouma/nineth/web/CollectionController.java
  37. 8 3
      src/main/java/com/izouma/nineth/web/DevelopController.java
  38. 1 0
      src/main/java/com/izouma/nineth/web/MintActivityController.java
  39. 3 0
      src/main/java/com/izouma/nineth/web/NewsController.java
  40. 12 0
      src/main/java/com/izouma/nineth/web/NewsLikeController.java
  41. 6 0
      src/main/java/com/izouma/nineth/web/PrivilegeOptionController.java
  42. 1 0
      src/main/java/com/izouma/nineth/web/RecommendController.java
  43. 44 0
      src/main/java/com/izouma/nineth/web/RedisCacheController.java
  44. 56 14
      src/main/java/com/izouma/nineth/web/ShowroomController.java
  45. 17 15
      src/main/java/com/izouma/nineth/web/TestClassController.java
  46. 3 3
      src/main/java/com/izouma/nineth/web/UserController.java
  47. 1 1
      src/main/nine-space/.env.app_raex
  48. 1 1
      src/main/nine-space/.env.development_raex
  49. 38 12
      src/main/resources/application.yaml
  50. 20 21
      src/main/resources/logback-spring.xml
  51. 187 1460
      src/main/vue/package-lock.json
  52. 1 1
      src/main/vue/public/index.html
  53. 1 1
      src/main/vue/src/views/Admin.vue
  54. 86 7
      src/test/java/com/izouma/nineth/CommonTest.java
  55. 21 0
      src/test/java/com/izouma/nineth/service/AirDropServiceTest.java
  56. 2 2
      src/test/java/com/izouma/nineth/service/ShowroomServiceTest.java
  57. 37 47
      src/test/java/com/izouma/nineth/service/UserServiceTest.java

+ 19 - 29
pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.3.2.RELEASE</version>
+        <version>2.6.5</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <groupId>com.izouma</groupId>
@@ -30,7 +30,7 @@
     </repositories>
 
     <properties>
-        <java.version>1.8</java.version>
+        <java.version>11</java.version>
         <skipTests>true</skipTests>
         <poi.verion>3.17</poi.verion>
         <javawx.version>3.5.0</javawx.version>
@@ -43,13 +43,13 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>9</source>
-                    <target>9</target>
+                    <excludes>
+                        <exclude>
+                            <groupId>org.projectlombok</groupId>
+                            <artifactId>lombok</artifactId>
+                        </exclude>
+                    </excludes>
                 </configuration>
             </plugin>
         </plugins>
@@ -88,29 +88,14 @@
             <artifactId>spring-boot-starter-aop</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-activemq</artifactId>
-        </dependency>
-
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-cache</artifactId>
         </dependency>
 
         <dependency>
-            <groupId>org.springframework.data</groupId>
-            <artifactId>spring-data-redis</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>redis.clients</groupId>
-            <artifactId>jedis</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>io.lettuce</groupId>
-            <artifactId>lettuce-core</artifactId>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
         </dependency>
 
         <dependency>
@@ -329,13 +314,11 @@
         <dependency>
             <groupId>io.netty</groupId>
             <artifactId>netty-all</artifactId>
-            <version>4.1.29.Final</version>
         </dependency>
 
         <dependency>
             <groupId>io.netty</groupId>
             <artifactId>netty-tcnative-boringssl-static</artifactId>
-            <version>2.0.17.Final</version>
         </dependency>
 
         <dependency>
@@ -386,7 +369,7 @@
         <dependency>
             <groupId>net.coobird</groupId>
             <artifactId>thumbnailator</artifactId>
-            <version>0.4.14</version>
+            <version>0.4.17</version>
         </dependency>
 
         <dependency>
@@ -410,7 +393,7 @@
         <dependency>
             <groupId>org.apache.rocketmq</groupId>
             <artifactId>rocketmq-spring-boot-starter</artifactId>
-            <version>2.2.0</version>
+            <version>2.2.1</version>
         </dependency>
 
         <dependency>
@@ -430,6 +413,13 @@
             <artifactId>bucket4j-core</artifactId>
             <version>7.3.0</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.github.marschall</groupId>
+            <artifactId>hibernate-batch-sequence-generator</artifactId>
+            <version>2.0.1</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 0 - 2
src/main/java/com/izouma/nineth/Application.java

@@ -7,11 +7,9 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
 import org.springframework.retry.annotation.EnableRetry;
 import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
 @SpringBootApplication
 @EnableJpaAuditing
-@EnableSwagger2
 @EnableCaching
 @EnableScheduling
 @EnableAsync

+ 1 - 1
src/main/java/com/izouma/nineth/config/CacheConfig.java

@@ -33,7 +33,7 @@ import java.util.Map;
 
 @Configuration
 @AutoConfigureAfter({RedisAutoConfiguration.class, CacheAutoConfiguration.class})
-@EnableRedisRepositories
+@EnableRedisRepositories(basePackages = "com.izouma.nineth.repo.redis")
 public class CacheConfig {
 
     @Bean

+ 3 - 1
src/main/java/com/izouma/nineth/config/RedisKeys.java

@@ -31,5 +31,7 @@ public class RedisKeys {
 
     public static final String BLACK_LIST = "blackList::";
 
-    private static final String VIP_COLLECTION_LIST = "vipCollectionList";
+    public static final String VIP_COLLECTION_LIST = "vipCollectionList";
+
+    public static final String JWT_TOKEN = "jwtToken::";
 }

+ 1 - 0
src/main/java/com/izouma/nineth/config/WebMvcConfig.java

@@ -95,6 +95,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
     public void addCorsMappings(CorsRegistry registry) {
         registry.addMapping("/**")
                 .allowedHeaders("*")
+                .allowedOriginPatterns("*")
                 .allowCredentials(true)
                 .allowedMethods("HEAD", "GET", "PUT", "POST", "DELETE", "PATCH")
                 .exposedHeaders("Content-Disposition");

+ 8 - 1
src/main/java/com/izouma/nineth/domain/Showroom.java

@@ -21,13 +21,17 @@ import java.util.List;
 @Entity
 @Table(indexes = {
         @Index(columnList = "userId"),
-        @Index(columnList = "assetId")
+        @Index(columnList = "assetId"),
+        @Index(columnList = "likes"),
+        @Index(columnList = "share")
 })
 @Where(clause = "del = 0")
 @ApiModel("展厅")
 public class Showroom extends BaseEntity {
     private Long userId;
 
+    private String nickname;
+
     private Long assetId;
 
     @ApiModelProperty("头像")
@@ -49,4 +53,7 @@ public class Showroom extends BaseEntity {
 
     @Transient
     private List<ShowCollection> collections;
+
+    @Transient
+    private boolean liked;
 }

+ 12 - 1
src/main/java/com/izouma/nineth/domain/TestClass.java

@@ -6,12 +6,23 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
 
 @Data
 @Entity
 @AllArgsConstructor
 @NoArgsConstructor
 @Builder
-public class TestClass extends BaseEntity {
+public class TestClass {
+    public TestClass(String name) {
+        this.name = name;
+    }
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
     private String name;
 }

+ 17 - 2
src/main/java/com/izouma/nineth/domain/User.java

@@ -27,7 +27,7 @@ import java.util.Set;
 @Data
 @Entity
 @Table(indexes = {
-        @Index(columnList = "phone"),
+        @Index(columnList = "phone", unique = true, name = "user_index_phone"),
         @Index(columnList = "collectionId"),
         @Index(columnList = "collectionInvitor"),
         @Index(columnList = "admin"),
@@ -39,7 +39,22 @@ import java.util.Set;
 @NoArgsConstructor
 @Builder
 @ApiModel(value = "用户", description = "用户")
-public class User extends BaseEntity implements Serializable {
+public class User extends BaseEntityNoID implements Serializable {
+
+    @Id
+//    @GenericGenerator(
+//            name = "some_column_name_id_generator",
+//            strategy = "com.github.marschall.hibernate.batchsequencegenerator.BatchSequenceGenerator",
+//            parameters = {
+//                    @org.hibernate.annotations.Parameter(name = "sequence", value = "user_sequence"),
+//                    @org.hibernate.annotations.Parameter(name = "fetch_size", value = "50")
+//            })
+//    @GeneratedValue(generator = "user_id_generator")
+
+    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_seq")
+    @SequenceGenerator(name = "user_seq", sequenceName = "user_seq", allocationSize = 100, initialValue = 1890000)
+//    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
 
     //    @Pattern(regexp = Constants.Regex.USERNAME)
     @Size(min = 1, max = 50)

+ 0 - 20
src/main/java/com/izouma/nineth/domain/UserToken.java

@@ -1,20 +0,0 @@
-package com.izouma.nineth.domain;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.springframework.data.annotation.Id;
-import org.springframework.data.redis.core.RedisHash;
-
-
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-@RedisHash("UserToken")
-public class UserToken {
-
-    @Id
-    private String username;
-
-    private String token;
-}

+ 9 - 1
src/main/java/com/izouma/nineth/exception/GlobalExceptionHandler.java

@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 @ControllerAdvice
@@ -86,8 +87,15 @@ public class GlobalExceptionHandler {
             modelAndView.addObject("trace", trace);
             return modelAndView;
         } else {
+            String message = e.getMessage();
+            if (Pattern.matches(".*SQL.*constraint.*user_index_phone.*", e.getMessage())) {
+                message = "手机号已注册";
+            }
+            if (Pattern.matches(".*SQL.*constraint.*username.*", e.getMessage())) {
+                message = "用户名已存在";
+            }
             Map<String, Object> map = new HashMap<>();
-            map.put("error", e.getMessage());
+            map.put("error", message);
             map.put("code", -1);
             return map;
         }

+ 3 - 0
src/main/java/com/izouma/nineth/repo/NewsLikeRepo.java

@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
 import javax.transaction.Transactional;
+import java.util.Collection;
 import java.util.List;
 
 public interface NewsLikeRepo extends JpaRepository<NewsLike, Long>, JpaSpecificationExecutor<NewsLike> {
@@ -18,4 +19,6 @@ public interface NewsLikeRepo extends JpaRepository<NewsLike, Long>, JpaSpecific
     List<NewsLike> findByUserIdAndNewsId(Long userId, Long newsId);
 
     List<NewsLike> findByUserIdAndShowroomId(Long userId, Long showroomId);
+
+    List<NewsLike> findByUserIdAndShowroomIdIn(Long userId, Collection<Long> showroomId);
 }

+ 3 - 1
src/main/java/com/izouma/nineth/repo/ShowCollectionRepo.java

@@ -23,12 +23,14 @@ public interface ShowCollectionRepo extends JpaRepository<ShowCollection, Long>,
 
     List<ShowCollection> findAllByShowroomId(Long showroomId);
 
+    List<ShowCollection> findAllByShowroomIdIn(Collection<Long> showroomId);
+
     @Query("update ShowCollection t set t.del = true where t.showroomId = ?1")
     @Modifying
     @Transactional
     void softDeleteByRoom(Long showroomId);
 
-    @Query("update ShowCollection t set t.del = true where t.showroomId in ?1")
+    @Query("update ShowCollection t set t.del = true where t.id in ?1")
     @Modifying
     @Transactional
     void softDeleteByIdIn(Collection<Long> ids);

+ 5 - 0
src/main/java/com/izouma/nineth/repo/ShowroomRepo.java

@@ -23,4 +23,9 @@ public interface ShowroomRepo extends JpaRepository<Showroom, Long>, JpaSpecific
     Optional<Showroom> findByUserIdAndAssetId(Long userId, Long assetId);
 
     Optional<Showroom> findByAssetId(Long assetId);
+
+    @Query("update Showroom t set t.share = t.share + ?2 where t.id = ?1")
+    @Modifying
+    @Transactional
+    void addShare(Long id, int num);
 }

+ 3 - 2
src/main/java/com/izouma/nineth/repo/TestClassRepo.java

@@ -9,8 +9,9 @@ import org.springframework.data.jpa.repository.Query;
 import javax.transaction.Transactional;
 
 public interface TestClassRepo extends JpaRepository<TestClass, Long>, JpaSpecificationExecutor<TestClass> {
-    @Query("update TestClass t set t.del = true where t.id = ?1")
+
     @Modifying
     @Transactional
-    void softDelete(Long id);
+    @Query(value = "insert into test_class (name) values (?1)", nativeQuery = true)
+    public void nativeSave(String name);
 }

+ 10 - 10
src/main/java/com/izouma/nineth/repo/UserRepo.java

@@ -3,13 +3,11 @@ package com.izouma.nineth.repo;
 import com.izouma.nineth.domain.User;
 import com.izouma.nineth.enums.AuthStatus;
 import com.izouma.nineth.security.Authority;
-import org.springframework.cache.annotation.CachePut;
 import org.springframework.cache.annotation.Cacheable;
 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 org.springframework.lang.NonNull;
 
 import javax.transaction.Transactional;
 import java.time.LocalDateTime;
@@ -23,12 +21,7 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
     @Query("update User u set u.del = true where u.id = ?1")
     void softDelete(Long id);
 
-    @NonNull
-    @CachePut(value = "userInfo", key = "#user.id")
-    User save(@NonNull User user);
-
-    @Cacheable("user")
-    User findByUsernameAndDelFalse(String username);
+    Optional<User> findByUsernameAndDelFalse(String username);
 
     List<User> findAllByAuthoritiesContainsAndDelFalse(Authority authority);
 
@@ -36,6 +29,7 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
 
     Optional<User> findByPhoneAndDelFalse(String phone);
 
+    @Cacheable(value = "user", key = "#userId")
     Optional<User> findByIdAndDelFalse(Long userId);
 
     @Transactional
@@ -176,8 +170,6 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
 
     long countAllByAuthoritiesContainsAndDelFalse(Authority authority);
 
-    List<User> findAllByCreatedAtBetweenAndAuthoritiesContains(LocalDateTime start, LocalDateTime end, Authority authorities);
-
     List<User> findAllByCreatedAtIsAfterAndAuthoritiesContains(LocalDateTime createdAt, Authority authorities);
 
     List<User> findBySettleAccountIdIsNotNull();
@@ -210,4 +202,12 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
     void updateAllByInvitor(Collection<Long> ids);
 
     List<User> findAllByCollectionId(Long collectionId);
+
+    @Query(value = "update showroom join user on showroom.user_id = user.id " +
+            "set showroom.nickname = user.nickname " +
+            "where user.id = ?1 ", nativeQuery = true)
+    @Modifying
+    @Transactional
+    void updateShowroomToUser(Long userId);
+
 }

+ 0 - 14
src/main/java/com/izouma/nineth/repo/UserTokenRepo.java

@@ -1,14 +0,0 @@
-package com.izouma.nineth.repo;
-
-import com.izouma.nineth.domain.UserToken;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Modifying;
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.stereotype.Repository;
-
-import javax.transaction.Transactional;
-import java.util.Optional;
-
-@Repository
-public interface UserTokenRepo extends CrudRepository<UserToken, String> {
-}

+ 11 - 13
src/main/java/com/izouma/nineth/security/JwtAuthorizationTokenFilter.java

@@ -48,9 +48,9 @@ public class JwtAuthorizationTokenFilter extends OncePerRequestFilter {
             try {
                 username = jwtTokenUtil.getUsernameFromToken(authToken);
             } catch (IllegalArgumentException e) {
-                log.error("an error occurred during getting username from token", e);
+                log.error("an error occurred during getting username from token");
             } catch (ExpiredJwtException e) {
-                log.warn("the token is expired and not valid anymore", e);
+                log.warn("the token is expired and not valid anymore");
             } catch (SignatureException e) {
                 log.error(e.getMessage());
             }
@@ -67,19 +67,17 @@ public class JwtAuthorizationTokenFilter extends OncePerRequestFilter {
             UserDetails userDetails;
             try {
                 userDetails = userDetailsService.loadUserByUsername(username);
+
+                // For simple validation it is completely sufficient to just check the token integrity. You don't have to call
+                // the database compellingly. Again it's up to you ;)
+                if (jwtTokenUtil.validateToken(authToken, userDetails)) {
+                    UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
+                    authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
+                    SecurityContextHolder.getContext().setAuthentication(authentication);
+                }
             } catch (Exception e) {
                 //response.sendError(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage());
-                chain.doFilter(request, response);
-                return;
-            }
-
-
-            // For simple validation it is completely sufficient to just check the token integrity. You don't have to call
-            // the database compellingly. Again it's up to you ;)
-            if (jwtTokenUtil.validateToken(authToken, userDetails)) {
-                UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
-                authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
-                SecurityContextHolder.getContext().setAuthentication(authentication);
+                log.error(e.getMessage());
             }
         }
 

+ 13 - 14
src/main/java/com/izouma/nineth/security/JwtTokenUtil.java

@@ -1,21 +1,22 @@
 package com.izouma.nineth.security;
 
-import com.izouma.nineth.domain.UserToken;
-import com.izouma.nineth.repo.UserTokenRepo;
+import com.izouma.nineth.config.RedisKeys;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import io.jsonwebtoken.Claims;
 import io.jsonwebtoken.Clock;
 import io.jsonwebtoken.Jwts;
 import io.jsonwebtoken.SignatureAlgorithm;
 import io.jsonwebtoken.impl.DefaultClock;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.stereotype.Component;
 
 import java.io.Serializable;
+import java.time.Duration;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Optional;
+import java.util.Objects;
 import java.util.function.Function;
 
 @Component
@@ -30,11 +31,11 @@ public class JwtTokenUtil implements Serializable {
     private Clock     clock = DefaultClock.INSTANCE;
     private JwtConfig jwtConfig;
 
-    private final UserTokenRepo userTokenRepo;
+    private final RedisTemplate<String, Object> redisTemplate;
 
-    public JwtTokenUtil(JwtConfig jwtConfig, UserTokenRepo userTokenRepo) {
+    public JwtTokenUtil(JwtConfig jwtConfig, RedisTemplate<String, Object> redisTemplate) {
         this.jwtConfig = jwtConfig;
-        this.userTokenRepo = userTokenRepo;
+        this.redisTemplate = redisTemplate;
     }
 
     public String getUsernameFromToken(String token) {
@@ -63,11 +64,9 @@ public class JwtTokenUtil implements Serializable {
 
     private Boolean isTokenExpired(String token) {
         final Date expiration = getExpirationDateFromToken(token);
-        Optional<UserToken> userToken = userTokenRepo.findById(getUsernameFromToken(token));
-        if (!userToken.isPresent()) {
-            return true;
-        }
-        if (!token.equals(userToken.get().getToken())) {
+        String username = getUsernameFromToken(token);
+        Object redisToken = redisTemplate.opsForValue().get(RedisKeys.JWT_TOKEN + username);
+        if (redisToken != null && !Objects.equals(redisToken, token)) {
             return true;
         }
         return expiration.before(clock.now());
@@ -86,8 +85,8 @@ public class JwtTokenUtil implements Serializable {
         JwtUser jwtUser = (JwtUser) userDetails;
         Map<String, Object> claims = new HashMap<>();
         String token = doGenerateToken(claims, userDetails.getUsername());
-        userTokenRepo.deleteById(jwtUser.getUser().getUsername());
-        userTokenRepo.save(new UserToken(jwtUser.getUser().getUsername(), token));
+        redisTemplate.opsForValue().set(RedisKeys.JWT_TOKEN + userDetails.getUsername(),
+                token, Duration.ofDays(30));
         return token;
     }
 
@@ -100,7 +99,7 @@ public class JwtTokenUtil implements Serializable {
                 .setSubject(subject)
                 .setIssuedAt(createdDate)
                 .setExpiration(expirationDate)
-                .signWith(SignatureAlgorithm.HS512, jwtConfig.getSecret())
+                .signWith(SignatureAlgorithm.HS256, jwtConfig.getSecret())
                 .compact();
     }
 

+ 3 - 2
src/main/java/com/izouma/nineth/security/JwtUser.java

@@ -8,6 +8,7 @@ import org.springframework.security.core.userdetails.UserDetails;
 import java.time.ZoneId;
 import java.util.Collection;
 import java.util.Date;
+import java.util.Optional;
 
 /**
  * Created by stephan on 20.03.16.
@@ -18,7 +19,7 @@ public class JwtUser implements UserDetails {
 
     private final Collection<? extends GrantedAuthority> authorities;
     private final Date                                   lastPasswordResetDate;
-    private       User                                   user;
+    private final User                                   user;
 
     public JwtUser(User user, Collection<? extends GrantedAuthority> authorities) {
         this.authorities = authorities;
@@ -33,7 +34,7 @@ public class JwtUser implements UserDetails {
 
     @Override
     public String getUsername() {
-        return user.getUsername();
+        return Optional.ofNullable(user.getId()).map(Object::toString).orElse(null);
     }
 
     @JsonIgnore

+ 2 - 1
src/main/java/com/izouma/nineth/security/JwtUserDetailsService.java

@@ -15,7 +15,8 @@ public class JwtUserDetailsService implements UserDetailsService {
 
     @Override
     public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
-        User user = userRepo.findByUsernameAndDelFalse(username);
+        Long userId = Long.parseLong(username);
+        User user = userRepo.findById(userId).orElseThrow(null);
 
         if (user == null) {
             throw new UsernameNotFoundException(String.format("No user found with username '%s'.", username));

+ 23 - 16
src/main/java/com/izouma/nineth/security/WebSecurityConfig.java

@@ -1,6 +1,6 @@
 package com.izouma.nineth.security;
 
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
@@ -13,6 +13,7 @@ import org.springframework.security.config.annotation.web.builders.WebSecurity;
 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
 import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@@ -22,28 +23,30 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
 @EnableConfigurationProperties({JwtConfig.class})
 public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
 
-    @Autowired
-    private JwtAuthenticationEntryPoint unauthorizedHandler;
+    private final JwtAuthenticationEntryPoint unauthorizedHandler;
+    private final UserDetailsService          userDetailsService;
+    private final JwtAuthorizationTokenFilter authenticationTokenFilter;
+    private final String                      tokenHeader;
 
-    @Autowired
-    private JwtUserDetailsService jwtUserDetailsService;
-
-    // Custom JWT based security filter
-    @Autowired
-    JwtAuthorizationTokenFilter authenticationTokenFilter;
-
-    @Value("${jwt.header}")
-    private String tokenHeader;
+    public WebSecurityConfig(JwtAuthenticationEntryPoint unauthorizedHandler,
+                             @Qualifier("jwtUserDetailsService") UserDetailsService userDetailsService,
+                             JwtAuthorizationTokenFilter authenticationTokenFilter,
+                             @Value("${jwt.header}") String tokenHeader) {
+        this.unauthorizedHandler = unauthorizedHandler;
+        this.userDetailsService = userDetailsService;
+        this.authenticationTokenFilter = authenticationTokenFilter;
+        this.tokenHeader = tokenHeader;
+    }
 
-    @Autowired
-    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
-        auth.userDetailsService(jwtUserDetailsService)
+    @Override
+    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+        auth.userDetailsService(userDetailsService)
                 .passwordEncoder(passwordEncoderBean());
     }
 
     @Bean
     public PasswordEncoder passwordEncoderBean() {
-        return new BCryptPasswordEncoder();
+        return new BCryptPasswordEncoder(4);
     }
 
     @Bean
@@ -96,6 +99,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/blindBoxItem/all").permitAll()
                 .antMatchers("/collection/recommend").permitAll()
                 .antMatchers("/order/**/status").permitAll()
+                .antMatchers("/order/checkLimit").permitAll()
                 .antMatchers("/mintOrder/**/status").permitAll()
                 .antMatchers("/activity/all").permitAll()
                 .antMatchers("/activity/get/*").permitAll()
@@ -110,6 +114,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/druid/**").permitAll()
                 .antMatchers("/identityAuth/autoAuth").permitAll()
                 .antMatchers("/statistic/weekTop").permitAll()
+                .antMatchers("/showroom/all").permitAll()
+                .antMatchers("/showroom/get/**").permitAll()
+                .antMatchers("/testClass/**").permitAll()
                 // all other requests need to be authenticated
                 .anyRequest().authenticated().and()
                 // make sure we use stateless session; session won't be used to

+ 41 - 0
src/main/java/com/izouma/nineth/service/AirDropService.java

@@ -1,5 +1,6 @@
 package com.izouma.nineth.service;
 
+import com.izouma.nineth.TokenHistory;
 import com.izouma.nineth.domain.*;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.enums.AirDropType;
@@ -13,6 +14,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
 import java.util.List;
 
 @Service
@@ -27,6 +29,9 @@ public class AirDropService {
     private UserRepo          userRepo;
     private AssetService      assetService;
     private CollectionService collectionService;
+    private ShowroomService   showroomService;
+    private TokenHistoryRepo  tokenHistoryRepo;
+    private AssetRepo         assetRepo;
 
     public Page<AirDrop> all(PageQuery pageQuery) {
         return airDropRepo.findAll(JpaUtils.toSpecification(pageQuery, AirDrop.class), JpaUtils.toPageRequest(pageQuery));
@@ -72,6 +77,10 @@ public class AirDropService {
                         } else {
                             assetService.createAsset(collection, user, null, null, "空投", collectionService.getNextNumber(collection.getId()));
                         }
+                        Asset asset = assetService.createAsset(collection, user, null, null, "空投", collectionService.getNextNumber(collection.getId()));
+                        if (collection.getType() == CollectionType.SHOWROOM) {
+                            showroomService.save(asset);
+                        }
                     }
                     collectionService.decreaseStock(collection.getId(), 1);
                     collectionService.increaseSale(collection.getId(), 1);
@@ -82,4 +91,36 @@ public class AirDropService {
         }
         return airDropRepo.save(record);
     }
+
+    public void drop(Long collectionId, Long userId, int num, LocalDateTime time) {
+        Collection collection = collectionRepo.findById(collectionId)
+                .orElseThrow(new BusinessException("藏品不存在"));
+        User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
+        try {
+            for (int i = 0; i < num; i++) {
+                Asset asset;
+                if (collection.getType() == CollectionType.BLIND_BOX) {
+                    BlindBoxItem winItem = collectionService.draw(collection.getId());
+                    asset = assetService.createAsset(winItem, user, 0L, collection.getPrice(), "出售",
+                            winItem.getTotal() > 1 ? collectionService.getNextNumber(winItem.getCollectionId()) : null,
+                            collection.getHoldDays());
+                } else {
+                    asset = assetService.createAsset(collection, user, 0L, collection.getPrice(), "出售",
+                            collection.getTotal() > 1 ? collectionService.getNextNumber(collection.getId()) : null);
+                }
+                assetRepo.flush();
+                tokenHistoryRepo.flush();
+
+                asset.setCreatedAt(time.plusSeconds((long) (Math.random() * 120)));
+                assetRepo.save(asset);
+
+                for (TokenHistory tokenHistory : tokenHistoryRepo.findByTokenIdOrderByCreatedAtDesc(asset.getTokenId())) {
+                    tokenHistory.setCreatedAt(asset.getCreatedAt());
+                    tokenHistoryRepo.save(tokenHistory);
+                }
+            }
+        } catch (Exception e) {
+            log.error("空投出错", e);
+        }
+    }
 }

+ 3 - 2
src/main/java/com/izouma/nineth/service/AssetMintService.java

@@ -34,6 +34,7 @@ public class AssetMintService {
     private NFTService         nftService;
     private ApplicationContext applicationContext;
     private Environment        env;
+    private UserService        userService;
 
     @Retryable(maxAttempts = 10, backoff = @Backoff(delay = 1000))
     public void mint(Long assetId) {
@@ -44,7 +45,7 @@ public class AssetMintService {
             user.setNftAccount(account.getAccountId());
             user.setKmsId(account.getAccountKmsId());
             user.setPublicKey(account.getPublicKey());
-            userRepo.save(user);
+            userService.save(user);
         }
         try {
             NFT nft = nftService.createToken(user.getNftAccount(), asset.getTokenId());
@@ -74,7 +75,7 @@ public class AssetMintService {
 //            user.setNftAccount(account.getAccountId());
 //            user.setKmsId(account.getAccountKmsId());
 //            user.setPublicKey(account.getPublicKey());
-//            userRepo.save(user);
+//            userService.save(user);
 //        }
 //        try {
 //            NFT nft = nftService.createToken(user.getNftAccount(), asset.getTokenId());

+ 5 - 3
src/main/java/com/izouma/nineth/service/BlindBoxItemService.java

@@ -2,10 +2,11 @@ package com.izouma.nineth.service;
 
 import com.izouma.nineth.domain.BlindBoxItem;
 import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.dto.PageWrapper;
 import com.izouma.nineth.repo.BlindBoxItemRepo;
 import com.izouma.nineth.utils.JpaUtils;
 import lombok.AllArgsConstructor;
-import org.springframework.data.domain.Page;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 @Service
@@ -14,7 +15,8 @@ public class BlindBoxItemService {
 
     private BlindBoxItemRepo blindBoxItemRepo;
 
-    public Page<BlindBoxItem> all(PageQuery pageQuery) {
-        return blindBoxItemRepo.findAll(JpaUtils.toSpecification(pageQuery, BlindBoxItem.class), JpaUtils.toPageRequest(pageQuery));
+    @Cacheable(value = "blindBoxList", key = "#pageQuery.hashCode()")
+    public PageWrapper<BlindBoxItem> all(PageQuery pageQuery) {
+        return PageWrapper.of(blindBoxItemRepo.findAll(JpaUtils.toSpecification(pageQuery, BlindBoxItem.class), JpaUtils.toPageRequest(pageQuery)));
     }
 }

+ 11 - 11
src/main/java/com/izouma/nineth/service/CacheService.java

@@ -26,18 +26,18 @@ public class CacheService {
     public void clearUser() {
     }
 
-    @CacheEvict(value = "user", key = "#username")
-    public void clearUser(String username) {
-    }
-
-    @CacheEvict(value = "userInfo", key = "#id")
-    public void clearUserInfo(Long id) {
+    @CacheEvict(value = "user", key = "#id")
+    public void clearUser(Long id) {
     }
 
     @CacheEvict(value = "myUserInfo", key = "#id")
     public void clearUserMy(Long id) {
     }
 
+    @CacheEvict(value = "myUserInfo", allEntries = true)
+    public void clearUserMy() {
+    }
+
     @CacheEvict(value = "recommend", allEntries = true)
     public void clearRecommend() {
     }
@@ -55,27 +55,27 @@ public class CacheService {
     public void clearBannerList() {
     }
 
-    @Scheduled(fixedRate = 60000)
+    @Scheduled(fixedRate = 600000)
     @CacheEvict(value = "total", allEntries = true)
     public void clearTotal() {
     }
 
-    @Scheduled(fixedRate = 60000)
+    @Scheduled(fixedRate = 600000)
     @CacheEvict(value = "userTrend", allEntries = true)
     public void clearUserTrend() {
     }
 
-    @Scheduled(fixedRate = 60000)
+    @Scheduled(fixedRate = 600000)
     @CacheEvict(value = "orderNumTrend", allEntries = true)
     public void clearOrderNumTrend() {
     }
 
-    @Scheduled(fixedRate = 60000)
+    @Scheduled(fixedRate = 600000)
     @CacheEvict(value = "orderPriceTrend", allEntries = true)
     public void clearOrderPriceTrend() {
     }
 
-//    @Scheduled(fixedRate = 120000)
+    //    @Scheduled(fixedRate = 120000)
     @CacheEvict(value = "top", key = "#month")
     public void clearTop(int month) {
     }

+ 0 - 8
src/main/java/com/izouma/nineth/service/CollectionService.java

@@ -83,14 +83,6 @@ public class CollectionService {
         for (Collection collection : collections) {
             onShelfTask(collection);
         }
-        for (CollectionStockAndSale collection : collectionRepo.getStockAndSale()) {
-            if (redisTemplate.opsForValue().get(RedisKeys.COLLECTION_STOCK + collection.getId()) == null) {
-                redisTemplate.opsForValue().set(RedisKeys.COLLECTION_STOCK + collection.getId(), collection.getStock());
-            }
-            if (redisTemplate.opsForValue().get(RedisKeys.COLLECTION_SALE + collection.getId()) == null) {
-                redisTemplate.opsForValue().set(RedisKeys.COLLECTION_SALE + collection.getId(), collection.getSale());
-            }
-        }
     }
 
     @Cacheable(value = "collectionList", key = "#pageQuery.hashCode()")

+ 3 - 2
src/main/java/com/izouma/nineth/service/IdentityAuthService.java

@@ -38,6 +38,7 @@ public class IdentityAuthService {
 
     private IdentityAuthRepo              identityAuthRepo;
     private UserRepo                      userRepo;
+    private UserService                   userService;
     private AdapayService                 adapayService;
     private RedisTemplate<String, Object> redisTemplate;
     private Environment                   env;
@@ -63,7 +64,7 @@ public class IdentityAuthService {
         identityAuth.setStatus(AuthStatus.PENDING);
         identityAuthRepo.save(identityAuth);
         user.setAuthStatus(AuthStatus.PENDING);
-        userRepo.save(user);
+        userService.save(user);
         cacheService.clearUserMy(user.getId());
 
         identityAuthRepo.deleteDuplicated(identityAuth.getUserId(), identityAuth.getId());
@@ -80,7 +81,7 @@ public class IdentityAuthService {
                 user.setAuthId(auth.getId());
             }
             user.setAuthStatus(status);
-            userRepo.save(user);
+            userService.save(user);
         }
         auth.setStatus(status);
         auth.setReason(reason);

+ 5 - 1
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -92,6 +92,7 @@ public class OrderService {
     private SmsService                    smsService;
     private ErrorOrderRepo                errorOrderRepo;
     private ShowCollectionRepo            showCollectionRepo;
+    private ShowroomService               showroomService;
 
     public Page<Order> all(PageQuery pageQuery) {
         return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
@@ -622,8 +623,11 @@ public class OrderService {
 
                     } else {
                         orderRepo.save(order);
-                        assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售",
+                        Asset asset = assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售",
                                 collection.getTotal() > 1 ? collectionService.getNextNumber(order.getCollectionId()) : null);
+                        if (collection.getType() == CollectionType.SHOWROOM) {
+                            showroomService.save(asset);
+                        }
                     }
                 }
                 commission(order);

+ 64 - 16
src/main/java/com/izouma/nineth/service/ShowroomService.java

@@ -1,10 +1,8 @@
 package com.izouma.nineth.service;
 
 import cn.hutool.core.collection.CollUtil;
-import com.izouma.nineth.domain.Asset;
+import com.izouma.nineth.domain.*;
 import com.izouma.nineth.domain.Collection;
-import com.izouma.nineth.domain.ShowCollection;
-import com.izouma.nineth.domain.Showroom;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.enums.AssetStatus;
 import com.izouma.nineth.enums.CollectionType;
@@ -41,7 +39,7 @@ public class ShowroomService {
     /*
     不做盲盒
      */
-    public void save(Long userId, Showroom showroom) {
+    public Showroom save(Long userId, Showroom showroom) {
         Asset asset = assetRepo.findById(showroom.getAssetId()).orElseThrow(new BusinessException("资产不存在"));
         if (!userId.equals(asset.getUserId())) {
             throw new BusinessException("该资产不属于你");
@@ -85,21 +83,52 @@ public class ShowroomService {
         showroom.setUserId(userId);
         showroom.setShowroomBg(asset.getShowroomBg());
         showroom.setMaxCollection(asset.getMaxCollection());
+        showroom.setNickname(asset.getOwnerName());
         Showroom show = showroomRepo.save(showroom);
 
         showCollections.forEach(showCollection -> {
             Collection collection = collectionMap.get(showCollection.getCollectionId());
             if (ObjectUtils.isNotEmpty(collection)) {
-                showCollection.setPic(collection.getPic().get(0).getUrl());
+                FileObject pic = collection.getPic().get(0);
+                showCollection.setPic(pic.getUrl());
+                if("video/mp4".equals(pic.getType())){
+                    showCollection.setPic(pic.getThumb());
+                }
                 showCollection.setShowroomId(show.getId());
                 showCollection.setAssetId(collection.getAssetId());
                 showCollectionRepo.save(showCollection);
             }
         });
+        return show;
     }
 
-    public void update(Showroom showroom) {
+    public Showroom save(Asset asset) {
+        if (!AssetStatus.NORMAL.equals(asset.getStatus())) {
+            throw new BusinessException("该状态不可创建展厅");
+        }
+        if (asset.isConsignment()) {
+            throw new BusinessException("寄售中不可以创建");
+        }
+
+        if (showroomRepo.findByAssetId(asset.getId()).isPresent()) {
+            throw new BusinessException("已创建过展厅");
+        }
+        Showroom showroom = Showroom.builder()
+                .showroomBg(asset.getShowroomBg())
+                .maxCollection(asset.getMaxCollection())
+                .publish(false)
+                .userId(asset.getUserId())
+                .assetId(asset.getId())
+                .nickname(asset.getOwnerName())
+                .build();
+
+
+        return showroomRepo.save(showroom);
+    }
+
+    public Showroom update(Long userId, Showroom showroom) {
         Showroom recordRoom = showroomRepo.findById(showroom.getId()).orElseThrow(new BusinessException("无展厅"));
+        showroom.setMaxCollection(recordRoom.getMaxCollection());
         // 上传的藏品
         List<ShowCollection> showCollections = showroom.getCollections();
 
@@ -107,6 +136,9 @@ public class ShowroomService {
         Map<Long, ShowCollection> showCollectionMap = recordShowColls.stream()
                 .collect(Collectors.toMap(ShowCollection::getId, coll -> coll));
 
+        Map<Long, ShowCollection> showCollectionMap1 = recordShowColls.stream()
+                .collect(Collectors.toMap(ShowCollection::getCollectionId, coll -> coll));
+
         Set<Long> removeRecord = new HashSet<>(showCollectionMap.keySet());
 
         if (CollUtil.isNotEmpty(showCollections)) {
@@ -119,10 +151,15 @@ public class ShowroomService {
                     .filter(show -> ObjectUtils.isEmpty(show.getId()))
                     .map(ShowCollection::getCollectionId)
                     .collect(Collectors.toList());
-            Map<Long, Collection> collectionMap = collectionRepo.findAllByIdIn(collectionIds)
-                    .stream()
-                    .collect(Collectors.toMap(Collection::getId, coll -> coll));
 
+            List<Collection> collections = collectionRepo.findAllByIdIn(collectionIds);
+            Map<Long, Collection> collectionMap = new HashMap<>();
+            collections.forEach(collection -> {
+                if (!userId.equals(collection.getOwnerId())) {
+                    throw new BusinessException("该藏品不属于你");
+                }
+                collectionMap.put(collection.getId(), collection);
+            });
 
             showCollections.forEach(coll -> {
                 if (coll.getId() != null) {
@@ -134,12 +171,23 @@ public class ShowroomService {
                         removeRecord.remove(coll.getId());
                     }
                 } else {
-                    Collection collection = collectionMap.get(coll.getCollectionId());
-                    if (ObjectUtils.isNotEmpty(collection)) {
-                        coll.setPic(collection.getPic().get(0).getUrl());
-                        coll.setShowroomId(recordRoom.getId());
-                        coll.setAssetId(collection.getAssetId());
-                        showCollectionRepo.save(coll);
+                    ShowCollection showCollection = showCollectionMap1.get(coll.getCollectionId());
+                    if (ObjectUtils.isNotEmpty(showCollection)) {
+                        ObjUtils.merge(showCollection, coll);
+                        showCollectionRepo.save(showCollection);
+                        removeRecord.remove(showCollection.getId());
+                    } else {
+                        Collection collection = collectionMap.get(coll.getCollectionId());
+                        if (ObjectUtils.isNotEmpty(collection)) {
+                            FileObject pic = collection.getPic().get(0);
+                            coll.setPic(pic.getUrl());
+                            if("video/mp4".equals(pic.getType())){
+                                coll.setPic(pic.getThumb());
+                            }
+                            coll.setShowroomId(recordRoom.getId());
+                            coll.setAssetId(collection.getAssetId());
+                            showCollectionRepo.save(coll);
+                        }
                     }
                 }
             });
@@ -152,7 +200,7 @@ public class ShowroomService {
         }
 
         ObjUtils.merge(recordRoom, showroom);
-        showroomRepo.save(recordRoom);
+        return showroomRepo.save(recordRoom);
     }
 
 }

+ 50 - 100
src/main/java/com/izouma/nineth/service/UserService.java

@@ -45,7 +45,7 @@ import org.springframework.data.domain.PageImpl;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.Async;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.stereotype.Service;
 
 import javax.persistence.criteria.Predicate;
@@ -81,6 +81,7 @@ public class UserService {
     private RocketMQTemplate              rocketMQTemplate;
     private GeneralProperties             generalProperties;
     private RedisTemplate<String, Object> redisTemplate;
+    private PasswordEncoder               passwordEncoder;
 
     public User update(User user) {
         if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
@@ -98,14 +99,16 @@ public class UserService {
         userRepo.updateOrderMinter(orig.getId());
         userRepo.updateHistoryFromUser(orig.getId());
         userRepo.updateHistoryToUser(orig.getId());
+        userRepo.updateShowroomToUser(orig.getId());
         cacheService.clearCollection();
         cacheService.clearUserMy(user.getId());
         return orig;
     }
 
     public User save(User user) {
-        cacheService.clearUserInfo(user.getId());
-        cacheService.clearUser(user.getUsername());
+        if (user.getId() != null) {
+            cacheService.clearUserMy(user.getId());
+        }
         return userRepo.save(user);
     }
 
@@ -144,18 +147,14 @@ public class UserService {
     }
 
     public User create(UserRegister userRegister) {
-        if (StringUtils.isNoneEmpty(userRegister.getPhone()) && userRepo.findByPhoneAndDelFalse(userRegister.getPhone())
-                .orElse(null) != null) {
-            throw new BusinessException("该手机号已注册");
-        }
         User user = new User();
         BeanUtils.copyProperties(userRegister, user);
         user.setShareRatio(sysConfigService.getBigDecimal("share_ratio"));
         user.setAuthStatus(AuthStatus.NOT_AUTH);
         if (StringUtils.isNotBlank(userRegister.getPassword())) {
-            user.setPassword(new BCryptPasswordEncoder().encode(userRegister.getPassword()));
+            user.setPassword(passwordEncoder.encode(userRegister.getPassword()));
         }
-        return userRepo.save(user);
+        return save(user);
     }
 
     @EventListener
@@ -164,7 +163,7 @@ public class UserService {
             user.setNftAccount(event.getAccount().getAccountId());
             user.setKmsId(event.getAccount().getAccountKmsId());
             user.setPublicKey(event.getAccount().getPublicKey());
-            userRepo.save(user);
+            save(user);
         });
     }
 
@@ -191,7 +190,6 @@ public class UserService {
             }
         }
         User user = create(UserRegister.builder()
-                .authorities(Collections.singleton(Authority.get(AuthorityName.ROLE_USER)))
                 .username(name)
                 .nickname(name)
                 .password(password)
@@ -249,79 +247,14 @@ public class UserService {
         return redisTemplate.opsForValue().get("register::" + phone);
     }
 
-    public User testPhoneRegister() {
-        String phone = "19" + RandomStringUtils.randomNumeric(11);
-        String password = "123456";
-        String inviteCode = null;
-        Long invitor = null;
-        Long collectionId = null;
-        String name = "9th_" + RandomStringUtils.randomAlphabetic(8);
-        Invite invite = null;
-        if (StringUtils.isNotBlank(inviteCode)) {
-            invite = inviteRepo.findFirstByCode(inviteCode).orElse(null);
-        }
-        Collection collection;
-        if (collectionId != null) {
-            collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("无藏品"));
-//            if (!collection.isOnShelf() || !collection.isSalable()) {
-//                collectionId = null;
-//            } else if (collection.isScheduleSale()) {
-//                if (collection.getStartTime().isAfter(LocalDateTime.now())) {
-//                    collectionId = null;
-//                }
-//            }
-            // 只看是否开去分享
-            if (ObjectUtils.isEmpty(collection.getOpenQuota()) || !collection.getOpenQuota()) {
-                collectionId = null;
-            }
-        }
-        User user = create(UserRegister.builder()
-                .authorities(Collections.singleton(Authority.get(AuthorityName.ROLE_USER)))
-                .username(name)
-                .nickname(name)
-                .password(password)
+    public User testPhoneRegister(String phone) {
+        return create(UserRegister.builder()
                 .avatar(Constants.DEFAULT_AVATAR)
-                .phone(phone)
-                .invitorPhone(Optional.ofNullable(invite).map(Invite::getPhone).orElse(null))
-                .invitorName(Optional.ofNullable(invite).map(Invite::getName).orElse(null))
-                .inviteCode(Optional.ofNullable(invite).map(Invite::getCode).orElse(null))
-                .collectionInvitor(invitor)
-                .collectionId(collectionId)
+                .username(RandomStringUtils.randomAlphabetic(32))
+                .nickname(RandomStringUtils.randomAlphabetic(32))
+                .phone(RandomStringUtils.randomNumeric(16))
+                .password("123456")
                 .build());
-        if (invite != null) {
-            inviteRepo.increaseNum(invite.getId());
-        }
-
-        // 加积分
-//        if (collectionId != null && invitor != null) {
-//            // 额度或者额度为空, 库存不为空
-//            if (collection.getStock() > 0 && (collection.getVipQuota() > 0 || ObjectUtils.isEmpty(collection.getVipQuota()))) {
-//                int countUser = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, invitor);
-//                // 邀请人数
-//                if (countUser >= collection.getAssignment()) {
-//                    int point = pointRecordRepo.countByUserIdAndCollectionId(invitor, collectionId);
-//                    // 是否已有积分
-//                    if (point <= 0) {
-//                        long count = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, invitor);
-//                        if (count >= collection.getAssignment()) {
-//                            // 扣除藏品额度
-//                            if (ObjectUtils.isNotEmpty(collection.getVipQuota())) {
-//                                collectionService.decreaseQuota(collectionId, 1);
-//                            }
-//                            userRepo.updateVipPoint(invitor, 1);
-//                            pointRecordRepo.save(PointRecord.builder()
-//                                    .collectionId(collectionId)
-//                                    .userId(invitor)
-//                                    .type("VIP_POINT")
-//                                    .point(1)
-//                                    .build());
-//
-//                        }
-//                    }
-//                }
-//            }
-//        }
-        return user;
     }
 
     public void del(Long id) {
@@ -333,7 +266,7 @@ public class UserService {
         if (StringUtils.isNoneEmpty(user.getPhone())) {
             user.setPhone(user.getPhone() + "###" + RandomStringUtils.randomAlphabetic(8));
         }
-        userRepo.save(user);
+        save(user);
         //删除实名认证
         identityAuthRepo.softDeleteByUserId(id);
     }
@@ -364,7 +297,21 @@ public class UserService {
             throw new BusinessException("账号或密码错误");
         }
         if (StringUtils.isNoneEmpty(user.getPassword()) &&
-                !new BCryptPasswordEncoder().matches(password, user.getPassword())) {
+                !passwordEncoder.matches(password, user.getPassword())) {
+            throw new BusinessException("账号或密码错误");
+        }
+
+        return user;
+    }
+
+    public User loginByUsernamePwd(String username, String password) {
+        if (StringUtils.isEmpty(username)) {
+            throw new BusinessException("用户名错误");
+        }
+        User user = userRepo.findByUsernameAndDelFalse(username).orElseThrow(new BusinessException("账号或密码错误"));
+
+        if (StringUtils.isEmpty(user.getPassword())
+                || !passwordEncoder.matches(password, user.getPassword())) {
             throw new BusinessException("账号或密码错误");
         }
 
@@ -390,7 +337,7 @@ public class UserService {
                     .authorities(Collections.singleton(Authority.get(AuthorityName.ROLE_USER)))
                     .authStatus(AuthStatus.NOT_AUTH)
                     .build();
-            userRepo.save(user);
+            save(user);
         }
         return user;
     }
@@ -419,7 +366,7 @@ public class UserService {
                     .authorities(Collections.singleton(Authority.get(AuthorityName.ROLE_USER)))
                     .authStatus(AuthStatus.NOT_AUTH)
                     .build();
-            userInfo = userRepo.save(userInfo);
+            userInfo = save(userInfo);
             return userInfo;
         } catch (WxErrorException e) {
             e.printStackTrace();
@@ -462,7 +409,7 @@ public class UserService {
                     .city(wxUserInfo.getCity())
                     .authorities(Collections.singleton(Authority.builder().name("ROLE_USER").build()))
                     .build();
-            user = userRepo.save(user);
+            user = save(user);
 
         } else {
             user.setAvatar(avatarUrl);
@@ -471,7 +418,7 @@ public class UserService {
             user.setCountry(wxUserInfo.getCountry());
             user.setProvince(wxUserInfo.getProvince());
             user.setCity(wxUserInfo.getCity());
-            user = userRepo.save(user);
+            user = save(user);
         }
 
         return user;
@@ -479,8 +426,8 @@ public class UserService {
 
     public String setPassword(Long userId, String password) {
         User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
-        user.setPassword(new BCryptPasswordEncoder().encode(password));
-        user = userRepo.save(user);
+        user.setPassword(passwordEncoder.encode(password));
+        user = save(user);
         return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
     }
 
@@ -508,7 +455,7 @@ public class UserService {
         });
 
         user.setPhone(phone);
-        userRepo.save(user);
+        save(user);
     }
 
     public UserDTO toDTO(User user) {
@@ -555,13 +502,13 @@ public class UserService {
         if (!StringUtils.equals(phone, user.getPhone())) {
             throw new BusinessException("验证码无效");
         }
-        user.setTradeCode(new BCryptPasswordEncoder().encode(tradeCode));
-        userRepo.save(user);
+        user.setTradeCode(passwordEncoder.encode(tradeCode));
+        save(user);
     }
 
     public void verifyTradeCode(Long userId, String tradeCode) {
         User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
-        if (!new BCryptPasswordEncoder().matches(tradeCode, user.getTradeCode())) {
+        if (!passwordEncoder.matches(tradeCode, user.getTradeCode())) {
             throw new BusinessException("校验失败");
         }
     }
@@ -620,13 +567,13 @@ public class UserService {
 
         adapayMerchantService.createMemberForAll(userId.toString(), user.getPhone(), identityAuth.getRealName(), identityAuth.getIdNo());
         user.setMemberId(user.getId().toString());
-        userRepo.save(user);
+        save(user);
 
         String accountId = adapayMerchantService.createSettleAccountForAll
                 (user.getMemberId(), identityAuth.getRealName(),
                         identityAuth.getIdNo(), phone, bankNo);
         user.setSettleAccountId(Optional.ofNullable(accountId).orElse("1"));
-        userRepo.save(user);
+        save(user);
 
         userBankCardRepo.save(UserBankCard.builder()
                 .bank(bankValidate.getBank())
@@ -646,7 +593,7 @@ public class UserService {
         if (StringUtils.isNotBlank(user.getSettleAccountId()) && StringUtils.isNotBlank(user.getMemberId())) {
             adapayMerchantService.delSettleAccountForAll(user.getMemberId());
             user.setSettleAccountId(null);
-            userRepo.save(user);
+            save(user);
             userBankCardRepo.deleteByUserId(userId);
         } else {
             throw new BusinessException("未绑定");
@@ -657,7 +604,7 @@ public class UserService {
         User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
         if (user.getAuthStatus() == AuthStatus.SUCCESS) {
             user.setAuthStatus(AuthStatus.NOT_AUTH);
-            userRepo.save(user);
+            save(user);
             identityAuthRepo.deleteAll(identityAuthRepo.findByUserIdAndDelFalse(userId));
         }
     }
@@ -753,7 +700,7 @@ public class UserService {
                 userBankCardRepo.save(userBankCard);
             } catch (Exception e) {
                 user.setSettleAccountId(null);
-                userRepo.save(user);
+                save(user);
                 userBankCardRepo.deleteByUserId(user.getId());
             }
             count.getAndIncrement();
@@ -763,7 +710,10 @@ public class UserService {
 
     @Cacheable(value = "myUserInfo", key = "#id")
     public User my(Long id) {
-        return userRepo.findById(id).orElseThrow(new BusinessException("用户不存在"));
+        User user = userRepo.findById(id).orElseThrow(new BusinessException("用户不存在"));
+        user.setPassword(null);
+        user.setTradeCode(null);
+        return user;
     }
 
 }

+ 6 - 7
src/main/java/com/izouma/nineth/service/sms/AliSmsService.java

@@ -1,10 +1,11 @@
 package com.izouma.nineth.service.sms;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.aliyuncs.CommonRequest;
 import com.aliyuncs.CommonResponse;
 import com.aliyuncs.DefaultAcsClient;
 import com.aliyuncs.IAcsClient;
-import com.aliyuncs.exceptions.ClientException;
 import com.aliyuncs.http.MethodType;
 import com.aliyuncs.profile.DefaultProfile;
 import com.izouma.nineth.config.Constants;
@@ -17,8 +18,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.configurationprocessor.json.JSONException;
-import org.springframework.boot.configurationprocessor.json.JSONObject;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
@@ -85,7 +84,7 @@ public class AliSmsService implements SmsService {
                 throw new BusinessException("发送失败,请稍后再试", response.getHttpStatus() + "," + response.getData());
             }
             log.info("send sms response {}", response.getData());
-            JSONObject jsonObject = new JSONObject(response.getData());
+            JSONObject jsonObject = JSON.parseObject(response.getData());
             if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
                 throw new BusinessException("发送失败,请稍后再试", jsonObject.getString("Message"));
             }
@@ -99,7 +98,7 @@ public class AliSmsService implements SmsService {
                     .expired(false)
                     .build());
             return sessionId;
-        } catch (ClientException | JSONException e) {
+        } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException("发送失败,请稍后再试", e.getMessage());
         }
@@ -149,12 +148,12 @@ public class AliSmsService implements SmsService {
                 log.error("发送失败," + response.getHttpStatus() + "," + response.getData());
             }
             log.info("send sms response {}", response.getData());
-            JSONObject jsonObject = new JSONObject(response.getData());
+            JSONObject jsonObject = JSON.parseObject(response.getData());
             if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
                 log.error("发送失败," + jsonObject.getString("Message"));
             }
 
-        } catch (ClientException | JSONException e) {
+        } catch (Exception e) {
             e.printStackTrace();
             log.error("发送失败," + e.getMessage());
         }

+ 0 - 4
src/main/java/com/izouma/nineth/web/AppErrorController.java

@@ -11,10 +11,6 @@ import javax.servlet.http.HttpServletRequest;
 
 @Controller
 public class AppErrorController implements ErrorController {
-    @Override
-    public String getErrorPath() {
-        return "/error";
-    }
 
     @RequestMapping("/error")
     public String handleError(HttpServletRequest request, Model model) {

+ 8 - 32
src/main/java/com/izouma/nineth/web/AuthenticationController.java

@@ -4,7 +4,6 @@ import com.izouma.nineth.domain.User;
 import com.izouma.nineth.enums.AuthorityName;
 import com.izouma.nineth.exception.AuthenticationException;
 import com.izouma.nineth.security.JwtTokenUtil;
-import com.izouma.nineth.security.JwtUser;
 import com.izouma.nineth.security.JwtUserFactory;
 import com.izouma.nineth.service.CaptchaService;
 import com.izouma.nineth.service.UserService;
@@ -12,11 +11,6 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.authentication.DisabledException;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,7 +18,6 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Objects;
 
 @Slf4j
 @AllArgsConstructor
@@ -38,19 +31,18 @@ public class AuthenticationController {
 
     @PostMapping("/login")
     public String loginByUserPwd(String username, String password, Integer expiration) {
-        Authentication authentication = authenticate(username, password);
-        JwtUser jwtUser = (JwtUser) authentication.getPrincipal();
-        return jwtTokenUtil.generateToken(jwtUser);
+        User user = userService.loginByUsernamePwd(username, password);
+        return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
     }
 
     @PostMapping("/loginAdmin")
     public String loginByUserPwdAdmin(String username, String password, Integer expiration) {
-        Authentication authentication = authenticate(username, password);
-        if (!authentication.getAuthorities().contains(new SimpleGrantedAuthority(AuthorityName.ROLE_ADMIN.name()))) {
+        User user = userService.loginByUsernamePwd(username, password);
+        if (user.getAuthorities() == null ||
+                user.getAuthorities().stream().anyMatch(au -> au.getName().equals(AuthorityName.ROLE_ADMIN.name()))) {
             throw new AuthenticationException("禁止登录", null);
         }
-        JwtUser jwtUser = (JwtUser) authentication.getPrincipal();
-        return jwtTokenUtil.generateToken(jwtUser);
+        return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
     }
 
     @PostMapping("/phoneLogin")
@@ -104,8 +96,8 @@ public class AuthenticationController {
 
     @PostMapping("/testphoneRegister")
     @ApiOperation(value = "手机号密码注册")
-    public String phonePwdLogin() {
-        User user = userService.testPhoneRegister();
+    public String phonePwdLogin(String phone) {
+        User user = userService.testPhoneRegister(phone);
         return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
     }
 
@@ -139,20 +131,4 @@ public class AuthenticationController {
     }
 
 
-    /**
-     * Authenticates the user. If something is wrong, an {@link AuthenticationException} will be thrown
-     *
-     * @return Authentication
-     */
-    private Authentication authenticate(String username, String password) {
-        Objects.requireNonNull(username);
-        Objects.requireNonNull(password);
-        try {
-            return authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
-        } catch (DisabledException e) {
-            throw new AuthenticationException("禁止登录", e);
-        } catch (BadCredentialsException e) {
-            throw new AuthenticationException("用户名或密码错误", e);
-        }
-    }
 }

+ 1 - 0
src/main/java/com/izouma/nineth/web/BannerController.java

@@ -28,6 +28,7 @@ public class BannerController extends BaseController {
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public Banner save(@RequestBody Banner record) {
+        record.setPic("https://"+record.getPic());
         if (record.getId() != null) {
             Banner orig = bannerRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
             ObjUtils.merge(orig, record);

+ 9 - 8
src/main/java/com/izouma/nineth/web/BlindBoxItemController.java

@@ -1,9 +1,10 @@
 package com.izouma.nineth.web;
+
 import com.izouma.nineth.domain.BlindBoxItem;
-import com.izouma.nineth.service.BlindBoxItemService;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.BlindBoxItemRepo;
+import com.izouma.nineth.service.BlindBoxItemService;
 import com.izouma.nineth.utils.ObjUtils;
 import com.izouma.nineth.utils.excel.ExcelUtils;
 import lombok.AllArgsConstructor;
@@ -20,9 +21,9 @@ import java.util.List;
 @AllArgsConstructor
 public class BlindBoxItemController extends BaseController {
     private BlindBoxItemService blindBoxItemService;
-    private BlindBoxItemRepo blindBoxItemRepo;
+    private BlindBoxItemRepo    blindBoxItemRepo;
 
-    //@PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public BlindBoxItem save(@RequestBody BlindBoxItem record) {
         if (record.getId() != null) {
@@ -37,7 +38,7 @@ public class BlindBoxItemController extends BaseController {
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/all")
     public Page<BlindBoxItem> all(@RequestBody PageQuery pageQuery) {
-        return blindBoxItemService.all(pageQuery);
+        return blindBoxItemService.all(pageQuery).toPage();
     }
 
     @GetMapping("/get/{id}")
@@ -45,10 +46,10 @@ public class BlindBoxItemController extends BaseController {
         return blindBoxItemRepo.findById(id).orElseThrow(new BusinessException("无记录"));
     }
 
-    @PostMapping("/del/{id}")
-    public void del(@PathVariable Long id) {
-        blindBoxItemRepo.softDelete(id);
-    }
+//    @PostMapping("/del/{id}")
+//    public void del(@PathVariable Long id) {
+//        blindBoxItemRepo.softDelete(id);
+//    }
 
     @GetMapping("/excel")
     @ResponseBody

+ 19 - 1
src/main/java/com/izouma/nineth/web/CollectionController.java

@@ -50,9 +50,14 @@ public class CollectionController extends BaseController {
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/create")
     public Collection create(@RequestBody Collection record) {
+        List<FileObject> pic = record.getPic();
+        if (pic.size()>0){
+            for (FileObject fileObject : pic) {
+                fileObject.setUrl("https://"+fileObject.getUrl());
+            }
+        }
         return collectionService.create(record);
     }
-
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/all")
     public Page<CollectionDTO> all(@RequestBody PageQuery pageQuery) {
@@ -101,6 +106,13 @@ public class CollectionController extends BaseController {
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/createBlindBox")
     public Collection createBlindBox(@RequestBody CreateBlindBox createBlindBox) {
+        Collection blindBox = createBlindBox.getBlindBox();
+        List<FileObject> pic = blindBox.getPic();
+        if (pic.size()>0){
+            for (FileObject fileObject : pic) {
+                fileObject.setUrl("https://"+fileObject.getUrl());
+            }
+        }
         return collectionService.createBlindBox(createBlindBox);
     }
 
@@ -145,6 +157,12 @@ public class CollectionController extends BaseController {
             }
             CollectionDTO collectionDTO = new CollectionDTO();
             BeanUtils.copyProperties(rc.getCollection(), collectionDTO);
+
+            // 减少数据量
+            collectionDTO.setDetail(null);
+            collectionDTO.setPrivileges(null);
+            collectionDTO.setProperties(null);
+
             return new RecommendDTO(rc.getRecommend().getSort(), collectionDTO, "collection");
         }).collect(Collectors.toList());
 

+ 8 - 3
src/main/java/com/izouma/nineth/web/DevelopController.java

@@ -5,10 +5,12 @@ import org.reflections.Reflections;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.mvc.condition.PathPatternsRequestCondition;
 import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
 import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition;
 import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
 import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
+import org.springframework.web.util.pattern.PathPattern;
 
 import javax.persistence.Entity;
 import java.util.*;
@@ -50,9 +52,12 @@ public class DevelopController {
             HashMap<String, String> hashMap = new HashMap<>();
             RequestMappingInfo info = m.getKey();
             HandlerMethod method = m.getValue();
-            PatternsRequestCondition p = info.getPatternsCondition();
-            for (String url : p.getPatterns()) {
-                hashMap.put("url", url);
+            PathPatternsRequestCondition p = info.getPathPatternsCondition();
+            if (p == null) {
+                continue;
+            }
+            for (PathPattern url : p.getPatterns()) {
+                hashMap.put("url", url.getPatternString());
             }
             hashMap.put("className", method.getMethod().getDeclaringClass().getName()); // 类名
             hashMap.put("method", method.getMethod().getName()); // 方法名

+ 1 - 0
src/main/java/com/izouma/nineth/web/MintActivityController.java

@@ -26,6 +26,7 @@ public class MintActivityController extends BaseController {
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public MintActivity save(@RequestBody MintActivity record) {
+        record.setCover("https://"+record.getCover());
         if (record.getId() != null) {
             MintActivity orig = mintActivityRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
             ObjUtils.merge(orig, record);

+ 3 - 0
src/main/java/com/izouma/nineth/web/NewsController.java

@@ -13,6 +13,7 @@ import com.izouma.nineth.utils.ObjUtils;
 import com.izouma.nineth.utils.SecurityUtils;
 import com.izouma.nineth.utils.excel.ExcelUtils;
 import lombok.AllArgsConstructor;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.domain.Page;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -32,6 +33,7 @@ public class NewsController extends BaseController {
     @PreAuthorize("hasAnyRole('ADMIN','NEWS')")
     @PostMapping("/save")
     public News save(@RequestBody News record) {
+        record.setPic("https://"+record.getPic());
         if (record.getId() != null) {
             News orig = newsRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
             ObjUtils.merge(orig, record);
@@ -48,6 +50,7 @@ public class NewsController extends BaseController {
     }
 
     @GetMapping("/get/{id}")
+    @Cacheable("news")
     public News get(@PathVariable Long id) {
         News news = newsRepo.findById(id).orElseThrow(new BusinessException("无记录"));
         User user = SecurityUtils.getAuthenticatedUser();

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

@@ -73,5 +73,17 @@ public class NewsLikeController extends BaseController {
     public void unlike(@PathVariable Long id) {
         newsLikeService.unlike(SecurityUtils.getAuthenticatedUser().getId(), id);
     }
+
+    @GetMapping("/{id}/likeRoom")
+    @ApiOperation("点赞")
+    public void likeRoom(@PathVariable Long id) {
+        newsLikeService.likeRoom(SecurityUtils.getAuthenticatedUser().getId(), id);
+    }
+
+    @GetMapping("/{id}/unlikeRoom")
+    @ApiOperation("取消点赞")
+    public void unlikeRoom(@PathVariable Long id) {
+        newsLikeService.unlikeRoom(SecurityUtils.getAuthenticatedUser().getId(), id);
+    }
 }
 

+ 6 - 0
src/main/java/com/izouma/nineth/web/PrivilegeOptionController.java

@@ -25,6 +25,12 @@ public class PrivilegeOptionController extends BaseController {
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public PrivilegeOption save(@RequestBody PrivilegeOption record) {
+        List<String> icon = record.getIcon();
+        if (icon.size()>0){
+            for (String s : icon) {
+                s="https://"+s;
+            }
+        }
         if (record.getId() != null) {
             PrivilegeOption orig = privilegeOptionRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
             ObjUtils.merge(orig, record);

+ 1 - 0
src/main/java/com/izouma/nineth/web/RecommendController.java

@@ -27,6 +27,7 @@ public class RecommendController extends BaseController {
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public Recommend save(@RequestBody Recommend record) {
+        record.setPic("https://"+record.getPic());
         if (record.getId() != null) {
             Recommend orig = recommendRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
             ObjUtils.merge(orig, record);

+ 44 - 0
src/main/java/com/izouma/nineth/web/RedisCacheController.java

@@ -0,0 +1,44 @@
+package com.izouma.nineth.web;
+
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.Cursor;
+import org.springframework.data.redis.core.RedisCallback;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.ScanOptions;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RestController
+@RequestMapping("/restCache")
+@AllArgsConstructor
+@Slf4j
+public class RedisCacheController {
+    private RedisTemplate<String, Object> redisTemplate;
+
+    @GetMapping("/scan")
+    public Iterable<String> scan(String key) {
+
+        return redisTemplate.execute((RedisCallback<Iterable<String>>) connection -> {
+
+            List<String> keys = new ArrayList<>();
+
+            Cursor<byte[]> cursor = connection.scan(ScanOptions.scanOptions()
+                    .count(1000)
+                    .match(key)
+                    .build());
+            while (cursor.hasNext()) {
+                keys.add(new String(cursor.next()));
+            }
+
+            cursor.close();
+
+            return keys;
+        });
+
+    }
+}

+ 56 - 14
src/main/java/com/izouma/nineth/web/ShowroomController.java

@@ -1,21 +1,29 @@
 package com.izouma.nineth.web;
 
+import cn.hutool.core.collection.CollUtil;
+import com.izouma.nineth.domain.NewsLike;
+import com.izouma.nineth.domain.ShowCollection;
 import com.izouma.nineth.domain.Showroom;
-import com.izouma.nineth.repo.ShowCollectionRepo;
-import com.izouma.nineth.service.ShowroomService;
+import com.izouma.nineth.domain.User;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.exception.BusinessException;
+import com.izouma.nineth.repo.NewsLikeRepo;
+import com.izouma.nineth.repo.ShowCollectionRepo;
 import com.izouma.nineth.repo.ShowroomRepo;
-import com.izouma.nineth.utils.ObjUtils;
+import com.izouma.nineth.service.ShowroomService;
+import com.izouma.nineth.utils.SecurityUtils;
 import com.izouma.nineth.utils.excel.ExcelUtils;
 import lombok.AllArgsConstructor;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.data.domain.Page;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/showroom")
@@ -24,28 +32,57 @@ public class ShowroomController extends BaseController {
     private ShowroomService    showroomService;
     private ShowroomRepo       showroomRepo;
     private ShowCollectionRepo showCollectionRepo;
+    private NewsLikeRepo       newsLikeRepo;
 
-    //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public Showroom save(@RequestBody Showroom record) {
-        if (record.getId() != null) {
-            Showroom orig = showroomRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
-            ObjUtils.merge(orig, record);
-            return showroomRepo.save(orig);
-        }
-        return showroomRepo.save(record);
+        return showroomService.save(SecurityUtils.getAuthenticatedUser().getId(), record);
     }
 
+    @PostMapping("/update")
+    public Showroom update(@RequestBody Showroom record) {
+        return showroomService.update(SecurityUtils.getAuthenticatedUser().getId(), record);
+    }
 
-    //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/all")
     public Page<Showroom> all(@RequestBody PageQuery pageQuery) {
-        return showroomService.all(pageQuery);
+        Page<Showroom> all = showroomService.all(pageQuery);
+        List<Long> ids = all.map(Showroom::getId).getContent();
+        Map<Long, List<ShowCollection>> collect = showCollectionRepo.findAllByShowroomIdIn(ids)
+                .stream()
+                .collect(Collectors.groupingBy(ShowCollection::getShowroomId));
+        showroomService.all(pageQuery);
+
+        User user = SecurityUtils.getAuthenticatedUser();
+        Map<Long, Long> likesMap = new HashMap<>();
+        if (user != null && !user.isAdmin() && CollUtil.isNotEmpty(ids)) {
+            List<NewsLike> likes = newsLikeRepo.findByUserIdAndShowroomIdIn(user
+                    .getId(), ids);
+            likesMap = likes.stream()
+                    .collect(Collectors.groupingBy(NewsLike::getShowroomId, Collectors.counting()));
+
+        }
+
+        Map<Long, Long> finalLikesMap = likesMap;
+        return all.map(showroom -> {
+            showroom.setCollections(collect.get(showroom.getId()));
+            showroom.setLiked(ObjectUtils.isNotEmpty(finalLikesMap.get(showroom.getId())));
+            return showroom;
+        });
     }
 
     @GetMapping("/get/{id}")
     public Showroom get(@PathVariable Long id) {
-        return showroomRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+        Showroom showroom = showroomRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+        showroom.setCollections(showCollectionRepo.findAllByShowroomId(id));
+        User user = SecurityUtils.getAuthenticatedUser();
+
+        if (user != null && !user.isAdmin()) {
+            List<NewsLike> likes = newsLikeRepo.findByUserIdAndShowroomId(user
+                    .getId(), id);
+            showroom.setLiked(CollUtil.isNotEmpty(likes));
+        }
+        return showroom;
     }
 
     @PostMapping("/del/{id}")
@@ -60,5 +97,10 @@ public class ShowroomController extends BaseController {
         List<Showroom> data = all(pageQuery).getContent();
         ExcelUtils.export(response, data);
     }
+
+    @GetMapping("/{id}/share")
+    public void addShare(@PathVariable Long id) {
+        showroomRepo.addShare(id, 1);
+    }
 }
 

+ 17 - 15
src/main/java/com/izouma/nineth/web/TestClassController.java

@@ -1,12 +1,13 @@
 package com.izouma.nineth.web;
+
 import com.izouma.nineth.domain.TestClass;
-import com.izouma.nineth.service.TestClassService;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.TestClassRepo;
-import com.izouma.nineth.utils.ObjUtils;
+import com.izouma.nineth.service.TestClassService;
 import com.izouma.nineth.utils.excel.ExcelUtils;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
@@ -17,21 +18,27 @@ import java.util.List;
 @RestController
 @RequestMapping("/testClass")
 @AllArgsConstructor
+@Slf4j
 public class TestClassController extends BaseController {
     private TestClassService testClassService;
-    private TestClassRepo testClassRepo;
+    private TestClassRepo    testClassRepo;
 
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
-    public TestClass save(@RequestBody TestClass record) {
-        if (record.getId() != null) {
-            TestClass orig = testClassRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
-            ObjUtils.merge(orig, record);
-            return testClassRepo.save(orig);
-        }
-        return testClassRepo.save(record);
+    public TestClass save() {
+        long ts = System.currentTimeMillis();
+        TestClass t = new TestClass("aaa");
+        log.info("create testClass {}ms", System.currentTimeMillis() - ts);
+        ts = System.currentTimeMillis();
+        t = testClassRepo.save(t);
+        log.info("save testClass {}ms", System.currentTimeMillis() - ts);
+        return t;
     }
 
+    @PostMapping("/save1")
+    public void save1() {
+        testClassRepo.nativeSave("aaa");
+    }
 
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/all")
@@ -44,11 +51,6 @@ public class TestClassController extends BaseController {
         return testClassRepo.findById(id).orElseThrow(new BusinessException("无记录"));
     }
 
-    @PostMapping("/del/{id}")
-    public void del(@PathVariable Long id) {
-        testClassRepo.softDelete(id);
-    }
-
     @GetMapping("/excel")
     @ResponseBody
     public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {

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

@@ -20,7 +20,6 @@ import me.chanjar.weixin.common.error.WxErrorException;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.data.domain.Page;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
@@ -46,7 +45,7 @@ public class UserController extends BaseController {
         UserRegister user = UserRegister.builder()
                 .username(username)
                 .nickname(username)
-                .password(new BCryptPasswordEncoder().encode(password))
+                .password(password)
                 .authorities(Collections.singleton(Authority.get(AuthorityName.ROLE_USER)))
                 .build();
         return userService.create(user);
@@ -55,6 +54,7 @@ public class UserController extends BaseController {
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/create")
     public User create(@RequestBody UserRegister userRegister) {
+        userRegister.setAvatar("https//"+userRegister.getAvatar());
         return userService.create(userRegister);
     }
 
@@ -64,7 +64,7 @@ public class UserController extends BaseController {
         if (user.getId() != null) {
             return userService.update(user);
         }
-        return userRepo.save(user);
+        return userService.save(user);
     }
 
     @GetMapping("/my")

+ 1 - 1
src/main/nine-space/.env.app_raex

@@ -2,6 +2,6 @@ VUE_APP_BASE_URL=https://www.raex.vip
 NODE_ENV=production
 PUBLIC_PATH=./
 ASSETS_PATH=raex
-TITLE=绿洲数字藏品中心
+TITLE=南京数藏数字藏品中心
 VUE_APP_CORDOVA=true
 VUE_APP_PAGE_TYPE=raex

+ 1 - 1
src/main/nine-space/.env.development_raex

@@ -2,5 +2,5 @@ VUE_APP_BASE_URL=https://test.raex.vip/
 NODE_ENV=development
 PUBLIC_PATH=/
 ASSETS_PATH=raex
-TITLE=绿洲数字藏品中心
+TITLE=南京数藏数字藏品中心
 VUE_APP_PAGE_TYPE=raex

+ 38 - 12
src/main/resources/application.yaml

@@ -39,13 +39,15 @@ spring:
     druid:
       # 连接池的配置信息
       # 初始化大小,最小,最大
-      initial-size: 10
-      min-idle: 10
-      maxActive: 5000
+      initial-size: 5
+      min-idle: 20
+      maxActive: 3000
       # 配置获取连接等待超时的时间
-      maxWait: 10000
+      maxWait: 60000
+      # 使用不公平锁提高并发
+      use-unfair-lock: true
       # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
-      timeBetweenEvictionRunsMillis: 60000
+      timeBetweenEvictionRunsMillis: 30000
       # 配置一个连接在池中最小生存的时间,单位是毫秒
       minEvictableIdleTimeMillis: 300000
       validationQuery: SELECT 1
@@ -63,6 +65,10 @@ spring:
       remove-abandoned: true
       remove-abandoned-timeout: 1800
       log-abandoned: true
+      # 保持连接
+      keep-alive: true
+      # 超过多长时间
+      keep-alive-between-time-millis: 60000
       # 配置DruidStatFilter
       web-stat-filter:
         enabled: true
@@ -81,14 +87,22 @@ spring:
             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
+    database-platform: org.hibernate.dialect.MySQL8Dialect
     hibernate:
       ddl_auto: update
     properties:
       hibernate:
+        dialect: org.hibernate.dialect.MySQL8Dialect
+        storage_engine: innodb
         enable_lazy_load_no_trans: true
+        order_inserts: true
+        order_updates: true
+        fetch_size: 400
+        jdbc:
+          batch_size: 30
     open-in-view: true
   servlet:
     multipart:
@@ -213,7 +227,9 @@ rocketmq:
 ---
 
 spring:
-  profiles: test
+  config:
+    activate:
+      on-profile: test
   datasource:
     url: jdbc:mysql://rm-wz9sc79f5255780op.mysql.rds.aliyuncs.com/raex_test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
     username: raex_server
@@ -245,7 +261,9 @@ general:
 ---
 
 spring:
-  profiles: test1
+  config:
+    activate:
+      on-profile: test1
   datasource:
     url: jdbc:mysql://rdsave1o67m1ido6gwp6145.mysql.rds.aliyuncs.com/nanjing_nft?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
     username: nkcnft
@@ -292,7 +310,9 @@ rocketmq:
 ---
 
 spring:
-  profiles: local
+  config:
+    activate:
+      on-profile: local
   datasource:
     url: jdbc:mysql://192.168.50.10/raex_test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
     username: root
@@ -304,7 +324,9 @@ spring:
 ---
 
 spring:
-  profiles: prod
+  config:
+    activate:
+      on-profile: prod
   datasource:
     url: jdbc:mysql://rdsave1o67m1ido6gwp6145.mysql.rds.aliyuncs.com/nanjing_nft?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
     username: nkcnft
@@ -353,7 +375,9 @@ aliyun:
 ---
 
 spring:
-  profiles: notify
+  config:
+    activate:
+      on-profile: notify
   datasource:
     url: jdbc:mysql://rdsave1o67m1ido6gwp6145.mysql.rds.aliyuncs.com/nanjing_nft?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
     username: nkcnft
@@ -399,7 +423,9 @@ rocketmq:
 ---
 
 spring:
-  profiles: notifytest
+  config:
+    activate:
+      on-profile: notifytest
   datasource:
     url: jdbc:mysql://rdsave1o67m1ido6gwp6145.mysql.rds.aliyuncs.com/nanjing_nft?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
     username: nkcnft

+ 20 - 21
src/main/resources/logback-spring.xml

@@ -16,22 +16,21 @@
         <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>
         <logger name="org.freemarker" level="DEBUG"/>
 
-        <!-- dingding log -->
-        <appender name="HTTP_INVOKE_LOGGER_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
-            <param name="append" value="true"/>
-            <param name="encoding" value="UTF-8"/>
-            <param name="threshold" value="INFO"/>
-            <encoder>
-                <pattern>${CONSOLE_LOG_PATTERN}</pattern>
-            </encoder>
-        </appender>
+<!--        <logger name="druid.sql.Statement" level="debug">-->
+<!--        </logger>-->
+<!--        <logger name="druid.sql.DataSource" level="debug">-->
+<!--        </logger>-->
+<!--        <logger name="druid.sql.Connection" level="debug">-->
+<!--        </logger>-->
+<!--        <logger name="druid.sql.ResultSet" level="debug">-->
+<!--        </logger>-->
 
-<!--        <logger name="org.hibernate.SQL" level="DEBUG"/>-->
-<!--        <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>-->
-<!--        <logger name="org.springframework.jdbc.core.JdbcTemplate" level="DEBUG"/>-->
-<!--        <logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE"/>-->
-<!--        <logger name="cn.binarywang.wx.miniapp" level="DEBUG"/>-->
-<!--        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>-->
+        <!--        <logger name="org.hibernate.SQL" level="DEBUG"/>-->
+        <!--        <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>-->
+        <!--        <logger name="org.springframework.jdbc.core.JdbcTemplate" level="DEBUG"/>-->
+        <!--        <logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE"/>-->
+        <!--        <logger name="cn.binarywang.wx.miniapp" level="DEBUG"/>-->
+        <!--        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>-->
     </springProfile>
 
     <springProfile name="local">
@@ -81,12 +80,12 @@
         <root level="INFO">
             <appender-ref ref="FILE"/>
         </root>
-<!--        <logger name="org.hibernate.SQL" level="DEBUG"/>-->
-<!--        <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>-->
-<!--        <logger name="org.springframework.jdbc.core.JdbcTemplate" level="DEBUG"/>-->
-<!--        <logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE"/>-->
-<!--        <logger name="cn.binarywang.wx.miniapp" level="DEBUG"/>-->
-<!--        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>-->
+        <!--        <logger name="org.hibernate.SQL" level="DEBUG"/>-->
+        <!--        <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>-->
+        <!--        <logger name="org.springframework.jdbc.core.JdbcTemplate" level="DEBUG"/>-->
+        <!--        <logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE"/>-->
+        <!--        <logger name="cn.binarywang.wx.miniapp" level="DEBUG"/>-->
+        <!--        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>-->
     </springProfile>
 
     <springProfile name="test1">

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 187 - 1460
src/main/vue/package-lock.json


+ 1 - 1
src/main/vue/public/index.html

@@ -6,7 +6,7 @@
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
     <script src="<%= BASE_URL %>fontawesome-v5.13.0.js"></script>
-    <title>绿洲管理后台</title>
+    <title>南京数藏管理后台</title>
   </head>
   <body>
     <noscript>

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

@@ -2,7 +2,7 @@
     <el-container id="app">
         <el-aside :width="collapse ? '65px' : '200px'" class="aside">
             <div v-if="collapse" class="logo-wrapper collapse" @click="$router.push('/dashboard')"></div>
-            <div v-else class="logo-wrapper" @click="$router.push('/dashboard')">RAEX绿洲</div>
+            <div v-else class="logo-wrapper" @click="$router.push('/dashboard')">南京数藏</div>
             <el-menu
                 :collapse="collapse"
                 :background-color="$theme['menu-bg']"

+ 86 - 7
src/test/java/com/izouma/nineth/CommonTest.java

@@ -8,6 +8,7 @@ import com.izouma.nineth.config.Constants;
 import com.izouma.nineth.domain.BaseEntity;
 import com.izouma.nineth.domain.BlindBoxItem;
 import com.izouma.nineth.domain.User;
+import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.utils.AESEncryptUtil;
 import com.izouma.nineth.utils.TokenUtils;
 import com.izouma.nineth.web.BaseController;
@@ -455,12 +456,90 @@ public class CommonTest {
 
     @Test
     public void aasdf() {
-        String body = HttpRequest.post("https://zid.market.alicloudapi.com/idcheck/Post")
-                .header("Authorization", "APPCODE b48bc8f6759345a79ae20a951f03dabe")
-                .contentType(HttpRequest.CONTENT_TYPE_FORM)
-                .form("cardNo", "352228198905220012")
-                .form("realName", "吴承培")
-                .body();
-        System.out.println(JSON.toJSONString(JSON.parseObject(body), SerializerFeature.PrettyFormat));
+        System.out.println(new BCryptPasswordEncoder().matches("123456", "$2a$10$hYKQk3SKDqpK2QPDFqGdLekKWFcHs8rvou0hV4TxFy.ylL8PTBo5a"));
+    }
+
+
+    @Test
+    public void testBCrypt() {
+        BCryptPasswordEncoder encoder1 = new BCryptPasswordEncoder(4);
+        BCryptPasswordEncoder encoder2 = new BCryptPasswordEncoder(4);
+        String pwd = "$2a$10$oAWnGIHR2Cvc0BsMN7YCtOjvXsBLBygYxiVG3E1fuUmhM3sEOYhQe";
+
+        System.out.println(encoder1.matches("123456", pwd));
+        System.out.println(encoder2.matches("123456", pwd));
+
+        System.out.println(encoder1.matches("1234561", pwd));
+        System.out.println(encoder2.matches("1234561", pwd));
+
+        long encode1 = 0;
+        long match1 = 0;
+        for (int i = 0; i < 10; i++) {
+            long t = System.currentTimeMillis();
+            encoder1.encode("123456");
+            encode1 += System.currentTimeMillis() - t;
+
+            t = System.currentTimeMillis();
+            encoder1.matches("123456", pwd);
+            match1 += System.currentTimeMillis() - t;
+        }
+        System.out.println("avg encode = " + encode1 / 10 + "ms");
+        System.out.println("avg match = " + match1 / 10 + "ms");
+
+
+        long encode2 = 0;
+        long match2 = 0;
+        for (int i = 0; i < 10; i++) {
+            long t = System.currentTimeMillis();
+            encoder2.encode("123456");
+            encode2 += System.currentTimeMillis() - t;
+
+            t = System.currentTimeMillis();
+            encoder2.matches("123456", pwd);
+            match2 += System.currentTimeMillis() - t;
+        }
+        System.out.println("avg encode = " + encode2 / 10 + "ms");
+        System.out.println("avg match = " + match2 / 10 + "ms");
+    }
+
+
+    @Test
+    public void testParseToken() {
+        long t1 = 0;
+        long t2 = 0;
+        for (int i = 0; i < 1000; i++) {
+            long t = System.currentTimeMillis();
+            String token = Jwts.builder()
+                    .setClaims(new HashMap<>())
+                    .setSubject("a" + i)
+                    .setIssuedAt(new Date())
+                    .setExpiration(new Date(new Date().getTime() + 10000000))
+                    .signWith(SignatureAlgorithm.HS256, "123456")
+                    .compact();
+            t1 += System.currentTimeMillis() - t;
+
+            System.out.println(token);
+
+            t = System.currentTimeMillis();
+            Claims claims = Jwts.parser()
+                    .setSigningKey("123456")
+                    .parseClaimsJws(token)
+                    .getBody();
+            System.out.println(claims.getSubject());
+            t2 += System.currentTimeMillis() - t;
+        }
+        System.out.println(t1);
+        System.out.println(t2);
+        System.out.println(t1 / 1000);
+        System.out.println(t2 / 1000);
+    }
+
+    @Test
+    public void testHashCode() {
+        long t = System.currentTimeMillis();
+
+        new PageQuery().hashCode();
+
+        System.out.println(System.currentTimeMillis() - t);
     }
 }

+ 21 - 0
src/test/java/com/izouma/nineth/service/AirDropServiceTest.java

@@ -0,0 +1,21 @@
+package com.izouma.nineth.service;
+
+import com.izouma.nineth.ApplicationTests;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.time.LocalDateTime;
+
+import static org.junit.Assert.*;
+
+
+public class AirDropServiceTest extends ApplicationTests {
+    @Autowired
+    AirDropService airDropService;
+
+    @Test
+    public void drop() {
+        airDropService.drop(4235490L, 4273750L, 498,
+                LocalDateTime.of(2022, 3, 25, 17, 30));
+    }
+}

+ 2 - 2
src/test/java/com/izouma/nineth/service/ShowroomServiceTest.java

@@ -145,7 +145,7 @@ public class ShowroomServiceTest extends ApplicationTests {
 
         ShowCollection collection11 = ShowCollection.builder()
                 .sort(10)
-                .collectionId(207023L)
+                .collectionId(206067L)
                 .build();
 
         List<ShowCollection> collections = new ArrayList<>();
@@ -167,7 +167,7 @@ public class ShowroomServiceTest extends ApplicationTests {
                 .introduction("这个一个展厅测试")
                 .build();
         showroom.setId(207035L);
-        showroomService.update(showroom);
+        showroomService.update(9972L, showroom);
 
     }
 }

+ 37 - 47
src/test/java/com/izouma/nineth/service/UserServiceTest.java

@@ -1,6 +1,5 @@
 package com.izouma.nineth.service;
 
-import com.github.kevinsawicki.http.HttpRequest;
 import com.huifu.adapay.core.exception.BaseAdaPayException;
 import com.izouma.nineth.ApplicationTests;
 import com.izouma.nineth.config.Constants;
@@ -11,25 +10,20 @@ import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.dto.UserBankCard;
 import com.izouma.nineth.dto.UserRegister;
 import com.izouma.nineth.enums.AuthStatus;
-import com.izouma.nineth.enums.AuthorityName;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.IdentityAuthRepo;
 import com.izouma.nineth.repo.UserBankCardRepo;
 import com.izouma.nineth.repo.UserRepo;
-import com.izouma.nineth.security.Authority;
 import com.izouma.nineth.service.storage.StorageService;
 import com.izouma.nineth.utils.BankUtils;
-import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 
 public class UserServiceTest extends ApplicationTests {
 
@@ -48,8 +42,6 @@ public class UserServiceTest extends ApplicationTests {
 
     @Test
     public void findByUsernameAndDelFalse1() {
-        userRepo.findByUsernameAndDelFalse("admin");
-        userRepo.findByUsernameAndDelFalse("admin");
     }
 
     @Test
@@ -58,39 +50,25 @@ public class UserServiceTest extends ApplicationTests {
     }
 
     @Test
-    public void sss9() throws IOException {
-        for (User user : userRepo.findAll()) {
-            if (user.getAvatar().startsWith("https://cdn")) {
-                HttpRequest request = HttpRequest.get(user.getAvatar());
-                File file = File.createTempFile("gw1", "1sadga");
-                request.receive(file);
-                user.setAvatar(storageService.uploadFromInputStream(new FileInputStream(file), "image/" + RandomStringUtils.randomAlphabetic(12) + ".jpg"));
-                userRepo.save(user);
-            }
-        }
-    }
-
-    @Test
-    public void a() {
-        for (String s : ("13816681152\n" +
-                "15564456867\n" +
-                "13363659367\n" +
-                "18963550881\n" +
-                "13931604318\n" +
-                "13705395943\n" +
-                "13162078752\n" +
-                "13589360751\n")
-                .split("\n")) {
-            String name = "9th_" + RandomStringUtils.randomAlphabetic(8);
+    public void register() throws IOException {
+        try {
             User user = userService.create(UserRegister.builder()
-                    .authorities(Collections.singleton(Authority.get(AuthorityName.ROLE_USER)))
-                    .username(name)
-                    .nickname(name)
-                    .password("123456")
+                    .username("1111fff1g1rertuiohejldknhgurphoj")
+                    .nickname("1111fff1g1rertuiohejldknhgurphoj")
                     .avatar(Constants.DEFAULT_AVATAR)
-                    .phone(s)
+                    .phone("15077886171")
                     .build());
+            System.out.println(user.getId());
+        } catch (Exception e) {
+            if (Pattern.matches(".*SQL.*constraint.*phone.*", e.getMessage())) {
+                System.out.println("手机号已注册");
+            }
+            if (Pattern.matches(".*SQL.*constraint.*username.*", e.getMessage())) {
+                System.out.println("用户名已存在");
+            }
+            e.printStackTrace();
         }
+
     }
 
     @Test
@@ -187,14 +165,26 @@ public class UserServiceTest extends ApplicationTests {
     }
 
     @Test
-    public void test1() {
-        List<User> users = userRepo.findAll();
-        users.forEach(user -> {
-            if (user.getVipPoint() > 1) {
-                user.setVipPoint(1);
-            } else {
-
-            }
-        });
+    public void removeBank() throws BaseAdaPayException {
+        Long[] arr = {2577842L, 1440523L, 2775597L, 2766468L, 2686690L, 2747709L,
+                2804878L, 1737822L, 1692606L, 1690986L, 12895L, 2768872L,
+                2758319L, 1722623L, 2767026L, 2742354L, 2772909L, 2813187L,
+                2592513L, 1245862L, 2581606L, 2775941L, 1649287L, 2764550L,
+                2660763L, 2609032L, 2777065L, 2589915L, 2810643L, 3114342L,
+                2897490L, 2579233L, 2728905L, 3064530L, 3261900L, 1634473L,
+                2798840L, 3146142L, 2872925L, 3309420L, 3618828L, 2786593L,
+                3337840L, 3253588L, 2745257L, 3454559L, 3474642L, 3468716L,
+                3363882L, 2685228L, 3088476L, 2900428L, 2705763L, 2687527L,
+                2787733L, 2737842L, 3324792L, 3147077L, 3145577L, 3142936L,
+                3385528L, 2888036L, 3366975L, 2842334L, 2864480L, 3277214L,
+                3260809L, 2867983L, 3246561L, 3472246L, 3302523L, 2882982L,
+                3150301L, 2782692L, 3082410L, 3043665L, 3448907L, 3421038L,
+                3371851L, 3225869L, 3087358L, 3463444L, 3478718L, 3434422L,
+                2784575L, 2622956L, 2700225L, 1635188L, 2715660L, 620172L,
+                3418309L, 3476261L, 2597211L, 3293018L, 3261495L, 3443258L
+        };
+        for (Long aLong : arr) {
+            userService.removeBankCard(aLong);
+        }
     }
 }

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů