parent
3458900394
commit
4a88ff003b
@ -0,0 +1,27 @@
|
|||||||
|
package com.example.yuanzhoutest.controller;
|
||||||
|
|
||||||
|
import com.example.yuanzhoutest.entity.UserEntity;
|
||||||
|
import com.example.yuanzhoutest.service.UserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/wuyuan/user")
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@PostMapping(value = "/login/password")
|
||||||
|
public UserEntity passLogin(@RequestBody() UserEntity dto){
|
||||||
|
UserEntity vo = userService.selectOneByPhone(dto.getPhone());
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.example.yuanzhoutest.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.example.yuanzhoutest.entity.UserEntity;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UserMapper extends BaseMapper<UserEntity> {
|
||||||
|
UserEntity selectOneByPhone(@Param("phone") String phone);
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package com.example.yuanzhoutest.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.Version;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("admin_user")
|
||||||
|
public class UserEntity {
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private Date registerTime;
|
||||||
|
|
||||||
|
private Boolean isCancellation;
|
||||||
|
|
||||||
|
@Version
|
||||||
|
private Long version;
|
||||||
|
|
||||||
|
public UserEntity(Long id, String userName, String phone) {
|
||||||
|
this.id = id;
|
||||||
|
this.userName = userName;
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "UserEntity{" +
|
||||||
|
"id=" + id +
|
||||||
|
", userName='" + userName + '\'' +
|
||||||
|
", phone='" + phone + '\'' +
|
||||||
|
", password='" + password + '\'' +
|
||||||
|
", registerTime=" + registerTime +
|
||||||
|
", isCancellation=" + isCancellation +
|
||||||
|
", version=" + version +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.example.yuanzhoutest.dao.UserMapper">
|
||||||
|
<select id="selectOneByPhone" resultType="com.example.yuanzhoutest.entity.UserEntity" parameterType="java.lang.String">
|
||||||
|
select *
|
||||||
|
from admin_user
|
||||||
|
where phone = #{phone}
|
||||||
|
and is_cancellation = 0;
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.example.yuanzhoutest.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.example.yuanzhoutest.entity.UserEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
UserEntity selectOneByPhone(String phone);
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.example.yuanzhoutest.service.impl;
|
||||||
|
|
||||||
|
import com.example.yuanzhoutest.dao.UserMapper;
|
||||||
|
import com.example.yuanzhoutest.entity.UserEntity;
|
||||||
|
import com.example.yuanzhoutest.service.UserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserServiceImpl implements UserService {
|
||||||
|
@Autowired
|
||||||
|
private UserMapper userMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public UserEntity selectOneByPhone(String phone) {
|
||||||
|
return userMapper.selectOneByPhone(phone);
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,19 @@
|
|||||||
package com.example.yuanzhoutest;
|
package com.example.yuanzhoutest;
|
||||||
|
|
||||||
|
import com.example.yuanzhoutest.entity.UserEntity;
|
||||||
|
import com.example.yuanzhoutest.service.UserService;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class YuanzhoutestApplicationTests {
|
class YuanzhoutestApplicationTests {
|
||||||
|
@Autowired // 注入个人仓库
|
||||||
|
private UserService userService;
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
public void testAddPerson() {
|
||||||
}
|
UserEntity user = userService.selectOneByPhone(String.valueOf(111));
|
||||||
|
|
||||||
|
System.out.println(user.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue