Преглед изворни кода

"微信一键登录实现"

yu_u66 пре 2 недеља
родитељ
комит
a1c5311275

+ 10 - 0
pom.xml

@@ -15,6 +15,16 @@
     </properties>
     <dependencies>
         <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.3</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.8.16</version>
+        </dependency>
+        <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>fastjson</artifactId>
             <version>1.2.80</version>

+ 1 - 1
src/main/java/com/futu/course/GooseApplication.java

@@ -5,7 +5,7 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
 @SpringBootApplication
-@MapperScan("com.futu.course")
+@MapperScan("com.futu.course.*.mapper")
 public class GooseApplication {
 
     public static void main(String[] args) {

+ 0 - 157
src/main/java/com/futu/course/user/domain/User.java

@@ -1,157 +0,0 @@
-package com.futu.course.user.domain;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import java.io.Serializable;
-import java.util.Date;
-import lombok.Data;
-
-/**
- * 用户表
- * @TableName user
- */
-@TableName(value ="user")
-@Data
-public class User implements Serializable {
-    /**
-     * 用户ID(使用Snowflake算法生成)
-     */
-    @TableId
-    private Long id;
-
-    /**
-     * 
-     */
-    private String openId;
-
-    /**
-     * 
-     */
-    private String unionId;
-
-    /**
-     * 
-     */
-    private String sessionKey;
-
-    /**
-     * 登录账号
-     */
-    private String username;
-
-    /**
-     * 加密后的密码
-     */
-    private String password;
-
-    /**
-     * 盐
-     */
-    private String salt;
-
-    /**
-     * 昵称
-     */
-    private String nickname;
-
-    /**
-     * 头像URL
-     */
-    private String avatar;
-
-    /**
-     * 手机号
-     */
-    private String mobile;
-
-    /**
-     * 会员等级(0-普通用户)
-     */
-    private Integer memberLevel;
-
-    /**
-     * 状态(0-禁用 1-正常)
-     */
-    private Integer status;
-
-    /**
-     * 
-     */
-    private Date createTime;
-
-    @TableField(exist = false)
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public boolean equals(Object that) {
-        if (this == that) {
-            return true;
-        }
-        if (that == null) {
-            return false;
-        }
-        if (getClass() != that.getClass()) {
-            return false;
-        }
-        User other = (User) that;
-        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
-            && (this.getOpenId() == null ? other.getOpenId() == null : this.getOpenId().equals(other.getOpenId()))
-            && (this.getUnionId() == null ? other.getUnionId() == null : this.getUnionId().equals(other.getUnionId()))
-            && (this.getSessionKey() == null ? other.getSessionKey() == null : this.getSessionKey().equals(other.getSessionKey()))
-            && (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
-            && (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
-            && (this.getSalt() == null ? other.getSalt() == null : this.getSalt().equals(other.getSalt()))
-            && (this.getNickname() == null ? other.getNickname() == null : this.getNickname().equals(other.getNickname()))
-            && (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar()))
-            && (this.getMobile() == null ? other.getMobile() == null : this.getMobile().equals(other.getMobile()))
-            && (this.getMemberLevel() == null ? other.getMemberLevel() == null : this.getMemberLevel().equals(other.getMemberLevel()))
-            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
-            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
-        result = prime * result + ((getOpenId() == null) ? 0 : getOpenId().hashCode());
-        result = prime * result + ((getUnionId() == null) ? 0 : getUnionId().hashCode());
-        result = prime * result + ((getSessionKey() == null) ? 0 : getSessionKey().hashCode());
-        result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
-        result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
-        result = prime * result + ((getSalt() == null) ? 0 : getSalt().hashCode());
-        result = prime * result + ((getNickname() == null) ? 0 : getNickname().hashCode());
-        result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode());
-        result = prime * result + ((getMobile() == null) ? 0 : getMobile().hashCode());
-        result = prime * result + ((getMemberLevel() == null) ? 0 : getMemberLevel().hashCode());
-        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
-        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getClass().getSimpleName());
-        sb.append(" [");
-        sb.append("Hash = ").append(hashCode());
-        sb.append(", id=").append(id);
-        sb.append(", openId=").append(openId);
-        sb.append(", unionId=").append(unionId);
-        sb.append(", sessionKey=").append(sessionKey);
-        sb.append(", username=").append(username);
-        sb.append(", password=").append(password);
-        sb.append(", salt=").append(salt);
-        sb.append(", nickname=").append(nickname);
-        sb.append(", avatar=").append(avatar);
-        sb.append(", mobile=").append(mobile);
-        sb.append(", memberLevel=").append(memberLevel);
-        sb.append(", status=").append(status);
-        sb.append(", createTime=").append(createTime);
-        sb.append(", serialVersionUID=").append(serialVersionUID);
-        sb.append("]");
-        return sb.toString();
-    }
-}

+ 0 - 18
src/main/java/com/futu/course/user/mapper/UserMapper.java

@@ -1,18 +0,0 @@
-package com.futu.course.user.mapper;
-
-import com.futu.course.user.domain.User;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
-* @author yuu
-* @description 针对表【user(用户表)】的数据库操作Mapper
-* @createDate 2025-05-05 18:52:53
-* @Entity com.futu.course.user.domain.User
-*/
-public interface UserMapper extends BaseMapper<User> {
-
-}
-
-
-
-

+ 0 - 1
src/main/java/com/futu/course/user/service/UserService.java

@@ -10,5 +10,4 @@ import com.baomidou.mybatisplus.extension.service.IService;
 */
 public interface UserService extends IService<User> {
 
-
 }

+ 3 - 19
src/main/java/com/futu/course/user/service/impl/UserServiceImpl.java

@@ -1,19 +1,10 @@
 package com.futu.course.user.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.futu.course.minio.service.impl.FileServiceImpl;
 import com.futu.course.user.domain.User;
 import com.futu.course.user.service.UserService;
 import com.futu.course.user.mapper.UserMapper;
-import io.minio.errors.*;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
 
 /**
 * @author yuu
@@ -21,16 +12,9 @@ import java.security.NoSuchAlgorithmException;
 * @createDate 2025-05-05 18:52:53
 */
 @Service
-public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService{
-    @Autowired
-    private FileServiceImpl fileService;
-    public String unload(MultipartFile multipartFile,@RequestParam("uid") Long uid) throws ServerException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
-        User byId = this.getById(uid);
-        String s = fileService.uploadImage(multipartFile);
-        byId.setAvatar(s);
-        boolean b = this.updateById(byId);
-       return b?"修改成功":"修改失败";
-    }
+public class UserServiceImpl extends ServiceImpl<UserMapper, User>
+    implements UserService{
+
 }
 
 

+ 2 - 1
src/main/resources/application.yml

@@ -5,7 +5,8 @@ spring:
     driver-class-name: com.mysql.cj.jdbc.Driver
     url: jdbc:mysql://182.92.251.243:3306/goose?characterEncoding=utf8&serverTimezone=GMT%2B8
     username: root
-    password: 01241314Yxp!
+    password: root
+
   redis:
     host: localhost
     database: 0

+ 0 - 30
src/main/resources/mapper/UserMapper.xml

@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.futu.course.user.mapper.UserMapper">
-
-    <resultMap id="BaseResultMap" type="com.futu.course.user.domain.User">
-            <id property="id" column="id" jdbcType="BIGINT"/>
-            <result property="openId" column="open_id" jdbcType="VARCHAR"/>
-            <result property="unionId" column="union_id" jdbcType="VARCHAR"/>
-            <result property="sessionKey" column="session_key" jdbcType="VARCHAR"/>
-            <result property="username" column="username" jdbcType="VARCHAR"/>
-            <result property="password" column="password" jdbcType="VARCHAR"/>
-            <result property="salt" column="salt" jdbcType="VARCHAR"/>
-            <result property="nickname" column="nickname" jdbcType="VARCHAR"/>
-            <result property="avatar" column="avatar" jdbcType="VARCHAR"/>
-            <result property="mobile" column="mobile" jdbcType="VARCHAR"/>
-            <result property="memberLevel" column="member_level" jdbcType="TINYINT"/>
-            <result property="status" column="status" jdbcType="TINYINT"/>
-            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
-    </resultMap>
-
-    <sql id="Base_Column_List">
-        id,open_id,union_id,
-        session_key,username,password,
-        salt,nickname,avatar,
-        mobile,member_level,status,
-        create_time
-    </sql>
-</mapper>