Browse Source

feat 1.短信集成 2.手机号验证码登录 3.用户增改接口

classic_blue 15 hours ago
parent
commit
56306b0a2d
35 changed files with 666 additions and 424 deletions
  1. 9 0
      babyApplication-common/babyApplication-common-datasource/pom.xml
  2. 21 17
      babyApplication-common/babyApplication-common-datasource/src/main/java/edu/travel/config/FieldMetaObjectHandler.java
  3. 7 0
      babyApplication-common/babyApplication-common-util/pom.xml
  4. 73 0
      babyApplication-common/babyApplication-common-util/src/main/java/edu/travel/util/JwtUtil.java
  5. 1 0
      babyApplication-common/babyApplication-common-util/src/main/java/edu/travel/util/SMSUtils.java
  6. 94 0
      babyApplication-common/babyApplication-common-util/src/main/java/edu/travel/util/UserContext.java
  7. 57 0
      babyApplication-model/babyApplication-model-entity/src/main/java/edu/travel/dto/UpdateAccountDto.java
  8. 3 34
      babyApplication-model/babyApplication-model-entity/src/main/java/edu/travel/entity/BtAccountInfo.java
  9. 15 0
      babyApplication-model/babyApplication-model-entity/src/main/java/edu/travel/enums/BaByRelationRoleEnum.java
  10. 3 34
      babyApplication-model/babyApplication-model-entity/src/main/java/edu/travel/vo/BtAccountInfoVo.java
  11. 6 0
      babyApplication-service/pom.xml
  12. 7 0
      babyApplication-service/src/main/java/edu/travel/service/BtAccountInfoService.java
  13. 105 42
      babyApplication-service/src/main/java/edu/travel/service/impl/BtAccountInfoServiceImpl.java
  14. 4 1
      babyApplication-service/src/main/java/edu/travel/service/impl/BtBabyUserRelationServiceImpl.java
  15. 2 2
      babyApplication-service/src/main/java/edu/travel/service/impl/BtBodyRecordServiceImpl.java
  16. 2 2
      babyApplication-service/src/main/java/edu/travel/service/impl/BtFeedRecordServiceImpl.java
  17. 3 1
      babyApplication-service/src/main/java/edu/travel/service/impl/BtMessageServiceImpl.java
  18. 3 1
      babyApplication-service/src/main/java/edu/travel/service/impl/MtFavoriteSongsServiceImpl.java
  19. 3 1
      babyApplication-service/src/main/java/edu/travel/service/impl/MtRelativeRolesServiceImpl.java
  20. 7 0
      babyApplication-web/pom.xml
  21. 2 1
      babyApplication-web/src/main/java/edu/travel/config/SecurityConfig.java
  22. 0 38
      babyApplication-web/src/main/java/edu/travel/constanst/Constants.java
  23. 38 0
      babyApplication-web/src/main/java/edu/travel/exception/GlobalExceptionHandler.java
  24. 20 59
      babyApplication-web/src/main/java/edu/travel/filter/LoginFilter.java
  25. 2 2
      babyApplication-web/src/main/java/edu/travel/filter/TokenAuthenticationFilter.java
  26. 33 3
      babyApplication-web/src/main/java/edu/travel/web/BtAccountInfoController.java
  27. 4 1
      babyApplication-web/src/main/java/edu/travel/web/BtBabyUserRelationController.java
  28. 4 1
      babyApplication-web/src/main/java/edu/travel/web/BtMessageController.java
  29. 4 1
      babyApplication-web/src/main/java/edu/travel/web/LoginController.java
  30. 0 41
      babyApplication-web/src/main/resources/application-dev.properties
  31. 0 41
      babyApplication-web/src/main/resources/application-prod.properties
  32. 0 50
      babyApplication-web/src/main/resources/application-test.properties
  33. 67 0
      babyApplication-web/src/main/resources/application-test.yaml
  34. 0 51
      babyApplication-web/src/main/resources/application.properties
  35. 67 0
      babyApplication-web/src/main/resources/application.yaml

+ 9 - 0
babyApplication-common/babyApplication-common-datasource/pom.xml

@@ -40,6 +40,15 @@
             <artifactId>mybatis-plus-boot-starter</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-security</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>${fastjson.version}</version>
+        </dependency>
+        <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>druid-spring-boot-starter</artifactId>
         </dependency>

+ 21 - 17
babyApplication-common/babyApplication-common-datasource/src/main/java/edu/travel/config/FieldMetaObjectHandler.java

@@ -1,7 +1,11 @@
 package edu.travel.config;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
 import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Component;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
