Quellcode durchsuchen

取消user缓存加载,/all不返回密码和权限值

XMTT vor 8 Jahren
Ursprung
Commit
fa177791b1

+ 10 - 22
src/main/java/com/ekexiu/console/system/service/UserService.java

@ -23,20 +23,16 @@ import org.jfw.util.PageQueryResult;
23 23
import org.jfw.util.StringUtil;
24 24
import org.jfw.util.auth.AuthUtil;
25 25
import org.jfw.util.exception.JfwBaseException;
26
import org.jfw.util.jdbc.JdbcTask;
27
import org.jfw.util.jdbc.JdbcUtil;
28 26
import org.jfw.util.web.fileupload.UploadItemIterator;
29 27

30
import javax.sql.DataSource;
31 28
import java.io.IOException;
32 29
import java.sql.Connection;
33 30
import java.sql.SQLException;
34
import java.util.*;
35
import java.util.concurrent.atomic.AtomicReference;
31
import java.util.ArrayList;
32
import java.util.List;
36 33

37 34
@Path("/sys/user")
38 35
public class UserService extends Upload {
39
	private AtomicReference<Map<String, User>> cache = new AtomicReference<Map<String, User>>();
40 36
	public static final String DEFAULT_AUTH_STR = AuthUtil.serialAuth(new int[]{0});
41 37
	public static final String DEFAULT_PW_STR = StringUtil.md5("12345678");
42 38

@ -147,23 +143,15 @@ public class UserService extends Upload {
147 143

148 144
	@Get
149 145
	@Path("/all")
150
	public Collection<User> queryall(@JdbcConn Connection con) throws SQLException {
151
		return this.cache.get().values();
152
	}
153

154
	public void initByDataSource(DataSource ds) throws SQLException {
155
		final Connection con = ds.getConnection();
156
		JdbcUtil.executeAutoClose(con, new JdbcTask() {
157
			@Override
158
			public void exec() throws SQLException {
159
				List<User> list = userDao.queryall(con);
160
				Map<String, User> map = new HashMap<String, User>();
161
				for (User res : list) {
162
					map.put(res.getId(), res);
163
				}
164
				cache.set(map);
146
	public List<User> queryall(@JdbcConn Connection con) throws SQLException {
147
		List<User> users = this.userDao.queryall(con);
148
		for (User user : users) {
149
			if (user != null) {
150
				user.setLoginPassword(null);
151
				user.setAuthinfo(null);
165 152
			}
166
		}, false);
153
		}
154
		return users;
167 155
	}
168 156

169 157
	@Put

+ 0 - 6
src/main/java/com/ekexiu/console/util/GlobalInitBean.java

@ -83,12 +83,6 @@ public class GlobalInitBean implements AfterBeanFactory {
83 83
				getBean(SysResourceService.class).initByDataSource(dataSource);
84 84
			}
85 85
		});
86
		list.add(new Initable() {
87
			@Override
88
			public void init(GlobalInitBean gib) throws Exception {
89
				getBean(UserService.class).initByDataSource(dataSource);
90
			}
91
		});
92 86
		return list;
93 87
	}
94 88
	public <T> T getBean(Class<T> cls){