master
parent
c2339d1c83
commit
0bca89a4f8
|
@ -1,5 +1,6 @@
|
|||
package com.bwie.auth.service;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
|
||||
import com.bwie.auth.feign.UserFeignService;
|
||||
|
@ -47,6 +48,11 @@ public class AuthServiceimpl implements AuthService{
|
|||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString().replaceAll("-",""));
|
||||
return message;
|
||||
});
|
||||
|
||||
// String code = RandomUtil.randomNumbers(4);
|
||||
// HashMap<String, Object> map = new HashMap<>();
|
||||
// map.put("code",code);
|
||||
// redisTemplate.opsForValue().set(phone,code,5, TimeUnit.MINUTES);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
@ -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.
|
@ -8,9 +8,9 @@ import java.util.Date;
|
|||
public class User {
|
||||
private Integer userId;
|
||||
private String userName;
|
||||
private String userPW;
|
||||
private String userPwd;
|
||||
private Integer userType;
|
||||
private String userIdCard;
|
||||
private String userIdcard;
|
||||
private Integer userAge;
|
||||
private String userGender;
|
||||
private String userAddress;
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -6,6 +6,7 @@ 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 io.swagger.models.auth.In;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -39,4 +40,58 @@ public class UserController {
|
|||
request.getMethod(),JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/list2")
|
||||
public Result<PageResult<User>> list2(@RequestBody UserRequest userRequest){
|
||||
log.info("执行操作:查询员工列表,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(userRequest));
|
||||
Result<PageResult<User>> result=userService.list2(userRequest);
|
||||
log.info("执行操作:查询员工列表,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody User user){
|
||||
log.info("执行操作:添加,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(user));
|
||||
Result result=Result.success();
|
||||
userService.add(user);
|
||||
log.info("执行操作:添加,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Result update(@RequestBody User user){
|
||||
log.info("执行操作:修改,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(user));
|
||||
Result result=Result.success();
|
||||
userService.update(user);
|
||||
log.info("执行操作:修改,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/findById/{userId}")
|
||||
public Result<User> findById(@PathVariable Integer userId){
|
||||
log.info("执行操作:回显,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(userId));
|
||||
User user=userService.findById(userId);
|
||||
log.info("执行操作:回显,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(userId));
|
||||
return Result.success(user);
|
||||
}
|
||||
|
||||
@DeleteMapping("deleteId/{userId}")
|
||||
public Result deleteId(@PathVariable Integer userId){
|
||||
log.info("执行操作:删除,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(userId));
|
||||
Result result=Result.success();
|
||||
userService.deleteId(userId);
|
||||
log.info("执行操作:删除,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(),
|
||||
request.getMethod(),JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,14 @@ public interface UserMapper {
|
|||
User findByPhone(String phone);
|
||||
|
||||
List<User> list(UserRequest userRequest);
|
||||
|
||||
void add(User user);
|
||||
|
||||
void update(User user);
|
||||
|
||||
User findById(Integer userId);
|
||||
|
||||
void deleteId(Integer userId);
|
||||
|
||||
List<User> list2(UserRequest userRequest);
|
||||
}
|
||||
|
|
|
@ -9,4 +9,14 @@ public interface UserService {
|
|||
User findByPhone(String phone);
|
||||
|
||||
Result<PageResult<User>> list(UserRequest userRequest);
|
||||
|
||||
void add(User user);
|
||||
|
||||
void update(User user);
|
||||
|
||||
User findById(Integer userId);
|
||||
|
||||
void deleteId(Integer userId);
|
||||
|
||||
Result<PageResult<User>> list2(UserRequest userRequest);
|
||||
}
|
||||
|
|
|
@ -1,21 +1,30 @@
|
|||
package com.bwie.user.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.common.constants.TokenConstants;
|
||||
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.common.utils.JwtUtils;
|
||||
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.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserServiceimpl implements UserService{
|
||||
@Autowired
|
||||
UserMapper userMapper;
|
||||
@Autowired
|
||||
HttpServletRequest request;
|
||||
@Autowired
|
||||
RedisTemplate<String,String> redisTemplate;
|
||||
@Override
|
||||
public User findByPhone(String phone) {
|
||||
return userMapper.findByPhone(phone);
|
||||
|
@ -28,4 +37,40 @@ public class UserServiceimpl implements UserService{
|
|||
PageInfo<User> info = new PageInfo<>();
|
||||
return PageResult.toResult(info.getTotal(),list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(User user) {
|
||||
userMapper.add(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(User user) {
|
||||
userMapper.update(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User findById(Integer userId) {
|
||||
return userMapper.findById(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteId(Integer userId) {
|
||||
userMapper.deleteId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<PageResult<User>> list2(UserRequest userRequest) {
|
||||
PageHelper.startPage(userRequest.getPageNum(),userRequest.getPageSize());
|
||||
List<User> list2=userMapper.list2(userRequest);
|
||||
PageInfo<User> info = new PageInfo<>();
|
||||
return PageResult.toResult(info.getTotal(),list2);
|
||||
}
|
||||
|
||||
|
||||
public User info() {
|
||||
String token = request.getHeader(TokenConstants.TOKEN);
|
||||
String userKey = JwtUtils.getUserKey(token);
|
||||
String jsonKetStr = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||
return JSONObject.parseObject(jsonKetStr,User.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,51 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bwie.user.mapper.UserMapper">
|
||||
<insert id="add">
|
||||
insert into t_user(
|
||||
user_name,
|
||||
user_pwd,
|
||||
user_type,
|
||||
user_idcard,
|
||||
user_age,
|
||||
user_gender,
|
||||
user_address,
|
||||
user_position,
|
||||
user_sal,
|
||||
phone,
|
||||
user_date
|
||||
) values (
|
||||
#{userName},
|
||||
#{userPwd},
|
||||
#{userType},
|
||||
#{userIdcard},
|
||||
#{userAge},
|
||||
#{userGender},
|
||||
#{userAddress},
|
||||
#{userPosition},
|
||||
#{userSal},
|
||||
#{phone},
|
||||
#{userDate}
|
||||
)
|
||||
</insert>
|
||||
<update id="update">
|
||||
update t_user set
|
||||
user_name=#{userName},
|
||||
user_pwd=#{userPwd},
|
||||
user_type=#{userType},
|
||||
user_idcard=#{userIdcard},
|
||||
user_age=#{userAge},
|
||||
user_gender=#{userGender},
|
||||
user_address=#{userAddress},
|
||||
user_position=#{userPosition},
|
||||
user_sal=#{userSal},
|
||||
phone=#{phone},
|
||||
user_date=#{userDate}
|
||||
where user_id=#{userId}
|
||||
</update>
|
||||
<delete id="deleteId">
|
||||
delete from t_user where user_id=#{userId}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="findByPhone" resultType="com.bwie.common.domain.User">
|
||||
|
@ -14,6 +59,20 @@
|
|||
<if test="userId!=null and userId!=''">
|
||||
and user_id=#{userId}
|
||||
</if>
|
||||
and (user_type=1 or user_type=2)
|
||||
</where>
|
||||
|
||||
</select>
|
||||
<select id="findById" resultType="com.bwie.common.domain.User">
|
||||
select * from t_user where user_id=#{userId}
|
||||
</select>
|
||||
<select id="list2" resultType="com.bwie.common.domain.User">
|
||||
select * from t_user
|
||||
<where>
|
||||
<if test="userId!=null and userId!=''">
|
||||
and user_id=#{userId}
|
||||
</if>
|
||||
and (user_type=3 or user_type=4)
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -3,6 +3,51 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bwie.user.mapper.UserMapper">
|
||||
<insert id="add">
|
||||
insert into t_user(
|
||||
user_name,
|
||||
user_pwd,
|
||||
user_type,
|
||||
user_idcard,
|
||||
user_age,
|
||||
user_gender,
|
||||
user_address,
|
||||
user_position,
|
||||
user_sal,
|
||||
phone,
|
||||
user_date
|
||||
) values (
|
||||
#{userName},
|
||||
#{userPwd},
|
||||
#{userType},
|
||||
#{userIdcard},
|
||||
#{userAge},
|
||||
#{userGender},
|
||||
#{userAddress},
|
||||
#{userPosition},
|
||||
#{userSal},
|
||||
#{phone},
|
||||
#{userDate}
|
||||
)
|
||||
</insert>
|
||||
<update id="update">
|
||||
update t_user set
|
||||
user_name=#{userName},
|
||||
user_pwd=#{userPwd},
|
||||
user_type=#{userType},
|
||||
user_idcard=#{userIdcard},
|
||||
user_age=#{userAge},
|
||||
user_gender=#{userGender},
|
||||
user_address=#{userAddress},
|
||||
user_position=#{userPosition},
|
||||
user_sal=#{userSal},
|
||||
phone=#{phone},
|
||||
user_date=#{userDate}
|
||||
where user_id=#{userId}
|
||||
</update>
|
||||
<delete id="deleteId">
|
||||
delete from t_user where user_id=#{userId}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="findByPhone" resultType="com.bwie.common.domain.User">
|
||||
|
@ -14,6 +59,20 @@
|
|||
<if test="userId!=null and userId!=''">
|
||||
and user_id=#{userId}
|
||||
</if>
|
||||
and (user_type=1 or user_type=2)
|
||||
</where>
|
||||
|
||||
</select>
|
||||
<select id="findById" resultType="com.bwie.common.domain.User">
|
||||
select * from t_user where user_id=#{userId}
|
||||
</select>
|
||||
<select id="list2" resultType="com.bwie.common.domain.User">
|
||||
select * from t_user
|
||||
<where>
|
||||
<if test="userId!=null and userId!=''">
|
||||
and user_id=#{userId}
|
||||
</if>
|
||||
and (user_type=3 or user_type=4)
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue