在在次修改
parent
55ee788649
commit
989f61ffdd
|
@ -0,0 +1,14 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AliAccessStaticViaInstance" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliArrayNamingShouldHaveBracket" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliControlFlowStatementWithoutBraces" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliDeprecation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliEqualsAvoidNull" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliLongLiteralsEndingWithLowercaseL" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliMissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliWrapperTypeEquality" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="MapOrSetKeyShouldOverrideHashCodeEquals" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-user-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,18 @@
|
|||
package com.bwie.user;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-26 9:08
|
||||
*/
|
||||
@FeignClient("bwie-user")
|
||||
public interface RemoteUserService {
|
||||
@PostMapping("/findName/{username}")
|
||||
public Result<User> findName(@PathVariable("username") String username);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>Java-glob</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-api</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>bwie-user-api</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -28,6 +28,11 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-user-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- SpringBoot Web-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -10,7 +10,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||
* @date 2023-12-19 15:31
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
@EnableFeignClients(
|
||||
basePackages = {"com.bwie"}
|
||||
)
|
||||
public class AuthAppliction {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthAppliction.class,args);
|
||||
|
|
|
@ -1,9 +1,27 @@
|
|||
package com.bwie.controller;
|
||||
|
||||
import com.bwie.common.domain.request.UserRequest;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.service.impl.AuthService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-19 15:30
|
||||
*/
|
||||
@RestController
|
||||
public class AuthController {
|
||||
@Autowired
|
||||
private AuthService authService;
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public Result login(@RequestBody UserRequest userRequest){
|
||||
return authService.login(userRequest);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package com.bwie.feign;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-19 15:30
|
||||
*/
|
||||
public interface AuthFeign {
|
||||
}
|
|
@ -1,9 +1,14 @@
|
|||
package com.bwie.service.impl;
|
||||
|
||||
import com.bwie.common.domain.request.UserRequest;
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-19 15:30
|
||||
*/
|
||||
public interface AuthService {
|
||||
Result login(UserRequest userRequest);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,58 @@
|
|||
package com.bwie.service.impl;
|
||||
|
||||
import com.alibaba.nacos.common.utils.UuidUtils;
|
||||
import com.bwie.common.constants.JwtConstants;
|
||||
import com.bwie.common.constants.TokenConstants;
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.JwtRequest;
|
||||
import com.bwie.common.domain.request.UserRequest;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.common.utils.JwtUtils;
|
||||
import com.bwie.user.RemoteUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.Time;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-19 15:31
|
||||
*/
|
||||
public class AuthServicelmpl {
|
||||
@Service
|
||||
public class AuthServicelmpl implements AuthService{
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public Result login(UserRequest userRequest) {
|
||||
User user = remoteUserService.findName(userRequest.getUsername()).getData();
|
||||
if (null==user){
|
||||
return Result.error("用户名不存在!!!!!!!");
|
||||
}
|
||||
if (!user.getPassword().equals(userRequest.getPassword())){
|
||||
return Result.error("密码错误!!!!!!!");
|
||||
}
|
||||
JwtRequest token = this.getToken(user);
|
||||
return Result.success(token,"登录成功");
|
||||
}
|
||||
/**
|
||||
* 生成token
|
||||
*/
|
||||
private JwtRequest getToken(User user){
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
String userKey = UuidUtils.generateUuid().replaceAll("-", "");
|
||||
map.put(JwtConstants.USER_KEY,userKey);
|
||||
String token = JwtUtils.createToken(map);
|
||||
redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+userKey,token,15, TimeUnit.MINUTES);
|
||||
return new JwtRequest(token);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-26 8:55
|
||||
*/
|
||||
@Data
|
||||
public class Book {
|
||||
|
||||
private Integer bookId;
|
||||
private String bookName;
|
||||
private String bookHoppy;
|
||||
private BigDecimal bookPrice;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date bookDate;
|
||||
private Integer userId;
|
||||
private String username;
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
private List<String> pics;
|
||||
/**
|
||||
* 爱好
|
||||
*/
|
||||
private List<String> hoppys;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-26 8:55
|
||||
*/
|
||||
@Data
|
||||
public class Pic {
|
||||
private Integer picId;
|
||||
private String picImages;
|
||||
private Integer bookId;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-26 8:55
|
||||
*/
|
||||
@Data
|
||||
public class Procut {
|
||||
private Integer procutId;
|
||||
private String procutName;
|
||||
private Integer treeId;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-26 8:55
|
||||
*/
|
||||
@Data
|
||||
public class User {
|
||||
|
||||
private Integer userId;
|
||||
private String username;
|
||||
private String password;
|
||||
private String tel;
|
||||
private Integer role;
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.bwie.common.domain.request;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-26 9:02
|
||||
*/
|
||||
@Data
|
||||
public class BookRequest {
|
||||
/**
|
||||
* 模糊
|
||||
*/
|
||||
private String bookName;
|
||||
/**
|
||||
* 区间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date bookDate;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date bookDates;
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
private Integer pageNum;
|
||||
private Integer pageSize;
|
||||
/**
|
||||
* 精确
|
||||
*/
|
||||
private Integer bookId;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie.common.domain.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-26 9:18
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class JwtRequest {
|
||||
private String token;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.bwie.common.domain.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-26 8:54
|
||||
*/
|
||||
@Data
|
||||
public class UserRequest {
|
||||
private String username;
|
||||
private String password;
|
||||
}
|
|
@ -1,9 +1,24 @@
|
|||
package com.bwie.user.controller;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.user.service.impl.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-19 15:32
|
||||
*/
|
||||
@RestController
|
||||
public class UserController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@PostMapping("/findName/{username}")
|
||||
public Result<User> findName(@PathVariable("username") String username){
|
||||
return userService.findName(username);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
package com.bwie.user.mapper;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-19 15:32
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface UserMapper {
|
||||
User findName(String username);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
package com.bwie.user.service.impl;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-19 15:32
|
||||
*/
|
||||
public interface UserService {
|
||||
Result<User> findName(String username);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
package com.bwie.user.service.impl;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.user.mapper.UserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author gxb
|
||||
* @description TODO
|
||||
* @date 2023-12-19 15:32
|
||||
*/
|
||||
public class UserServicelmpl {
|
||||
@Service
|
||||
public class UserServicelmpl implements UserService{
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
@Override
|
||||
public Result<User> findName(String username) {
|
||||
User user = userMapper.findName(username);
|
||||
return Result.success(user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ spring:
|
|||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-system
|
||||
name: bwie-user
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
|
@ -39,4 +39,4 @@ fdfs:
|
|||
# 生成缩略图
|
||||
thumb-image:
|
||||
height: 500
|
||||
width: 500
|
||||
width: 500
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?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.bwie.user.mapper.UserMapper">
|
||||
|
||||
<select id="findName" resultType="com.bwie.common.domain.User">
|
||||
select *
|
||||
from user
|
||||
where username = #{username};
|
||||
</select>
|
||||
</mapper>
|
6
pom.xml
6
pom.xml
|
@ -13,6 +13,7 @@
|
|||
<module>bwie-gateway</module>
|
||||
<module>bwie-common</module>
|
||||
<module>bwie-modules</module>
|
||||
<module>bwie-api</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
@ -67,6 +68,11 @@
|
|||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue