mirror of
https://github.com/getrebuild/rebuild.git
synced 2024-09-20 15:35:55 +08:00
Fixs for review
This commit is contained in:
parent
36b2ae52e8
commit
78858c7fc9
|
@ -75,13 +75,6 @@ public final class ServerStatus {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static boolean isDatabaseOK() {
|
||||
return checkDatabase().success;
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统状态检查
|
||||
|
@ -102,6 +95,12 @@ public final class ServerStatus {
|
|||
return isStatusOK();
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName(com.mysql.jdbc.Driver.class.getName());
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 数据库连接
|
||||
*
|
||||
|
@ -110,19 +109,11 @@ public final class ServerStatus {
|
|||
protected static Status checkDatabase() {
|
||||
String name = "Database";
|
||||
try {
|
||||
Class.forName(com.mysql.jdbc.Driver.class.getName());
|
||||
Connection c = DriverManager.getConnection(
|
||||
Application.getBean(AesPreferencesConfigurer.class).getItem("db.url"),
|
||||
Application.getBean(AesPreferencesConfigurer.class).getItem("db.user"),
|
||||
Application.getBean(AesPreferencesConfigurer.class).getItem("db.passwd"));
|
||||
SqlHelper.close(c);
|
||||
|
||||
// DataSource ds = Application.getPersistManagerFactory().getDataSource();
|
||||
// Connection c = DataSourceUtils.getConnection(ds);
|
||||
// DatabaseMetaData dmd = c.getMetaData();
|
||||
// String dbName = dmd.getDatabaseProductName() + dmd.getDatabaseProductVersion();
|
||||
// name += "/" + dbName;
|
||||
// DataSourceUtils.releaseConnection(c, ds);
|
||||
} catch (Exception ex) {
|
||||
return Status.error(name, ThrowableUtils.getRootCause(ex).getLocalizedMessage());
|
||||
}
|
||||
|
|
|
@ -48,12 +48,12 @@ public class UserAvatar extends BaseControll {
|
|||
|
||||
@RequestMapping("/user-avatar")
|
||||
public void renderAvatat(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
renderAvatat(getRequestUser(request), response);
|
||||
renderUserAvatat(getRequestUser(request), response);
|
||||
}
|
||||
|
||||
@RequestMapping("/user-avatar/{user}")
|
||||
public void renderAvatat(@PathVariable String user, HttpServletResponse response) throws IOException {
|
||||
renderAvatat(user, response);
|
||||
renderUserAvatat(user, response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,10 +61,12 @@ public class UserAvatar extends BaseControll {
|
|||
* @param response
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void renderAvatat(Object user, HttpServletResponse response) throws IOException {
|
||||
protected void renderUserAvatat(Object user, HttpServletResponse response) throws IOException {
|
||||
User realUser = null;
|
||||
if (user instanceof ID) {
|
||||
realUser = Application.getUserStore().getUser((ID) user);
|
||||
} if (ID.isId(user)) {
|
||||
realUser = Application.getUserStore().getUser(ID.valueOf(user.toString()));
|
||||
} else if (Application.getUserStore().existsName((String) user)) {
|
||||
realUser = Application.getUserStore().getUserByName((String) user);
|
||||
} else if (Application.getUserStore().existsEmail((String) user)) {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<div class="card" data-id="${item[0]}" data-disabled="${item[2]}">
|
||||
<div class="card-body">
|
||||
<a href="classification/${item[0]}">${item[1]}</a>
|
||||
<p class="text-muted m-0 fs-12"><span>${item[3]}</span>级 · ${item[4]} 项数据</p>
|
||||
<p class="text-muted m-0 fs-12">${item[3]}级 · ${item[4]} 项数据</p>
|
||||
</div>
|
||||
<div class="card-footer card-footer-contrast text-muted">
|
||||
<div class="float-left">
|
||||
|
|
|
@ -19,11 +19,7 @@ $(document).ready(function () {
|
|||
label = $val('#entityLabel'),
|
||||
comments = $val('#comments'),
|
||||
nameField = $val('#nameField')
|
||||
let _data = {
|
||||
entityLabel: label,
|
||||
comments: comments,
|
||||
nameField: nameField
|
||||
}
|
||||
let _data = { entityLabel: label, comments: comments, nameField: nameField }
|
||||
if (icon) _data.icon = icon
|
||||
_data = $cleanMap(_data)
|
||||
if (Object.keys(_data) === 0) {
|
||||
|
@ -31,10 +27,7 @@ $(document).ready(function () {
|
|||
return
|
||||
}
|
||||
|
||||
_data.metadata = {
|
||||
entity: 'MetaEntity',
|
||||
id: wpc.metaId
|
||||
}
|
||||
_data.metadata = { entity: 'MetaEntity', id: wpc.metaId }
|
||||
_btn.button('loading')
|
||||
$.post('../entity-update', JSON.stringify(_data), function (res) {
|
||||
if (res.error_code === 0) location.reload()
|
||||
|
@ -60,12 +53,8 @@ $(document).ready(function () {
|
|||
}
|
||||
})
|
||||
let rsSort = []
|
||||
rs.forEach((item) => {
|
||||
if (item.disabled === false) rsSort.push(item)
|
||||
})
|
||||
rs.forEach((item) => {
|
||||
if (item.disabled === true) rsSort.push(item)
|
||||
})
|
||||
rs.forEach((item) => { if (item.disabled === false) rsSort.push(item) })
|
||||
rs.forEach((item) => { if (item.disabled === true) rsSort.push(item) })
|
||||
rs = rsSort
|
||||
|
||||
$('#nameField').select2({
|
||||
|
|
|
@ -47,11 +47,11 @@ public class TestSupport {
|
|||
protected static final String TEST_ENTITY = "TestAllFields";
|
||||
|
||||
// 示例用户
|
||||
protected static final ID EXAMPLE_USER = ID.valueOf("001-9000000000000001");
|
||||
protected static final ID SIMPLE_USER = ID.valueOf("001-9000000000000001");
|
||||
// 示例部门
|
||||
protected static final ID EXAMPLE_DEPT = ID.valueOf("002-9000000000000001");
|
||||
protected static final ID SIMPLE_DEPT = ID.valueOf("002-9000000000000001");
|
||||
// 示例角色(无任何权限)
|
||||
protected static final ID EXAMPLE_ROLE = ID.valueOf("003-9000000000000001");
|
||||
protected static final ID SIMPLE_ROLE = ID.valueOf("003-9000000000000001");
|
||||
|
||||
@BeforeClass
|
||||
public static void startup() throws Exception {
|
||||
|
|
|
@ -36,16 +36,16 @@ public class SecurityManagerTest extends TestSupport {
|
|||
public void testEntityPrivileges() throws Exception {
|
||||
int entity = MetadataHelper.getEntity(TEST_ENTITY).getEntityCode();
|
||||
|
||||
Application.getSecurityManager().allowed(EXAMPLE_USER, entity, BizzPermission.CREATE);
|
||||
Application.getSecurityManager().allowed(EXAMPLE_USER, entity, BizzPermission.DELETE);
|
||||
Application.getSecurityManager().allowed(EXAMPLE_USER, entity, BizzPermission.UPDATE);
|
||||
Application.getSecurityManager().allowed(EXAMPLE_USER, entity, BizzPermission.READ);
|
||||
Application.getSecurityManager().allowed(EXAMPLE_USER, entity, BizzPermission.ASSIGN);
|
||||
Application.getSecurityManager().allowed(EXAMPLE_USER, entity, BizzPermission.SHARE);
|
||||
Application.getSecurityManager().allowed(SIMPLE_USER, entity, BizzPermission.CREATE);
|
||||
Application.getSecurityManager().allowed(SIMPLE_USER, entity, BizzPermission.DELETE);
|
||||
Application.getSecurityManager().allowed(SIMPLE_USER, entity, BizzPermission.UPDATE);
|
||||
Application.getSecurityManager().allowed(SIMPLE_USER, entity, BizzPermission.READ);
|
||||
Application.getSecurityManager().allowed(SIMPLE_USER, entity, BizzPermission.ASSIGN);
|
||||
Application.getSecurityManager().allowed(SIMPLE_USER, entity, BizzPermission.SHARE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZero() throws Exception {
|
||||
Application.getSecurityManager().allowed(EXAMPLE_USER, ZeroEntry.AllowLogin);
|
||||
Application.getSecurityManager().allowed(SIMPLE_USER, ZeroEntry.AllowLogin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class QueryFactoryTest extends TestSupport {
|
|||
sql.append(" from ").append(allDT.getName());
|
||||
System.out.println("Query : " + sql);
|
||||
|
||||
Filter filter = Application.getSecurityManager().createQueryFilter(EXAMPLE_USER);
|
||||
Filter filter = Application.getSecurityManager().createQueryFilter(SIMPLE_USER);
|
||||
Application.getQueryFactory().createQuery(sql.toString(), filter).array();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
rebuild - Building your business-systems freely.
|
||||
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rebuild.web.user.account;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import com.rebuild.server.service.bizz.UserService;
|
||||
import com.rebuild.web.MvcTestSupport;
|
||||
|
||||
/**
|
||||
* @author devezhao zhaofang123@gmail.com
|
||||
* @since 2019/05/10
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class UserAvatarTest extends MvcTestSupport {
|
||||
|
||||
@Test
|
||||
public void testGetAvatar() throws Exception {
|
||||
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
|
||||
.post("/account/user-avatar/" + UserService.ADMIN_USER);
|
||||
System.out.println(perform(builder, SIMPLE_USER, true));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue