Jelajahi Sumber

Merge branch 'master' of http://git.izouma.com/xiongzhu/9th

panhui 4 tahun lalu
induk
melakukan
720df37ccb

+ 2 - 2
src/main/java/com/izouma/nineth/config/Constants.java

@@ -11,9 +11,9 @@ public interface Constants {
 
     String DEFAULT_AVATAR = "https://awesomeadmin.oss-cn-hangzhou.aliyuncs.com/image/avatar_male.png";
 
-    String SMS_SIGN_NAME = "走马信息";
+    String SMS_SIGN_NAME = "身份验证";
 
-    String SMS_TEMPLATE_CODE_GENERIC = "SMS_175485688";
+    String SMS_TEMPLATE_CODE_GENERIC = "SMS_11685095";
 
     String bizId = "a00e36c5";
 

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

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

+ 6 - 2
src/main/java/com/izouma/nineth/service/CollectionService.java

@@ -17,6 +17,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -49,10 +50,13 @@ public class CollectionService {
     }
 
     public List<CollectionDTO> toDTO(List<Collection> collections) {
+        List<Like> likes = new ArrayList<>();
+        if (SecurityUtils.getAuthenticatedUser() != null) {
+            likes.addAll(likeRepo.findByUserId(SecurityUtils.getAuthenticatedUser().getId()));
+        }
         return collections.stream().parallel().map(collection -> {
             CollectionDTO dto = toDTO(collection, false);
-            if (SecurityUtils.getAuthenticatedUser() != null) {
-                List<Like> likes = likeRepo.findByUserId(SecurityUtils.getAuthenticatedUser().getId());
+            if (!likes.isEmpty()) {
                 dto.setLiked(likes.stream().anyMatch(l -> l.getCollectionId().equals(collection.getId())));
             }
             return dto;

+ 5 - 2
src/main/java/com/izouma/nineth/service/UserService.java

@@ -275,10 +275,13 @@ public class UserService {
     }
 
     public List<UserDTO> toDTO(List<User> users) {
+        List<Follow> follows = new ArrayList<>();
+        if (SecurityUtils.getAuthenticatedUser() != null) {
+            follows.addAll(followRepo.findByUserId(SecurityUtils.getAuthenticatedUser().getId()));
+        }
         return users.stream().parallel().map(user -> {
             UserDTO dto = toDTO(user, false);
-            if (SecurityUtils.getAuthenticatedUser() != null) {
-                List<Follow> follows = followRepo.findByUserId(SecurityUtils.getAuthenticatedUser().getId());
+            if (!follows.isEmpty()) {
                 dto.setFollow(follows.stream().anyMatch(f -> f.getFollowUserId().equals(user.getId())));
             }
             return dto;

+ 4 - 5
src/main/java/com/izouma/nineth/service/sms/AliSmsService.java

@@ -25,10 +25,9 @@ import java.time.ZoneOffset;
 @Service
 @Slf4j
 public class AliSmsService implements SmsService {
-    @Value("${aliyun.access-key-id}")
-    private String        accessKeyId;
-    @Value("${aliyun.access-key-secret}")
-    private String        accessKeySecret;
+    private final String accessKeyId     = "LTAI5tEL3wr9XeiyseqKLrEK";
+    private final String accessKeySecret = "I9JzOThjzeJMcpVf6melaMY3nt7ucU";
+
     @Autowired
     private SmsRecordRepo smsRecordRepo;
 
@@ -54,7 +53,7 @@ public class AliSmsService implements SmsService {
         request.putQueryParameter("PhoneNumbers", phone);
         request.putQueryParameter("SignName", Constants.SMS_SIGN_NAME);
         request.putQueryParameter("TemplateCode", Constants.SMS_TEMPLATE_CODE_GENERIC);
-        request.putQueryParameter("TemplateParam", "{\"code\":\"" + code + "\"}");
+        request.putQueryParameter("TemplateParam", "{\"code\":\"" + code + "\",\"product\":\"用户\"}");
         try {
             CommonResponse response = client.getCommonResponse(request);
             if (response.getHttpStatus() != 200) {

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

@@ -46,8 +46,8 @@ public class CollectionController extends BaseController {
     }
 
     @GetMapping("/get/{id}")
-    public Collection get(@PathVariable Long id) {
-        return collectionRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+    public CollectionDTO get(@PathVariable Long id) {
+        return collectionService.toDTO(collectionRepo.findById(id).orElseThrow(new BusinessException("无记录")), true);
     }
 
     @PostMapping("/del/{id}")

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

@@ -87,10 +87,10 @@ public class UserController extends BaseController {
         return userService.toDTO(userService.all(pageQuery));
     }
 
-//    @PreAuthorize("hasRole('ADMIN')")
+    //    @PreAuthorize("hasRole('ADMIN')")
     @GetMapping("/get/{id}")
-    public User get(@PathVariable Long id) {
-        return userRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+    public UserDTO get(@PathVariable Long id) {
+        return userService.toDTO(userRepo.findById(id).orElseThrow(new BusinessException("无记录")), true);
     }
 
     @PreAuthorize("hasRole('ADMIN')")

+ 21 - 21
src/main/resources/application.yaml

@@ -63,15 +63,15 @@ wx:
     msg_aes_key: aesKey
     msg_format: JSON
   pay:
-    appId: wx2375cba2eec2c479
-    mchId: 1529090291
-    mchKey: A2qWTQzN5EkvgeWgmnnTSY4vV3Y6Xxbj
-    subAppId: #服务商模式下的子商户公众账号ID
-    subMchId: #服务商模式下的子商户号
-    keyPath: classpath:/cert/apiclient_cert.p12
-    notifyUrl: http://nft.9space.vip/notify/order/weixin
-    refundNotifyUrl: http://nft.9space.vip/wx/refundNotify
-    returnUrl: http://nft.9space.vip/9th/orders
+    app-id: wx2375cba2eec2c479
+    mch-id: 1529090291
+    mch-key: A2qWTQzN5EkvgeWgmnnTSY4vV3Y6Xxbj
+    sub-app-id:
+    sub-mch-id:
+    key-path: classpath:/cert/apiclient_cert.p12
+    notify-url: https://nft.9space.vip/notify/order/weixin
+    refund-notify-url: https://nft.9space.vip/wx/refundNotify
+    return-url: https://nft.9space.vip/9th/orders
 storage:
   provider: aliyun
   local_path: /var/www/upload/
@@ -112,12 +112,12 @@ alipay:
   private-key: MIIEvgIBADANBgkqhkiG9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eJCfdSU/7kg2+XBgwD/zzLfj+cAR8SnlmYE5dA81hsM/l1MQrtLTryT/lAHR36eChb6QUnxAwwUZC8QiWDaFerlScJrJG0VJUEKQD6ANV2qP2fmU8IMxNZBT6WMvRvPIN34hCm9B8Kx2Tr8rOjZvwLwVwd1nR5a5mrbwG+kNY7olHW2ICYxJxIxXzypg4jTa5NyW7XR7tdgecRlAGJNxMeBqWwMRmN5l8G2ozV3iOIwhCMQIDAQAB
-  apiKey: CRv5YFAOIEGY5PgVf14Y9g==
-  appCertPath: classpath:cert/appCertPublicKey_2021002120645023.crt
-  aliPubCertPath: classpath:cert/alipayCertPublicKey_RSA2.crt
-  rootCertPath: classpath:cert/alipayRootCert.crt
-  notifyUrl: http://nft.9space.vip/notify/order/alipay
-  returnUrl: http://nft.9space.vip/9th/orders
+  ali-pub-cert-path: classpath:cert/alipayCertPublicKey_RSA2.crt
+  api-key: CRv5YFAOIEGY5PgVf14Y9g==
+  app-cert-path: classpath:cert/appCertPublicKey_2021002120645023.crt
+  root-cert-path: classpath:cert/alipayRootCert.crt
+  notify-url: https://nft.9space.vip/notify/order/alipay
+  return-url: https://nft.9space.vip/9th/orders
 ---
 
 spring:
@@ -130,12 +130,12 @@ spring:
   datasource:
     url: jdbc:mysql://mysql.izouma.com/nineth_test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
 general:
-  host: http://nft.9space.vip
+  host: https://nft.9space.vip
 wx:
   pay:
-    notify-url: http://nft.9space.vip/notify/order/weixin
-    refund-notify-url: http://nft.9space.vip/wx/refundNotify
-    return-url: http://nft.9space.vip/9th/orders
+    notify-url: https://nft.9space.vip/notify/order/weixin
+    refund-notify-url: https://nft.9space.vip/wx/refundNotify
+    return-url: https://nft.9space.vip/9th/orders
 alipay:
-  notify-url: http://nft.9space.vip/notify/order/alipay
-  return-url: http://nft.9space.vip/9th/orders
+  notify-url: https://nft.9space.vip/notify/order/alipay
+  return-url: https://nft.9space.vip/9th/orders