Search in sources :

Example 1 with User

use of com.junliang.spring.pojo.entity.User in project spring-boot by Linda-Tan.

the class HelloWorldApplicationTests method test.

@Test
public void test() throws Exception {
    User user = new User();
    user.setName("admin");
    user.setPassword("password");
    userRepository.save(user);
// userRepository.save(new User());
// userRepository.save(new User());
// userMapper.insert(new com.junliang.spring.pojo.domain.User());
// userMapper.insert(new com.junliang.spring.pojo.domain.User());
}
Also used : User(com.junliang.spring.pojo.entity.User) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with User

use of com.junliang.spring.pojo.entity.User in project spring-boot by Linda-Tan.

the class UserService method login.

@DataSource(name = "readDataSource")
public String login(String username, String password) {
    User user = userRepository.findByName(username);
    if (user == null)
        throw new BaseException(4001, "用户名不存在");
    if (!user.getPassword().equals(password))
        throw new BaseException(4002, "用户密码错误");
    UserInfo userInfo = new UserInfo();
    BeanCopierUtils.copyProperties(user, userInfo);
    return generateToken(userInfo);
}
Also used : BaseException(com.junliang.spring.exception.BaseException) User(com.junliang.spring.pojo.entity.User) UserInfo(com.junliang.spring.pojo.bean.UserInfo) DataSource(com.junliang.spring.aop.DataSource)

Example 3 with User

use of com.junliang.spring.pojo.entity.User in project spring-boot by Linda-Tan.

the class UserService method test1.

@DataSource
public void test1() {
    User user = new User();
    user.setName("userRepository");
    user.setPassword("userRepository");
    userRepository.save(user);
}
Also used : User(com.junliang.spring.pojo.entity.User) DataSource(com.junliang.spring.aop.DataSource)

Aggregations

User (com.junliang.spring.pojo.entity.User)3 DataSource (com.junliang.spring.aop.DataSource)2 BaseException (com.junliang.spring.exception.BaseException)1 UserInfo (com.junliang.spring.pojo.bean.UserInfo)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1