添加角色相关的接口,用户信息添加角色信息
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.service.IRoleService;
|
||||
import com.genersoft.iot.vmp.service.IUserService;
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.Role;
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.User;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
class RoleServiceImplTest {
|
||||
|
||||
@Resource
|
||||
private IRoleService roleService;
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
@org.junit.jupiter.api.Test
|
||||
void getAllUser() {
|
||||
List<Role> all = roleService.getAll();
|
||||
Role roleById = roleService.getRoleById(1);
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void add() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Role role = new Role();
|
||||
role.setName("test+" + i);
|
||||
role.setAuthority("adadadda");
|
||||
role.setCreateTime(format.format(System.currentTimeMillis()));
|
||||
role.setUpdateTime(format.format(System.currentTimeMillis()));
|
||||
roleService.add(role);
|
||||
}
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void delete() {
|
||||
roleService.delete(20);
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void update() {
|
||||
Role role = new Role();
|
||||
role.setId(21);
|
||||
role.setName("TTTTTT");
|
||||
role.setAuthority("adadadda");
|
||||
roleService.update(role);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.service.impl;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||
import com.genersoft.iot.vmp.service.IDeviceAlarmService;
|
||||
import com.genersoft.iot.vmp.service.IUserService;
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.Role;
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.User;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -11,6 +12,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@SpringBootTest
|
||||
@@ -24,7 +26,11 @@ class UserServiceImplTest {
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void getAllUser() {
|
||||
List<User> allUsers = userService.getAllUsers();
|
||||
System.out.println(userService.getAllUsers().size());
|
||||
User admin = userService.getUser("admin", "21232f297a57a5a743894a0e4a801fc3");
|
||||
User admin1 = userService.getUserByUsername("admin");
|
||||
System.out.println(12);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +40,10 @@ class UserServiceImplTest {
|
||||
User user = new User();
|
||||
user.setUsername("admin_" + i);
|
||||
user.setPassword("admin_password_" + i);
|
||||
user.setRoleId((int)(Math.random()*4 + 1));
|
||||
|
||||
Role role = new Role();
|
||||
role.setId(1);
|
||||
user.setRole(role);
|
||||
user.setCreateTime(format.format(System.currentTimeMillis()));
|
||||
user.setUpdateTime(format.format(System.currentTimeMillis()));
|
||||
userService.addUser(user);
|
||||
@@ -49,10 +58,12 @@ class UserServiceImplTest {
|
||||
@org.junit.jupiter.api.Test
|
||||
void update() {
|
||||
User user = new User();
|
||||
user.setId(1003);
|
||||
user.setId(11);
|
||||
user.setUsername("update" );
|
||||
user.setPassword("update");
|
||||
user.setRoleId((int)(Math.random()*4 + 1));
|
||||
Role role = new Role();
|
||||
role.setId(2);
|
||||
user.setRole(role);
|
||||
user.setUpdateTime(format.format(System.currentTimeMillis()));
|
||||
userService.updateUsers(user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user