@@ -24,22 +28,22 @@ public class FieldMetaObjectHandler implements MetaObjectHandler {
     @Override
     public void insertFill(MetaObject metaObject) {
         HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
-//        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
-//        Object principal = authentication.getPrincipal();
-//        if (principal == null) {
-//            return;
-//        }
-//        Long userId = null;
-//
-//        if (!(principal instanceof String && "anonymousUser".equals(principal))) {
-//            //走登录用户
-//            String jsonString = JSON.toJSONString(principal);
-//            JSONObject jsonObject = JSON.parseObject(jsonString);
-//            userId = jsonObject.getLong("id");
-//        }
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        Object principal = authentication.getPrincipal();
+        if (principal == null) {
+            return;
+        }
+        Long userId = null;
+
+        if (!(principal instanceof String && "anonymousUser".equals(principal))) {
+            //走登录用户
+            String jsonString = JSON.toJSONString(principal);
+            JSONObject jsonObject = JSON.parseObject(jsonString);
+            userId = jsonObject.getLong("id");
+        }
 
         if (metaObject.hasSetter(CREATE_USER_ID)) {
-//            this.strictInsertFill(metaObject, CREATE_USER_ID, String.class, userId != null ? userId.toString() : "");
+            this.strictInsertFill(metaObject, CREATE_USER_ID, String.class, userId != null ? userId.toString() : "");
         }
         if (metaObject.hasSetter(CREATE_TIME)) {
             this.strictInsertFill(metaObject, CREATE_TIME, Date.class, new Date());
@@ -54,10 +58,10 @@ public class FieldMetaObjectHandler implements MetaObjectHandler {
 
     @Override
     public void updateFill(MetaObject metaObject) {
-//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
-//        JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(principal));
+        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+        JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(principal));
         if (metaObject.hasSetter(UPDATE_USER_ID)) {
-//            this.strictInsertFill(metaObject, UPDATE_USER_ID, String.class,  jsonObject.getLong("id").toString());
+            this.strictInsertFill(metaObject, UPDATE_USER_ID, String.class,  jsonObject.getLong("id").toString());
         }
         if (metaObject.hasSetter(UPDATE_TIME)) {
             this.strictInsertFill(metaObject, UPDATE_TIME, Date.class, new Date());

+ 7 - 0
babyApplication-common/babyApplication-common-util/pom.xml

@@ -38,5 +38,12 @@
             <artifactId>volc-sdk-java</artifactId>
             <version>1.0.105</version>
         </dependency>
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>4.4.0</version>
+        </dependency>
+
+
     </dependencies>
 </project>

+ 73 - 0
babyApplication-common/babyApplication-common-util/src/main/java/edu/travel/util/JwtUtil.java

@@ -0,0 +1,73 @@
+package edu.travel.util;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.interfaces.DecodedJWT;
+import com.alibaba.fastjson.JSON;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+
+
+/**
+ * JwtUtil 类。
+ * <p>
+ * 描述:
+ *
+ * @author huangwenwen
+ * @date 2025/3/14
+ */
+
+public class JwtUtil {
+    private static final String SECRET_KEY = "Xk7f38@LsP9zU!d#2b9j6vFqY5Rm8zE9Fj1oH@7tR"; // 32+字符
+    private static final long EXPIRATION_TIME = 1000 * 60 * 60 * 24; // 24 小时
+
+    /**
+     * 生成 JWT Token
+     *
+     * @param user 用户对象
+     * @return 生成的 Token
+     */
+    public static <T> String generateJwtToken(T user) {
+        return JWT.create()
+                .withSubject(user.getClass().getSimpleName())  // 主题:类名
+                .withClaim("userInfo", JSON.toJSONString(user)) // 存储用户数据
+                .withIssuedAt(new Date())  // 签发时间
+                .withExpiresAt(new Date(System.currentTimeMillis() + EXPIRATION_TIME)) // 过期时间
+                .sign(Algorithm.HMAC256(SECRET_KEY)); // HMAC SHA256 签名
+    }
+
+    /**
+     * 解析 JWT Token 并获取用户对象
+     *
+     * @param token JWT Token
+     * @param clazz 目标对象的 Class
+     * @return 解析出的用户对象
+     */
+    public static <T> T parseJwtToken(String token, Class<T> clazz) {
+        DecodedJWT decodedJWT = JWT.require(Algorithm.HMAC256(SECRET_KEY))
+                .build()
+                .verify(token);
+
+        String userJson = decodedJWT.getClaim("userInfo").asString();
+        return JSON.parseObject(userJson, clazz);
+    }
+
+    /**
+     * 从请求头获取 Token 并解析成用户对象
+     *
+     * @param request HTTP 请求
+     * @param clazz   目标对象的 Class
+     * @return 解析出的用户对象
+     */
+    public static <T> T getUserFromRequest(HttpServletRequest request, Class<T> clazz) {
+        String token = request.getHeader("Authorization");
+        if (StringUtils.isBlank(token) || token.equals("null")) {
+            throw new RuntimeException("Token 不能为空");
+        }
+
+        token = token.replace("Bearer ", ""); // 去掉 "Bearer " 前缀
+        return parseJwtToken(token, clazz);
+    }
+}

+ 1 - 0
babyApplication-common/babyApplication-common-util/src/main/java/edu/travel/util/SMSUtils.java

@@ -30,6 +30,7 @@ public class SMSUtils {
         req.setSmsAccount(smsSwitch.getSmsAccount());
         if(countryCode.equals("86") || StringUtils.isBlank(countryCode)){
             req.setTemplateId(smsSwitch.getChinaTemplateId());
+            System.out.println(smsSwitch.getChinaSign());
             req.setSign(smsSwitch.getChinaSign());
         }else {
             req.setTemplateId(smsSwitch.getOtherTemplateId());

+ 94 - 0
babyApplication-common/babyApplication-common-util/src/main/java/edu/travel/util/UserContext.java

@@ -0,0 +1,94 @@
+package edu.travel.util;
+
+import com.alibaba.fastjson.JSON;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Method;
+
+/**
+ * UserContext 类。
+ * <p>
+ * 描述:
+ *
+ * @author huangwenwen
+ * @date 2025/3/14
+ */
+
+@Component
+public class UserContext<T> {
+
+    private static RedisTemplate<String, String> redisTemplate;
+
+    @Autowired
+    public void setRedisTemplate(RedisTemplate<String, String> redisTemplate) {
+        UserContext.redisTemplate = redisTemplate;
+    }
+
+    /**
+     * 获取当前 HTTP 请求
+     */
+    private static HttpServletRequest getCurrentRequest() {
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        return attributes != null ? attributes.getRequest() : null;
+    }
+
+    /**
+     * 获取当前用户(泛型)
+     */
+    public static <T> T getCurrentUser(Class<T> clazz) {
+        HttpServletRequest request = getCurrentRequest();
+        if (request == null) {
+            return null;
+        }
+
+        String token = request.getHeader("Authorization");
+        if (StringUtils.isBlank(token) || "null".equals(token)) {
+            return null;
+        }
+
+        try {
+            // 解析 JWT
+            T user = JwtUtil.parseJwtToken(token.replace("Bearer ", ""), clazz);
+            if (user == null) {
+                return null;
+            }
+
+            // 获取用户的唯一标识(假设所有用户类型都有 getPhone 方法)
+            String phone = getPhoneFromUser(user);
+            if (StringUtils.isBlank(phone)) {
+                return null;
+            }
+
+            // 从 Redis 获取用户信息
+            String redisUserJson = redisTemplate.opsForValue().get(phone + "_user_info");
+            if (StringUtils.isNotBlank(redisUserJson)) {
+                return JSON.parseObject(redisUserJson, clazz); // 返回用户信息
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+    /**
+     * 通过反射从用户对象获取唯一标识(
+
+     */
+    private static <T> String getPhoneFromUser(T user) {
+        try {
+            Method getPhoneMethod = user.getClass().getMethod("getPhone");
+            return (String) getPhoneMethod.invoke(user);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+}

+ 57 - 0
babyApplication-model/babyApplication-model-entity/src/main/java/edu/travel/dto/UpdateAccountDto.java

@@ -0,0 +1,57 @@
+package edu.travel.dto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.sun.istack.internal.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * UpdateAccountDto 类。
+ * <p>
+ * 描述:
+ *
+ * @author huangwenwen
+ * @date 2025/3/14
+ */
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class UpdateAccountDto {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 昵称
+     */
+    private String nickname;
+
+    /**
+     * 性别 0男 1女
+     */
+    private Integer sex;
+
+    /**
+     * 头像
+     */
+    private String avatar;
+
+    /**
+     * 生日日期
+     */
+    private Date birthday;
+
+    /**
+     * 用户密码
+     */
+    private String password;
+
+}

+ 3 - 34
babyApplication-model/babyApplication-model-entity/src/main/java/edu/travel/entity/BtAccountInfo.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.util.Date;
 import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
@@ -16,12 +17,13 @@ import lombok.NoArgsConstructor;
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
+@Builder
 @TableName(value = "bt_account_info")
 public class BtAccountInfo implements Serializable {
     /**
      * 主键
      */
-    @TableId(value = "id", type = IdType.INPUT)
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
     private Long id;
 
     /**
@@ -102,41 +104,8 @@ public class BtAccountInfo implements Serializable {
     @TableField(value = "tenant_unionid")
     private String tenantUnionid;
 
-    /**
-     * 项目名称
-     */
-    @TableField(value = "project")
-    private String project;
-
-    /**
-     * 创建时间
-     */
-    @TableField(value = "create_time")
-    private Date createTime;
 
-    /**
-     * 创建用户id
-     */
-    @TableField(value = "create_user_id")
-    private Long createUserId;
 
-    /**
-     * 更新时间
-     */
-    @TableField(value = "update_time")
-    private Date updateTime;
-
-    /**
-     * 更新用户id
-     */
-    @TableField(value = "update_user_id")
-    private Long updateUserId;
-
-    /**
-     * 逻辑删除标记
-     */
-    @TableField(value = "delete_flag")
-    private Integer deleteFlag;
 
     private static final long serialVersionUID = 1L;
 }

+ 15 - 0
babyApplication-model/babyApplication-model-entity/src/main/java/edu/travel/enums/BaByRelationRoleEnum.java

@@ -0,0 +1,15 @@
+package edu.travel.enums;
+
+/**
+ * 宝宝亲属角色 类。
+ * <p>
+ * 描述:
+ *
+ * @author huangwenwen
+ * @date 2025/3/14
+ */
+
+
+public class BaByRelationRoleEnum {
+
+}

+ 3 - 34
babyApplication-model/babyApplication-model-entity/src/main/java/edu/travel/vo/BtAccountInfoVo.java

@@ -14,23 +14,13 @@ import java.util.Date;
  */
 @Data
 @TableName(value = "baby.bt_account_info")
-public class BtAccountInfoVo extends BaseEntity {
+public class BtAccountInfoVo{
     /**
      * 主键
      */
     private String id;
 
     /**
-     * 姓
-     */
-    private String surname;
-
-    /**
-     * 名
-     */
-    private String name;
-
-    /**
      * 昵称
      */
     private String nickname;
@@ -59,30 +49,9 @@ public class BtAccountInfoVo extends BaseEntity {
      * 生日日期
      */
     private Date birthday;
-
-    /**
-     * 用户状态:0-禁用,1-启用(默认启用)
-     */
-    private Integer userStatus;
-
-    /**
-     * 用户密码
-     */
-    private String password;
-
-    /**
-     * 默认语言
-     */
-    private Long defaultLanguageId;
-
-    /**
-     * 微信小程序openid
-     */
-    private String tenantOpenId;
-
     /**
-     * 微信小程序unionid
+     * token
      */
-    private String tenantUnionid;
+    private String token;
 
 }

+ 6 - 0
babyApplication-service/pom.xml

@@ -61,5 +61,11 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>3.19.2</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

+ 7 - 0
babyApplication-service/src/main/java/edu/travel/service/BtAccountInfoService.java

@@ -3,6 +3,7 @@ package edu.travel.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import edu.travel.dto.LoginDto;
 import edu.travel.dto.SendSmsDto;
+import edu.travel.dto.UpdateAccountDto;
 import edu.travel.entity.AccountInfo;
 import edu.travel.entity.BtAccountInfo;
 import edu.travel.vo.BtAccountInfoVo;
@@ -13,4 +14,10 @@ public interface BtAccountInfoService extends IService<BtAccountInfo> {
     BtAccountInfoVo doLogin(LoginDto loginDto);
 
     void sendSms(SendSmsDto sendSmsDto);
+
+    BtAccountInfoVo getAccountInfo();
+
+    BtAccountInfo addAccount(BtAccountInfo btAccountInfo);
+
+    BtAccountInfoVo updateAccountInfo(UpdateAccountDto updateAccountDto);
 }

+ 105 - 42
babyApplication-service/src/main/java/edu/travel/service/impl/BtAccountInfoServiceImpl.java

@@ -1,85 +1,90 @@
 package edu.travel.service.impl;
 
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.algorithms.Algorithm;
+import javax.crypto.SecretKey;
+import java.util.Date;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.json.JSONObject;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import edu.travel.FinalParam;
+import edu.travel.dto.UpdateAccountDto;
+import edu.travel.service.SysServiceImpl;
+
 import edu.travel.dto.LoginDto;
 import edu.travel.dto.SendSmsDto;
 import edu.travel.entity.AccountInfo;
 import edu.travel.entity.BtAccountInfo;
 import edu.travel.mapper.BtAccountInfoMapper;
 import edu.travel.service.BtAccountInfoService;
+import edu.travel.service.SysServiceImpl;
+import edu.travel.util.EncryptUtil;
+import edu.travel.util.JwtUtil;
 import edu.travel.util.SMSUtils;
+
+import javax.crypto.SecretKey;
 import javax.servlet.http.HttpServletRequest;
 
+import edu.travel.util.UserContext;
 import edu.travel.vo.BtAccountInfoVo;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
+import java.util.Date;
 import java.util.Random;
 import java.util.concurrent.TimeUnit;
 
 
 
 @Service
-public class BtAccountInfoServiceImpl extends ServiceImpl<BtAccountInfoMapper, BtAccountInfo> implements BtAccountInfoService {
+public class BtAccountInfoServiceImpl extends SysServiceImpl<BtAccountInfoMapper, BtAccountInfo> implements BtAccountInfoService {
 
-//    private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
     @Autowired
     private SMSUtils smsUtils;
     @Autowired
     private RedisTemplate redisTemplate;
+
+    @Autowired
+    private BtAccountInfoService btAccountInfoService;
+
+    private static final String SECRET_KEY = "your-secret-key-your-secret-key"; // 32+字符,生产环境请更换
+    private static final long EXPIRATION_TIME = 10000 * 60 * 60 * 24; // 240 小时
     @Override
     public BtAccountInfoVo doLogin(LoginDto loginDto) {
-//        BtAccountInfo accountInfoByPhone = getAccountInfoByPhone(accountInfo.getPhone());
-//        if (accountInfoByPhone != null){
-//            boolean passwordMatches = encoder.matches(accountInfo.getPassword(), accountInfoByPhone.getPassword());
-//            if (passwordMatches) {
-//                String token = TokenUtil.generateToken(accountInfo);
-//                AccountInfo accountInfo1 = BeanUtil.copyProperties(accountInfoByPhone, AccountInfo.class);
-//                accountInfo1.setToken(token);
-//                return accountInfo1;
-//            } else {
-//                throw new RuntimeException("密码错误");
-//            }
-//        } else {
-//            accountInfo.setPassword(encoder.encode(accountInfo.getPassword()));
-//            BtAccountInfo entity = BeanUtil.copyProperties(accountInfo, BtAccountInfo.class);
-//            save(entity);
-//
-//            AccountInfo accountInfo1 = BeanUtil.copyProperties(entity, AccountInfo.class);
-//            String token = TokenUtil.generateToken(accountInfo);
-//            accountInfo1.setToken(token);
-//            return accountInfo1;
-//        }
-
         String username = loginDto.getPhoneNumber();
-        // 1. 基本校验
-        if (ObjectUtil.isEmpty(loginDto) || StringUtils.isBlank(username) ) {
+
+        // 基本校验
+        if (ObjectUtil.isEmpty(loginDto) || StringUtils.isBlank(username)) {
             throw new UsernameNotFoundException("手机号不能为空");
         }
-        if (StringUtils.isBlank(loginDto.getCode())){
+        if (StringUtils.isBlank(loginDto.getCode())) {
             throw new UsernameNotFoundException("验证码不能为空");
         }
 
-        // 2. 获取当前请求
         HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
                 .currentRequestAttributes()).getRequest();
 
-        // 3. 查询用户
+        // 查询用户
         BtAccountInfo tenant = this.getOne(new LambdaQueryWrapper<BtAccountInfo>()
                 .eq(BtAccountInfo::getPhone, username));
         if (tenant == null) {
-            throw new UsernameNotFoundException("用户不存在");
+            tenant = btAccountInfoService.addAccount(BtAccountInfo.builder()
+                    .phone(loginDto.getPhoneNumber())
+                    .area(loginDto.getCountryCode())
+                    .build());
         }
 
-        // 4. 处理不同登录方式
+        // 处理不同登录方式
         String loginType = request.getParameter("loginFrom");
         if ("admin".equals(loginType)) {
             // 管理员密码登录
@@ -89,26 +94,29 @@ public class BtAccountInfoServiceImpl extends ServiceImpl<BtAccountInfoMapper, B
             }
         } else {
             // 用户短信登录
-            String code = loginDto.getCode();
-            String redisKey = username + "_sms_code";
-            String storedCode = redisTemplate.opsForValue().get(redisKey).toString();
-
-            if (!StringUtils.equals(code, storedCode)) {
-                throw new UsernameNotFoundException("验证码错误");
-            }
-            // 清除已用验证码
+            String redisKey = username + "_user_sms";
             redisTemplate.delete(redisKey);
+
+            // 生成 JWT token
+            String token = JwtUtil.generateJwtToken(tenant);
+
+            BtAccountInfoVo btAccountInfoVo = BeanUtil.copyProperties(tenant, BtAccountInfoVo.class);
+            btAccountInfoVo.setToken(token);
+
+            // 存入 Redis
+            redisTemplate.opsForValue().set(username + "_user_info", JSON.toJSONString(btAccountInfoVo));
+
+            return btAccountInfoVo;
         }
         return null;
     }
 
+
     @Override
     public void sendSms(SendSmsDto sendSmsDto) {
         if (ObjectUtil.isEmpty(sendSmsDto) || StringUtils.isBlank(sendSmsDto.getPhoneNumber())){
            throw new RuntimeException("手机号不能为空");
         }
-        // 校验图形验证码
-        String imageCode = (String) redisTemplate.opsForValue().get(sendSmsDto.getPhoneNumber() + "_image_code");
         //发送短信
         Object o = redisTemplate.opsForValue().get(sendSmsDto.getPhoneNumber() + "_user_sms");
         if (o!=null) throw new RuntimeException("验证码已发送,请一分钟后重试");
@@ -118,6 +126,37 @@ public class BtAccountInfoServiceImpl extends ServiceImpl<BtAccountInfoMapper, B
         smsUtils.sendMsg(sendSmsDto.getCountryCode(), sendSmsDto.getPhoneNumber(), smsCode);
     }
 
+    @Override
+    public BtAccountInfoVo getAccountInfo() {
+        BtAccountInfo loginUser = UserContext.getCurrentUser(BtAccountInfo.class);
+        if (ObjectUtil.isEmpty(loginUser)) throw new RuntimeException("用户未登录");
+        BtAccountInfo btAccountInfo = this.getOneLink(new LambdaQueryWrapper<BtAccountInfo>().eq(BtAccountInfo::getPhone, loginUser.getPhone()));
+        if (ObjectUtil.isEmpty(btAccountInfo)) throw new RuntimeException("用户不存在");
+        return BeanUtil.copyProperties(btAccountInfo, BtAccountInfoVo.class);
+    }
+
+    @Override
+//    @Transactional
+    public BtAccountInfo addAccount(BtAccountInfo btAccountInfo) {
+        if (ObjectUtil.isEmpty(btAccountInfo)) throw new RuntimeException("用户信息不能为空");
+        if (StringUtils.isBlank(btAccountInfo.getPhone())) throw new RuntimeException("手机号不能为空");
+        btAccountInfo.setPassword("123456");
+        this.save(btAccountInfo);
+        return btAccountInfo;
+    }
+
+    @Override
+    @Transactional
+    public BtAccountInfoVo updateAccountInfo(UpdateAccountDto updateAccountDto) {
+        BtAccountInfo loginUser = UserContext.getCurrentUser(BtAccountInfo.class);
+        if (ObjectUtil.isEmpty(loginUser)) throw new RuntimeException("用户未登录");
+        BtAccountInfo btAccountInfo = this.getOneLink(new LambdaQueryWrapper<BtAccountInfo>().eq(BtAccountInfo::getId, loginUser.getId()));
+        if (ObjectUtil.isEmpty(btAccountInfo)) throw new RuntimeException("用户不存在");
+        BtAccountInfo entity = BeanUtil.copyProperties(updateAccountDto, BtAccountInfo.class);
+        this.updateById(entity);
+        return BeanUtil.copyProperties(this.getOneLink(new LambdaQueryWrapper<BtAccountInfo>().eq(BtAccountInfo::getId, updateAccountDto.getId())), BtAccountInfoVo.class);
+    }
+
 
     /**
      * 根据手机号查询用户
@@ -131,4 +170,28 @@ public class BtAccountInfoServiceImpl extends ServiceImpl<BtAccountInfoMapper, B
         }
         return null;
     }
+
+    /**
+     * 获取登录用户信息
+     */
+//    public BtAccountInfo getLoginUser() {
+////        BtAccountInfo principal = (BtAccountInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+//
+//        return principal;
+//    }
+
+    /**
+     * 生成 JWT Token
+     */
+    private String generateJwtToken(BtAccountInfo user) {
+        return JWT.create()
+                .withSubject(user.getPhone())
+                .withClaim("userInfo", JSON.toJSONString(user))
+                .withIssuedAt(new Date())
+                .withExpiresAt(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
+                .sign(Algorithm.HMAC256(SECRET_KEY)); // HMAC SHA256 加密
+    }
+
+
+
 }

+ 4 - 1
babyApplication-service/src/main/java/edu/travel/service/impl/BtBabyUserRelationServiceImpl.java

@@ -1,6 +1,9 @@
 package edu.travel.service.impl;
 
+import edu.travel.service.SysServiceImpl;
+
 import edu.travel.service.BtBabyUserRelationService;
+import edu.travel.service.SysServiceImpl;
 import org.springframework.stereotype.Service;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -9,7 +12,7 @@ import edu.travel.entity.BtBabyUserRelation;
 import edu.travel.mapper.BtBabyUserRelationMapper;
 
 @Service
-public class BtBabyUserRelationServiceImpl implements BtBabyUserRelationService {
+public class BtBabyUserRelationServiceImpl extends SysServiceImpl<BtBabyUserRelationMapper, BtBabyUserRelation> implements BtBabyUserRelationService {
 
 
 }

+ 2 - 2
babyApplication-service/src/main/java/edu/travel/service/impl/BtBodyRecordServiceImpl.java

@@ -1,15 +1,15 @@
 package edu.travel.service.impl;
 
 import edu.travel.service.BtBodyRecordService;
+import edu.travel.service.SysServiceImpl;
 import org.springframework.stereotype.Service;
 
-import org.springframework.beans.factory.annotation.Autowired;
 
 import edu.travel.mapper.BtBodyRecordMapper;
 import edu.travel.entity.BtBodyRecord;
 
 @Service
-public class BtBodyRecordServiceImpl implements BtBodyRecordService {
+public class BtBodyRecordServiceImpl extends SysServiceImpl<BtBodyRecordMapper, BtBodyRecord> implements BtBodyRecordService {
 
 
 }

+ 2 - 2
babyApplication-service/src/main/java/edu/travel/service/impl/BtFeedRecordServiceImpl.java

@@ -1,14 +1,14 @@
 package edu.travel.service.impl;
 
+import edu.travel.service.SysServiceImpl;
 import edu.travel.service.BtFeedRecordService;
 import org.springframework.stereotype.Service;
 
-import org.springframework.beans.factory.annotation.Autowired;
 
 import edu.travel.entity.BtFeedRecord;
 import edu.travel.mapper.BtFeedRecordMapper;
 
 @Service
-public class BtFeedRecordServiceImpl implements BtFeedRecordService {
+public class BtFeedRecordServiceImpl extends SysServiceImpl<BtFeedRecordMapper, BtFeedRecord> implements BtFeedRecordService {
 
 }

+ 3 - 1
babyApplication-service/src/main/java/edu/travel/service/impl/BtMessageServiceImpl.java

@@ -1,5 +1,7 @@
 package edu.travel.service.impl;
 
+import edu.travel.service.SysServiceImpl;
+
 import edu.travel.service.BtMessageService;
 import org.springframework.stereotype.Service;
 
@@ -9,6 +11,6 @@ import edu.travel.entity.BtMessage;
 import edu.travel.mapper.BtMessageMapper;
 
 @Service
-public class BtMessageServiceImpl implements BtMessageService {
+public class BtMessageServiceImpl extends SysServiceImpl<BtMessageMapper, BtMessage> implements BtMessageService {
 
 }

+ 3 - 1
babyApplication-service/src/main/java/edu/travel/service/impl/MtFavoriteSongsServiceImpl.java

@@ -1,5 +1,7 @@
 package edu.travel.service.impl;
 
+import edu.travel.service.SysServiceImpl;
+
 import edu.travel.service.MtFavoriteSongsService;
 import org.springframework.stereotype.Service;
 
@@ -9,7 +11,7 @@ import edu.travel.mapper.MtFavoriteSongsMapper;
 import edu.travel.entity.MtFavoriteSongs;
 
 @Service
-public class MtFavoriteSongsServiceImpl implements MtFavoriteSongsService {
+public class MtFavoriteSongsServiceImpl extends SysServiceImpl<MtFavoriteSongsMapper, MtFavoriteSongs> implements MtFavoriteSongsService {
 
 
 }

+ 3 - 1
babyApplication-service/src/main/java/edu/travel/service/impl/MtRelativeRolesServiceImpl.java

@@ -1,5 +1,7 @@
 package edu.travel.service.impl;
 
+import edu.travel.service.SysServiceImpl;
+
 import edu.travel.service.MtRelativeRolesService;
 import org.springframework.stereotype.Service;
 
@@ -9,7 +11,7 @@ import edu.travel.mapper.MtRelativeRolesMapper;
 import edu.travel.entity.MtRelativeRoles;
 
 @Service
-public class MtRelativeRolesServiceImpl implements MtRelativeRolesService {
+public class MtRelativeRolesServiceImpl extends SysServiceImpl<MtRelativeRolesMapper, MtRelativeRoles> implements MtRelativeRolesService {
 
 
 }

+ 7 - 0
babyApplication-web/pom.xml

@@ -60,5 +60,12 @@
             <version>1.9.7</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>3.19.2</version>
+        </dependency>
+
+
     </dependencies>
 </project>

+ 2 - 1
babyApplication-web/src/main/java/edu/travel/config/SecurityConfig.java

@@ -57,7 +57,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
                 .authorizeRequests()
                 // 允许匿名访问
                 .antMatchers(
-                        "/baby/login/**"
+                        "/baby/login/**",
+                        "/baby/account/**"
                         ).permitAll()
                 .antMatchers(
                         HttpMethod.GET,

+ 0 - 38
babyApplication-web/src/main/java/edu/travel/constanst/Constants.java

@@ -1,38 +0,0 @@
-package edu.travel.constanst;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 常量定义
- *
- * Created by FSQ
- * CopyRight https://www.fuint.cn
- */
-public class Constants {
-
-    // 第几页,默认第1页
-    public static final int PAGE_NUMBER = 1;
-
-    // 每页记录数,默认20条
-    public static final int PAGE_SIZE = 20;
-
-    // 读取数据最多行数
-    public static final int MAX_ROWS = 2000;
-
-    // 读取数据全部行数
-    public static final int ALL_ROWS = 1000000;
-
-    /**
-     * 系统配置, 从setting表中读取
-     */
-    public static Map<String, String> SYS_CONFIGS = new HashMap<String, String>();
-
-    public static final int HTTP_RESPONSE_CODE_PARAM_ERROR = 202;
-    public static final int HTTP_RESPONSE_CODE_USER_NOT_EXIST = 402;
-    public static final int HTTP_RESPONSE_CODE_USER_LOGIN_ERROR = 403;
-    public static final int HTTP_RESPONSE_CODE_NOLOGIN = 1001;
-
-    public static final String SESSION_USER = "BABY_USER";
-    public static final String SESSION_ADMIN_USER = "BABY_ADMIN_USER";
-}

+ 38 - 0
babyApplication-web/src/main/java/edu/travel/exception/GlobalExceptionHandler.java

@@ -0,0 +1,38 @@
+package edu.travel.exception;
+
+import edu.travel.emun.ResponseCode;
+import edu.travel.resp.BaseResponse;
+import edu.travel.resp.PageResponse;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
+/**
+ * GlobalExceptionHandler 类。
+ * <p>
+ * 描述:
+ *
+ * @author huangwenwen
+ * @date 2025/3/14
+ */
+
+
+public class GlobalExceptionHandler {
+
+    @ExceptionHandler(BaseException.class)
+    public BaseResponse<Object> handleUserInfoException(BaseException e){
+        e.printStackTrace();
+        return  PageResponse.out(e.getCode(),e.getMessage(),null);
+    }
+
+    @ExceptionHandler(IllegalArgumentException.class)
+    public BaseResponse<Object> handleException(IllegalArgumentException e){
+        e.printStackTrace();
+        return PageResponse.out(ResponseCode.LOGIC_ERROR.getCode(), e.getMessage(),null);
+    }
+
+    @ExceptionHandler(Throwable.class)
+    public BaseResponse<Object> handleException(Exception e){
+        e.printStackTrace();
+        return PageResponse.out(ResponseCode.ERROR.getCode(),e.getMessage(),null);
+    }
+
+}

+ 20 - 59
babyApplication-web/src/main/java/edu/travel/filter/LoginFilter.java

@@ -1,27 +1,22 @@
 package edu.travel.filter;
 
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import edu.travel.util.JwtUtil;
+import edu.travel.vo.BtAccountInfoVo;
 import org.apache.commons.lang3.StringUtils;
-import com.nimbusds.jose.JWSObject;
-import edu.travel.FinalParam;
-import edu.travel.util.EncryptUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
 import javax.servlet.*;
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.text.ParseException;
-import java.util.*;
+
 /**
  * LoginFilter 类。
  * <p>
- * 描述:
+ * 描述:拦截请求,解析 JWT 并从 Redis 获取用户信息
  *
  * @author huangwenwen
  * @date 2025/3/11
@@ -30,8 +25,8 @@ import java.util.*;
 @Component
 public class LoginFilter implements Filter {
 
-//    @Autowired
-//    private RedisTemplate<String, Object> redisTemplate;
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
 
     @Override
     public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
@@ -40,73 +35,39 @@ public class LoginFilter implements Filter {
         HttpServletRequest request = (HttpServletRequest) servletRequest;
         HttpServletResponse response = (HttpServletResponse) servletResponse;
 
-        // 获取请求路径
         String requestURI = request.getRequestURI();
 
-        // **放行登录相关接口**
         if (requestURI.startsWith("/baby/login")) {
             filterChain.doFilter(request, response);
             return;
         }
 
-        // 获取 token
         String token = request.getHeader("Authorization");
 
-        if (StringUtils.isBlank(token) || token.equals("null")) {
+        if (StringUtils.isBlank(token) || "null".equals(token)) {
             filterChain.doFilter(request, response);
             return;
         }
 
-        // 替换 Bearer 头
-        String realToken = token.replace("Bearer ", "");
         try {
-            JWSObject jwsObject = JWSObject.parse(realToken);
-            String userStr = jwsObject.getPayload().toString();
-            JSONObject jsonObject = JSON.parseObject(userStr);
-
-            // 提取权限信息
-            Object object = jsonObject.get(FinalParam.AUTHORITY_CLAIM_NAME);
-            List<String> authorities = new ArrayList<>();
-
-            if (object != null) {
-                if (object instanceof JSONArray) {
-                    authorities = ((JSONArray) object).toJavaList(String.class);
-                } else {
-                    String authoritiesStr = object.toString();
-                    JSONArray authoritiesArray = JSON.parseArray(authoritiesStr);
-                    authorities = authoritiesArray.toJavaList(String.class);
-                }
+            BtAccountInfoVo user = JwtUtil.parseJwtToken(token.replace("Bearer ", ""), BtAccountInfoVo.class);
+            if (user == null) {
+                filterChain.doFilter(request, response);
+                return;
             }
 
-            // 提取用户名和客户端ID
-            String principal = jsonObject.getObject("user_name", String.class);
-            String clientId = jsonObject.getObject("client_id", String.class);
-
-            // 封装到 Map
-            Map<String, Object> map = new HashMap<>();
-            map.put("authorities", authorities);
-            map.put("client_id", clientId);
-            map.put("principal", principal);
-
-            // 生成新的 token(Base64 编码)
-            String newToken = EncryptUtil.encodeUTF8StringBase64(JSON.toJSONString(map));
-
-            // 将 token 添加到请求头
-            HttpServletRequestWrapper requestWrapper = new HttpServletRequestWrapper(request) {
-                @Override
-                public String getHeader(String name) {
-                    if ("token".equals(name)) {
-                        return newToken;
-                    }
-                    return super.getHeader(name);
+            String redisUserJson = redisTemplate.opsForValue().get(user.getPhone() + "_user_info");
+            if (StringUtils.isNotBlank(redisUserJson)) {
+                BtAccountInfoVo redisUser = JSON.parseObject(redisUserJson, BtAccountInfoVo.class);
+                if (redisUser != null) {
+                    request.setAttribute("currentUser", redisUser);
                 }
-            };
-
-            filterChain.doFilter(requestWrapper, response);
+            }
 
-        } catch (ParseException e) {
+        } catch (Exception e) {
             e.printStackTrace();
-            filterChain.doFilter(request, response);
         }
+
+        filterChain.doFilter(request, response);
     }
 }

+ 2 - 2
babyApplication-web/src/main/java/edu/travel/filter/TokenAuthenticationFilter.java

@@ -29,10 +29,10 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
-@Component
+//@Component
 public class TokenAuthenticationFilter extends OncePerRequestFilter {
 
-    @Autowired
+//    @Autowired
     private BtAccountInfoService btAccountInfoService;  // 在单体应用中用数据库查询
 
     @Override

+ 33 - 3
babyApplication-web/src/main/java/edu/travel/web/BtAccountInfoController.java

@@ -1,16 +1,46 @@
 package edu.travel.web;
+import edu.travel.dto.UpdateAccountDto;
 import edu.travel.entity.BtAccountInfo;
+import edu.travel.resp.BaseResponse;
+import edu.travel.service.BtAccountInfoService;
+import edu.travel.vo.BtAccountInfoVo;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.web.bind.annotation.*;
 
 import org.springframework.beans.factory.annotation.Autowired;
 
 /**
-* 用户表(bt_account_info)表控制层
+* 用户相关接口
 *
-* @author xxxxx
+* @author huangwenwen
 */
 @RestController
-@RequestMapping("/bt_account_info")
+@RequestMapping("/baby/account")
 public class BtAccountInfoController extends BaseController<BtAccountInfo>{
 
+    @Autowired
+    private BtAccountInfoService btAccountInfoService;
+
+
+    /**
+     * 获取用户信息
+     * @return
+     */
+    @GetMapping("/getAccountInfo")
+    public BaseResponse<BtAccountInfoVo> getAccountInfo(){
+        BtAccountInfoVo vo = btAccountInfoService.getAccountInfo();
+        return new BaseResponse<>(200, "sucess", vo);
+    }
+
+    /**
+     * 修改用户信息
+     * @param updateAccountDto
+     * @return
+     */
+    @PostMapping("/updateAccountInfo")
+    public BaseResponse<BtAccountInfoVo> updateAccountInfo(@RequestBody UpdateAccountDto updateAccountDto){
+        BtAccountInfoVo vo = btAccountInfoService.updateAccountInfo(updateAccountDto);
+        return new BaseResponse<>(200, "sucess", vo);
+    }
+
 }

+ 4 - 1
babyApplication-web/src/main/java/edu/travel/web/BtBabyUserRelationController.java

@@ -1,4 +1,5 @@
 package edu.travel.web;
+import edu.travel.entity.BtBabyUserRelation;
 import org.springframework.web.bind.annotation.*;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -10,5 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 */
 @RestController
 @RequestMapping("/bt_baby_user_relation")
-public class BtBabyUserRelationController {
+public class BtBabyUserRelationController extends BaseController<BtBabyUserRelation>{
+
+//    @PostMapping("新增宝宝亲属关系")
 }

+ 4 - 1
babyApplication-web/src/main/java/edu/travel/web/BtMessageController.java

@@ -1,4 +1,5 @@
 package edu.travel.web;
+import edu.travel.entity.BtMessage;
 import org.springframework.web.bind.annotation.*;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -10,7 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 */
 @RestController
 @RequestMapping("/bt_message")
-public class BtMessageController {
+public class BtMessageController extends BaseController<BtMessage>{
+
+
 
 
 }

+ 4 - 1
babyApplication-web/src/main/java/edu/travel/web/LoginController.java

@@ -5,6 +5,7 @@ import edu.travel.dto.SendSmsDto;
 import edu.travel.resp.BaseResponse;
 import edu.travel.service.BtAccountInfoService;
 import edu.travel.vo.BtAccountInfoVo;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 /**
@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
 @RequestMapping("/baby/login")
 public class LoginController {
 
+    @Autowired
     private BtAccountInfoService btAccountInfoService;
 
     /**
@@ -30,7 +32,8 @@ public class LoginController {
      */
     @PostMapping("/doLogin")
     public BaseResponse<BtAccountInfoVo> doLogin(@RequestBody LoginDto loginDto) {
-        return new BaseResponse<>(200,"登陆成功",btAccountInfoService.doLogin(loginDto)) ;
+        BtAccountInfoVo btAccountInfoVo = btAccountInfoService.doLogin(loginDto);
+        return new BaseResponse<>(200,"登陆成功", btAccountInfoVo) ;
     }
 
     /**

+ 0 - 41
babyApplication-web/src/main/resources/application-dev.properties

@@ -1,41 +0,0 @@
-spring.application.name=baby
-
-spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.url=jdbc:mysql://101.126.146.250:3306/edu?useUnicode=true&characterEncoding=UTF8&useSSL=false
-spring.datasource.username=root
-spring.datasource.password=XYY1q2w!
-
-mybatis.mapperLocations=classpath:/mapper/*Mapper.xml
-
-mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
-
-huaweicloud.obs.mode = 1
-huaweicloud.obs.expireSeconds=1000
-huaweicloud.obs.endpoint=obs.cn-north-4.myhuaweicloud.com
-huaweicloud.obs.accessKey=C9WI47G4DXXN2EMIL1OO
-huaweicloud.obs.secretKey=tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
-huaweicloud.obs.bucketName=v-xiaoyaotravel
-huaweicloud.moderation.accessKey=C9WI47G4DXXN2EMIL1OO
-huaweicloud.moderation.secretKey=tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
-huaweicloud.moderation.region=cn-north-4
-huaweicloud.moderation.projectId=23089a903d5041b4a55170556cf8cae1
-
-huaweicloud.obs.folder = fuint_uploads
-#huaweicloud.obs.domain = https://v-xiaoyaotravel.obs.cn-north-4.myhuaweicloud.com
-huaweicloud.obs.domain = https://v.xiaoyaotravel.com
-
-images.root=C:/fuintFoodSystem_v1.3/fuintBackend/fuint-application/target/classes
-images.path=/static/uploadImages/
-
-images.upload.url=http://localhost:8080
-
-spring.redis.host=localhost
-spring.redis.port=6379
-spring.redis.database=0
-
-spring.jackson.date-format= yyyy-MM-dd HH:mm
-spring.jackson.time-zone= GMT+8
-
-spring.servlet.multipart.enabled=true
-spring.servlet.multipart.max-file-size=20MB
-spring.servlet.multipart.max-request-size=200MB

+ 0 - 41
babyApplication-web/src/main/resources/application-prod.properties

@@ -1,41 +0,0 @@
-spring.application.name=baby
-
-spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.url=jdbc:mysql://101.126.146.250:3306/edu?useUnicode=true&characterEncoding=UTF8&useSSL=false
-spring.datasource.username=root
-spring.datasource.password=XYY1q2w!
-
-mybatis.mapperLocations=classpath:/mapper/*Mapper.xml
-
-mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
-
-huaweicloud.obs.mode = 1
-huaweicloud.obs.expireSeconds=1000
-huaweicloud.obs.endpoint=obs.cn-north-4.myhuaweicloud.com
-huaweicloud.obs.accessKey=C9WI47G4DXXN2EMIL1OO
-huaweicloud.obs.secretKey=tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
-huaweicloud.obs.bucketName=v-xiaoyaotravel
-huaweicloud.moderation.accessKey=C9WI47G4DXXN2EMIL1OO
-huaweicloud.moderation.secretKey=tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
-huaweicloud.moderation.region=cn-north-4
-huaweicloud.moderation.projectId=23089a903d5041b4a55170556cf8cae1
-
-huaweicloud.obs.folder = fuint_uploads
-#huaweicloud.obs.domain = https://v-xiaoyaotravel.obs.cn-north-4.myhuaweicloud.com
-huaweicloud.obs.domain = https://v.xiaoyaotravel.com
-
-images.root=C:/fuintFoodSystem_v1.3/fuintBackend/fuint-application/target/classes
-images.path=/static/uploadImages/
-
-images.upload.url=http://localhost:8080
-
-spring.redis.host=localhost
-spring.redis.port=6379
-spring.redis.database=0
-
-spring.jackson.date-format= yyyy-MM-dd HH:mm
-spring.jackson.time-zone= GMT+8
-
-spring.servlet.multipart.enabled=true
-spring.servlet.multipart.max-file-size=20MB
-spring.servlet.multipart.max-request-size=200MB

+ 0 - 50
babyApplication-web/src/main/resources/application-test.properties

@@ -1,50 +0,0 @@
-server.port=8081
-spring.application.name=baby
-
-spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.url=jdbc:mysql://101.126.146.250:3306/baby?useUnicode=true&characterEncoding=UTF8&useSSL=false
-spring.datasource.username=root
-spring.datasource.password=XYY1q2w!
-
-mybatis.mapperLocations=classpath:/mapper/*Mapper.xml
-
-mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
-
-huaweicloud.obs.mode = 1
-huaweicloud.obs.expireSeconds=1000
-huaweicloud.obs.endpoint=obs.cn-north-4.myhuaweicloud.com
-huaweicloud.obs.accessKey=C9WI47G4DXXN2EMIL1OO
-huaweicloud.obs.secretKey=tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
-huaweicloud.obs.bucketName=v-xiaoyaotravel
-huaweicloud.moderation.accessKey=C9WI47G4DXXN2EMIL1OO
-huaweicloud.moderation.secretKey=tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
-huaweicloud.moderation.region=cn-north-4
-huaweicloud.moderation.projectId=23089a903d5041b4a55170556cf8cae1
-
-huaweicloud.obs.folder = fuint_uploads
-#huaweicloud.obs.domain = https://v-xiaoyaotravel.obs.cn-north-4.myhuaweicloud.com
-huaweicloud.obs.domain = https://v.xiaoyaotravel.com
-
-images.root=C:/fuintFoodSystem_v1.3/fuintBackend/fuint-application/target/classes
-images.path=/static/uploadImages/
-
-images.upload.url=http://localhost:8080
-
-spring.redis.host=192.168.1.44
-spring.redis.port=6379
-spring.redis.database=0
-
-spring.jackson.date-format= yyyy-MM-dd HH:mm
-spring.jackson.time-zone= GMT+8
-
-spring.servlet.multipart.enabled=true
-spring.servlet.multipart.max-file-size=20MB
-spring.servlet.multipart.max-request-size=200MB
-
-sms.blends.huoshan.ak=AKLTYzA3ZDNiY2M5MWNlNGM1NThhM2ZlN2JhNTIyYWMxZDA
-sms.blends.huoshan.sk=WXpVME1USTBNbVprTnpKaU5HTTNORGhsT1dJNU1tUXlaVFl4TjJVeE1Uaw==
-sms.blends.huoshan.smsAccount=7fe76339
-sms.blends.huoshan.chinaSign=??????????
-sms.blends.huoshan.otherSign=XYTravel
-sms.blends.huoshan.chinaTemplateId=ST_7fe71e56
-sms.blends.huoshan.otherTemplateId=ST_7fe70c7c

+ 67 - 0
babyApplication-web/src/main/resources/application-test.yaml

@@ -0,0 +1,67 @@
+server:
+  port: 8081
+  servlet:
+    encoding:
+      enable: true
+      charset: UTF-8
+      force: true
+  tomcat:
+    uri-encoding: UTF-8
+spring:
+  application:
+    name: baby
+#  profiles:
+#    active: test
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://101.126.146.250:3306/baby?useUnicode=true&characterEncoding=UTF8&useSSL=false
+    username: root
+    password: XYY1q2w!
+  redis:
+    host: 192.168.1.44
+    port: 6379
+    database: 0
+  jackson:
+    date-format: yyyy-MM-dd HH:mm
+    time-zone: GMT+8
+  servlet:
+    multipart:
+      enabled: true
+      max-file-size: 20MB
+      max-request-size: 200MB
+mybatis:
+  mapperLocations: classpath:/mapper/*Mapper.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+huaweicloud:
+  obs:
+    mode: 1
+    expireSeconds: 1000
+    endpoint: obs.cn-north-4.myhuaweicloud.com
+    accessKey: C9WI47G4DXXN2EMIL1OO
+    secretKey: tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
+    bucketName: v-xiaoyaotravel
+    folder: baby_uploads
+    #huaweicloud.obs.domain = https://v-xiaoyaotravel.obs.cn-north-4.myhuaweicloud.com
+    domain: https://v.xiaoyaotravel.com
+  moderation:
+    accessKey: C9WI47G4DXXN2EMIL1OO
+    secretKey: tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
+    region: cn-north-4
+    projectId: 23089a903d5041b4a55170556cf8cae1
+images:
+  root: C:/fuintFoodSystem_v1.3/fuintBackend/fuint-application/target/classes
+  path: /static/uploadImages/
+  upload:
+    url: http://localhost:8080
+sms:
+  blends:
+    huoshan:
+      ak: AKLTYzA3ZDNiY2M5MWNlNGM1NThhM2ZlN2JhNTIyYWMxZDA
+      sk: WXpVME1USTBNbVprTnpKaU5HTTNORGhsT1dJNU1tUXlaVFl4TjJVeE1Uaw==
+      enable: false
+      smsAccount: 7fe76339
+      chinaSign: 山东老韩国际人才合作
+      otherSign: XYTravel
+      chinaTemplateId: ST_7fe71e56
+      otherTemplateId: ST_7fe70c7c

+ 0 - 51
babyApplication-web/src/main/resources/application.properties

@@ -1,51 +0,0 @@
-server.port=8081
-spring.application.name=baby
-spring.profiles.active=test
-
-spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.url=jdbc:mysql://101.126.146.250:3306/baby?useUnicode=true&characterEncoding=UTF8&useSSL=false
-spring.datasource.username=root
-spring.datasource.password=XYY1q2w!
-
-mybatis.mapperLocations=classpath:/mapper/*Mapper.xml
-
-mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
-
-huaweicloud.obs.mode = 1
-huaweicloud.obs.expireSeconds=1000
-huaweicloud.obs.endpoint=obs.cn-north-4.myhuaweicloud.com
-huaweicloud.obs.accessKey=C9WI47G4DXXN2EMIL1OO
-huaweicloud.obs.secretKey=tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
-huaweicloud.obs.bucketName=v-xiaoyaotravel
-huaweicloud.moderation.accessKey=C9WI47G4DXXN2EMIL1OO
-huaweicloud.moderation.secretKey=tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
-huaweicloud.moderation.region=cn-north-4
-huaweicloud.moderation.projectId=23089a903d5041b4a55170556cf8cae1
-
-huaweicloud.obs.folder = fuint_uploads
-#huaweicloud.obs.domain = https://v-xiaoyaotravel.obs.cn-north-4.myhuaweicloud.com
-huaweicloud.obs.domain = https://v.xiaoyaotravel.com
-
-images.root=C:/fuintFoodSystem_v1.3/fuintBackend/fuint-application/target/classes
-images.path=/static/uploadImages/
-
-images.upload.url=http://localhost:8080
-
-spring.redis.host=192.168.1.44
-spring.redis.port=6379
-spring.redis.database=0
-
-spring.jackson.date-format= yyyy-MM-dd HH:mm
-spring.jackson.time-zone= GMT+8
-
-spring.servlet.multipart.enabled=true
-spring.servlet.multipart.max-file-size=20MB
-spring.servlet.multipart.max-request-size=200MB
-
-sms.blends.huoshan.ak=AKLTYzA3ZDNiY2M5MWNlNGM1NThhM2ZlN2JhNTIyYWMxZDA
-sms.blends.huoshan.sk=WXpVME1USTBNbVprTnpKaU5HTTNORGhsT1dJNU1tUXlaVFl4TjJVeE1Uaw==
-sms.blends.huoshan.smsAccount=7fe76339
-sms.blends.huoshan.chinaSign=??????????
-sms.blends.huoshan.otherSign=XYTravel
-sms.blends.huoshan.chinaTemplateId=ST_7fe71e56
-sms.blends.huoshan.otherTemplateId=ST_7fe70c7c

+ 67 - 0
babyApplication-web/src/main/resources/application.yaml

@@ -0,0 +1,67 @@
+server:
+  port: 8081
+  servlet:
+    encoding:
+      enable: true
+      charset: UTF-8
+      force: true
+  tomcat:
+    uri-encoding: UTF-8
+spring:
+  application:
+    name: baby
+  profiles:
+    active: test
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://101.126.146.250:3306/baby?useUnicode=true&characterEncoding=UTF8&useSSL=false
+    username: root
+    password: XYY1q2w!
+  redis:
+    host: 192.168.1.44
+    port: 6379
+    database: 0
+  jackson:
+    date-format: yyyy-MM-dd HH:mm
+    time-zone: GMT+8
+  servlet:
+    multipart:
+      enabled: true
+      max-file-size: 20MB
+      max-request-size: 200MB
+mybatis:
+  mapperLocations: classpath:/mapper/*Mapper.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+huaweicloud:
+  obs:
+    mode: 1
+    expireSeconds: 1000
+    endpoint: obs.cn-north-4.myhuaweicloud.com
+    accessKey: C9WI47G4DXXN2EMIL1OO
+    secretKey: tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
+    bucketName: v-xiaoyaotravel
+    folder: baby_uploads
+    #huaweicloud.obs.domain = https://v-xiaoyaotravel.obs.cn-north-4.myhuaweicloud.com
+    domain: https://v.xiaoyaotravel.com
+  moderation:
+    accessKey: C9WI47G4DXXN2EMIL1OO
+    secretKey: tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
+    region: cn-north-4
+    projectId: 23089a903d5041b4a55170556cf8cae1
+images:
+  root: C:/fuintFoodSystem_v1.3/fuintBackend/fuint-application/target/classes
+  path: /static/uploadImages/
+  upload:
+    url: http://localhost:8080
+sms:
+  blends:
+    huoshan:
+      ak: AKLTYzA3ZDNiY2M5MWNlNGM1NThhM2ZlN2JhNTIyYWMxZDA
+      sk: WXpVME1USTBNbVprTnpKaU5HTTNORGhsT1dJNU1tUXlaVFl4TjJVeE1Uaw==
+      enable: false
+      smsAccount: 7fe76339
+      chinaSign: 山东老韩国际人才合作
+      otherSign: XYTravel
+      chinaTemplateId: ST_7fe71e56
+      otherTemplateId: ST_7fe70c7c