Sfoglia il codice sorgente

初始化固定角色

tags/24080901
WendyYang 1 anno fa
parent
commit
55a61d2fa2
1 ha cambiato i file con 26 aggiunte e 0 eliminazioni
  1. +26
    -0
      pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java

+ 26
- 0
pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java Vedi File

@@ -8,12 +8,17 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.sys.model.entity.Menu;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.sys.model.entity.RoleMenu;
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

/**
* <p>
@@ -27,6 +32,27 @@ class IMenuServiceTest extends AppTests {

@Autowired
private IMenuService menuService;
@Autowired
private IRoleService roleService;

/**
* 初始化固定角色
*/
@Test
public void roleService() {
roleService.remove(null);
AtomicLong integer = new AtomicLong(0);
Arrays.stream(RoleEnum.values()).map(w -> {
Role role = new Role();
role.setId(integer.incrementAndGet());
role.setCode(w.name());
role.setName(w.getDesc());
role.setDescribe(w.getDesc());
role.setFixed(true);
role.setCreateOn(LocalDateTime.now());
return role;
}).forEach(roleService::save);
}

@Test
public void test() throws SQLException {


Loading…
Annulla
Salva