master
parent
fc7c87d8f4
commit
c2339d1c83
|
@ -51,6 +51,12 @@ public class AuthController {
|
|||
return Result.success(user);
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
public Result logout(){
|
||||
Result result=Result.success();
|
||||
authService.logout();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -12,4 +12,6 @@ public interface AuthService {
|
|||
|
||||
User info();
|
||||
|
||||
void logout();
|
||||
|
||||
}
|
||||
|
|
|
@ -98,6 +98,13 @@ public class AuthServiceimpl implements AuthService{
|
|||
return JSONObject.parseObject(jsonKetStr,User.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout() {
|
||||
String token = request.getHeader(TokenConstants.TOKEN);
|
||||
String userKey = JwtUtils.getUserKey(token);
|
||||
redisTemplate.delete(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||
}
|
||||
|
||||
public Boolean vailPhone(String phone){
|
||||
Pattern compile = Pattern.compile("^\\d{11}$");
|
||||
return compile.matcher(phone).matches();
|
||||
|
|
Binary file not shown.
|
@ -2,17 +2,20 @@ package com.bwie.common.domain;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class User {
|
||||
private Integer userID;
|
||||
private Integer userId;
|
||||
private String userName;
|
||||
private String userPW;
|
||||
private Integer userType;
|
||||
private String userIDCard;
|
||||
private String userIdCard;
|
||||
private Integer userAge;
|
||||
private String userGender;
|
||||
private String userAddress;
|
||||
private String userPosition;
|
||||
private Integer userSal;
|
||||
private String Phone;
|
||||
private Date userDate;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.bwie.common.domain.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserRequest {
|
||||
private Integer userId;
|
||||
private Integer pageNum=1;
|
||||
private Integer pageSize=3;
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -12,6 +12,7 @@ com\bwie\common\domain\request\MerchRequest.class
|
|||
com\bwie\common\constants\TokenConstants.class
|
||||
com\bwie\common\utils\OssUtil.class
|
||||
com\bwie\common\result\Result.class
|
||||
com\bwie\common\domain\request\UserRequest.class
|
||||
com\bwie\common\config\RedisConfig.class
|
||||
com\bwie\common\utils\FastUtil.class
|
||||
com\bwie\common\constants\RabbitName.class
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
D:\zhuangao5\safeway\bwie-common\src\main\java\com\bwie\common\utils\OssUtil.java
|
||||
D:\zhuangao5\safeway\bwie-common\src\main\java\com\bwie\common\domain\request\UserRequest.java
|
||||
D:\zhuangao5\safeway\bwie-common\src\main\java\com\bwie\common\result\Result.java
|
||||
D:\zhuangao5\safeway\bwie-common\src\main\java\com\bwie\common\utils\JwtUtils.java
|
||||
D:\zhuangao5\safeway\bwie-common\src\main\java\com\bwie\common\config\RedisConfig.java
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,13 +2,13 @@ package com.bwie.user.controller;
|
|||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserRequest;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.user.service.UserService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
@ -29,4 +29,14 @@ public class UserController {
|
|||
request.getMethod(), JSONObject.toJSONString(user));
|
||||
return Result.success(user);
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Result<PageResult<User>> list(@RequestBody UserRequest userRequest){
|
||||
log.info("执行操作:查询员工列表,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(userRequest));
|
||||
Result<PageResult<User>> result=userService.list(userRequest);
|
||||
log.info("执行操作:查询员工列表,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
package com.bwie.user.mapper;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface UserMapper {
|
||||
User findByPhone(String phone);
|
||||
|
||||
List<User> list(UserRequest userRequest);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package com.bwie.user.service;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserRequest;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
public interface UserService {
|
||||
User findByPhone(String phone);
|
||||
|
||||
Result<PageResult<User>> list(UserRequest userRequest);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
package com.bwie.user.service;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserRequest;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.user.mapper.UserMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserServiceimpl implements UserService{
|
||||
@Autowired
|
||||
|
@ -13,4 +20,12 @@ public class UserServiceimpl implements UserService{
|
|||
public User findByPhone(String phone) {
|
||||
return userMapper.findByPhone(phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<PageResult<User>> list(UserRequest userRequest) {
|
||||
PageHelper.startPage(userRequest.getPageNum(),userRequest.getPageSize());
|
||||
List<User> list=userMapper.list(userRequest);
|
||||
PageInfo<User> info = new PageInfo<>();
|
||||
return PageResult.toResult(info.getTotal(),list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ spring:
|
|||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
date-format: yyyy-MM-dd
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
|
|
|
@ -8,4 +8,12 @@
|
|||
<select id="findByPhone" resultType="com.bwie.common.domain.User">
|
||||
select * from t_user where phone=#{phone}
|
||||
</select>
|
||||
<select id="list" resultType="com.bwie.common.domain.User">
|
||||
select * from t_user
|
||||
<where>
|
||||
<if test="userId!=null and userId!=''">
|
||||
and user_id=#{userId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Binary file not shown.
|
@ -6,7 +6,7 @@ spring:
|
|||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
date-format: yyyy-MM-dd
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -8,4 +8,12 @@
|
|||
<select id="findByPhone" resultType="com.bwie.common.domain.User">
|
||||
select * from t_user where phone=#{phone}
|
||||
</select>
|
||||
<select id="list" resultType="com.bwie.common.domain.User">
|
||||
select * from t_user
|
||||
<where>
|
||||
<if test="userId!=null and userId!=''">
|
||||
and user_id=#{userId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue