XMTT 6 years ago
parent
commit
aa3f535858

+ 14 - 0
src/main/java/com/ekexiu/project/storage/base/po/CreateTimeSupported.java

@ -0,0 +1,14 @@
1
package com.ekexiu.project.storage.base.po;
2
3
import org.jfw.apt.annotation.JfwAptConfig;
4
import org.jfw.apt.orm.annotation.entry.Column;
5
import org.jfw.apt.orm.annotation.entry.VirtualTable;
6
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
7
8
@JfwAptConfig("DB:PostgreSQL")
9
@VirtualTable
10
public interface CreateTimeSupported {
11
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = false)
12
	String getCreateTime();
13
	void setCreateTime(String createTime);
14
}

+ 35 - 0
src/main/java/com/ekexiu/project/storage/resource/dao/StorageDao.java

@ -0,0 +1,35 @@
1
package com.ekexiu.project.storage.resource.dao;
2
3
import com.ekexiu.project.storage.resource.po.Storage;
4
import org.jfw.apt.annotation.Nullable;
5
import org.jfw.apt.orm.annotation.dao.DAO;
6
import org.jfw.apt.orm.annotation.dao.method.From;
7
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
8
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
9
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
10
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
11
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
12
import org.jfw.util.PageQueryResult;
13
14
import java.sql.Connection;
15
import java.sql.SQLException;
16
17
/**
18
 * Created by TT on 2018/9/11.
19
 */
20
@DAO
21
public interface StorageDao {
22
23
    @Insert
24
    int insert(Connection con, Storage storage) throws SQLException;
25
26
    @UpdateWith
27
    @From(Storage.class)
28
    @SetSentence("active = '0'")
29
    int logicDelete(Connection con, String id) throws SQLException;
30
31
    @PageSelect
32
    @OrderBy("ORDER BY CREATE_TIME")
33
     PageQueryResult<Storage> pageQuery(Connection con, @Nullable Boolean active, int pageSize, int pageNo) throws SQLException;
34
35
}

+ 129 - 0
src/main/java/com/ekexiu/project/storage/resource/po/Storage.java

@ -0,0 +1,129 @@
1
package com.ekexiu.project.storage.resource.po;
2
3
import com.ekexiu.project.storage.base.po.CreateTimeSupported;
4
import org.jfw.apt.orm.annotation.entry.Column;
5
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
6
import org.jfw.apt.orm.annotation.entry.Table;
7
import org.jfw.apt.orm.core.enums.DE;
8
9
/**
10
 * Created by TT on 2018/9/11.
11
 */
12
@Table(descp = "医疗影像表")
13
@PrimaryKey("id")
14
public class Storage implements CreateTimeSupported {
15
16
    private String id;
17
    private String name;
18
    private String type;
19
    private long size;
20
    private String hospital;
21
    private String department;
22
    private String owner;
23
    private String createTime;
24
    private String url;
25
    private String fileName;
26
27
    private boolean active;
28
29
    @Column(descp = "文件ID", value = DE.id_32)
30
    public String getId() {
31
        return id;
32
    }
33
34
    public void setId(String id) {
35
        this.id = id;
36
    }
37
38
    @Column(descp = "文件名称", value = DE.text_de)
39
    public String getName() {
40
        return name;
41
    }
42
43
    public void setName(String name) {
44
        this.name = name;
45
    }
46
47
    @Column(descp = "文件类型", value = DE.text_de)
48
    public String getType() {
49
        return type;
50
    }
51
52
    public void setType(String type) {
53
        this.type = type;
54
    }
55
56
    @Column(descp = "文件大小", value = DE.long_de)
57
    public long getSize() {
58
        return size;
59
    }
60
61
    public void setSize(long size) {
62
        this.size = size;
63
    }
64
65
    @Column(descp = "所属医院", value = DE.text_de)
66
    public String getHospital() {
67
        return hospital;
68
    }
69
70
    public void setHospital(String hospital) {
71
        this.hospital = hospital;
72
    }
73
74
    @Column(descp = "文件科室", value = DE.text_de)
75
    public String getDepartment() {
76
        return department;
77
    }
78
79
    public void setDepartment(String department) {
80
        this.department = department;
81
    }
82
83
    @Column(descp = "上传人ID", value = DE.id_32)
84
    public String getOwner() {
85
        return owner;
86
    }
87
88
    public void setOwner(String owner) {
89
        this.owner = owner;
90
    }
91
92
    @Column(descp = "是否可用", value = DE.boolean_de)
93
    public boolean isActive() {
94
        return active;
95
    }
96
97
    public void setActive(boolean active) {
98
        this.active = active;
99
    }
100
101
    @Column(descp = "文件路径", value = DE.text_de)
102
    public void setUrl(String url) {
103
        this.url = url;
104
    }
105
106
    public String getFileName() {
107
        return fileName;
108
    }
109
110
    @Column(descp = "文件名", value = DE.text_de)
111
    public void setFileName(String fileName) {
112
        this.fileName = fileName;
113
    }
114
115
    @Override
116
    public String getCreateTime() {
117
        return createTime;
118
    }
119
120
    @Override
121
    public void setCreateTime(String createTime) {
122
        this.createTime = createTime;
123
    }
124
125
    public String getUrl() {
126
        return url;
127
    }
128
129
}

+ 199 - 0
src/main/java/com/ekexiu/project/storage/resource/service/StorageService.java

@ -0,0 +1,199 @@
1
package com.ekexiu.project.storage.resource.service;
2
3
import com.ekexiu.project.storage.resource.dao.StorageDao;
4
import com.ekexiu.project.storage.resource.po.Storage;
5
import com.ekexiu.project.storage.system.SessionUser;
6
import org.jfw.apt.annotation.Autowrie;
7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.web.annotation.LoginUser;
9
import org.jfw.apt.web.annotation.Path;
10
import org.jfw.apt.web.annotation.operate.Get;
11
import org.jfw.apt.web.annotation.operate.Post;
12
import org.jfw.apt.web.annotation.param.JdbcConn;
13
import org.jfw.apt.web.annotation.param.Upload;
14
import org.jfw.util.PageQueryResult;
15
import org.jfw.util.StringUtil;
16
import org.jfw.util.exception.JfwBaseException;
17
import org.jfw.util.web.fileupload.Item;
18
import org.jfw.util.web.fileupload.UploadItemIterator;
19
20
import java.io.File;
21
import java.io.FileOutputStream;
22
import java.io.InputStream;
23
import java.io.OutputStream;
24
import java.sql.Connection;
25
import java.sql.SQLException;
26
import java.util.concurrent.atomic.AtomicInteger;
27
28
/**
29
 * Created by TT on 2018/9/11.
30
 */
31
@Path("/storage")
32
public class StorageService {
33
    private static final AtomicInteger FN_IDX = new AtomicInteger(1);
34
    private File filePath;
35
    @Autowrie
36
    private StorageDao storageDao;
37
38
    public StorageDao getStorageDao() {
39
        return storageDao;
40
    }
41
42
    public void setStorageDao(StorageDao storageDao) {
43
        this.storageDao = storageDao;
44
    }
45
46
    public File getFilePath() {
47
        return filePath;
48
    }
49
50
    public void setFilePath(File filePath) {
51
        this.filePath = filePath;
52
    }
53
54
    @Post
55
    @Path
56
    public String insert(@JdbcConn(true) Connection con, @LoginUser SessionUser user, @Upload UploadItemIterator it) throws Exception {
57
        Storage storage = new Storage();
58
        try {
59
            while (it.hasNext()) {
60
                Item item = it.next();
61
                if (!item.isFormField()) {
62
                    if (storage.getUrl() != null) {
63
                        throw new JfwBaseException(-1, "only one file");
64
                    }
65
                    String name = normalizeFileName(item.getName());
66
                    int index = name.lastIndexOf('.');
67
                    String ext = index >= 0 ? name.substring(index + 1) : "";
68
                    ext = ext.trim();
69
                    long fileLen = 0;
70
                    int len = 0;
71
                    UploadFile uf = this.buildTargetFile(ext);
72
                    storage.setFileName(name);
73
                    storage.setUrl(uf.getUri());
74
                    File file = uf.getFn();
75
                    byte[] buf = new byte[8092];
76
                    OutputStream of = new FileOutputStream(file);
77
                    try {
78
                        InputStream in = item.getInputStream();
79
                        try {
80
                            while ((len = in.read(buf)) >= 0) {
81
                                if (len > 0) {
82
                                    of.write(buf, 0, len);
83
                                    fileLen += len;
84
                                }
85
                            }
86
                            storage.setSize(fileLen);
87
                        } finally {
88
                            in.close();
89
                        }
90
                    } finally {
91
                        of.close();
92
                    }
93
                } else {
94
                    if ("name".equals(item.getFieldName())) {
95
                        storage.setName(item.getString());
96
                    } else if ("type".equals(item.getFieldName())) {
97
                        storage.setType(item.getString());
98
                    }
99
100
                }
101
            }
102
        } finally {
103
            if (it != null)
104
                it.clean();
105
        }
106
        if (storage.getName() == null) {
107
108
        }
109
110
        String id = StringUtil.buildUUID();
111
        storage.setHospital(user.getHospital());
112
        storage.setDepartment(user.getDepartment());
113
        storage.setOwner(user.getId());
114
        storage.setId(id);
115
        storage.setActive(true);
116
        this.storageDao.insert(con, storage);
117
        return id;
118
    }
119
120
    @Get
121
    @Path("/delete")
122
    @LoginUser
123
    public void logicDelete(@JdbcConn(true) Connection con, String id) throws SQLException {
124
        this.storageDao.logicDelete(con, id);
125
    }
126
127
128
    @Path("/pq")
129
    @Get
130
    @LoginUser
131
    public PageQueryResult<Storage> pageQuery(@JdbcConn Connection con, @Nullable Boolean active, int pageSize, int pageNo) throws SQLException {
132
        return this.storageDao.pageQuery(con, active, pageSize, pageNo);
133
    }
134
135
136
    private UploadFile buildTargetFile(String ext) {
137
        StringBuilder sb = new StringBuilder();
138
        sb.append(System.currentTimeMillis() / (1000 * 60 * 60 * 24));
139
        File path = new File(this.filePath, sb.toString());
140
        if (!path.exists()) {
141
            synchronized (this) {
142
                if (!path.mkdirs())
143
                    throw new RuntimeException("mkdir error[" + path + "]");
144
                FN_IDX.set(1);
145
            }
146
        }
147
        File file;
148
        do {
149
            String fn = FN_IDX.toString();
150
            if (ext.isEmpty()) {
151
                file = new File(path, fn);
152
            } else {
153
                file = new File(path, fn + "." + ext);
154
            }
155
            FN_IDX.incrementAndGet();
156
        } while (file.exists());
157
        sb.append("/").append(file.getName());
158
        UploadFile uf = new UploadFile();
159
        uf.setFn(file);
160
        uf.setUri("/" + sb.toString());
161
        return uf;
162
    }
163
164
    private String normalizeFileName(String fn) {
165
        int index = fn.indexOf('\\');
166
        if (index >= 0) {
167
            fn = fn.substring(fn.lastIndexOf('\\') + 1);
168
        }
169
        index = fn.indexOf('/');
170
        if (index >= 0) {
171
            fn = fn.substring(fn.lastIndexOf('/') + 1);
172
        }
173
        if (fn.length() == 0)
174
            throw new RuntimeException("invalid filename in Multipart/data request");
175
        return fn;
176
    }
177
178
    public static class UploadFile {
179
        private String uri;
180
        private transient File fn;
181
182
        public File getFn() {
183
            return fn;
184
        }
185
186
        public void setFn(File fn) {
187
            this.fn = fn;
188
        }
189
190
        public String getUri() {
191
            return uri;
192
        }
193
194
        public void setUri(String uri) {
195
            this.uri = uri;
196
        }
197
    }
198
199
}

+ 79 - 0
src/main/java/com/ekexiu/project/storage/system/SessionUser.java

@ -0,0 +1,79 @@
1
package com.ekexiu.project.storage.system;
2
3
import org.jfw.util.auth.AuthUser;
4
5
/**
6
 * Created by TT on 2018/9/12.
7
 */
8
public class SessionUser implements AuthUser {
9
    private String id;
10
    private String account;
11
    private String name;
12
    private String hospital;
13
    private String department;
14
    private String createTime;
15
16
    private boolean active;
17
    @Override
18
    public boolean hasAuthority(int i) {
19
        return false;
20
    }
21
22
    @Override
23
    public String getId() {
24
        return id;
25
    }
26
27
28
    public void setId(String id) {
29
        this.id = id;
30
    }
31
32
    public String getAccount() {
33
        return account;
34
    }
35
36
    public void setAccount(String account) {
37
        this.account = account;
38
    }
39
40
    public String getName() {
41
        return name;
42
    }
43
44
    public void setName(String name) {
45
        this.name = name;
46
    }
47
48
    public String getHospital() {
49
        return hospital;
50
    }
51
52
    public void setHospital(String hospital) {
53
        this.hospital = hospital;
54
    }
55
56
    public String getDepartment() {
57
        return department;
58
    }
59
60
    public void setDepartment(String department) {
61
        this.department = department;
62
    }
63
64
    public String getCreateTime() {
65
        return createTime;
66
    }
67
68
    public void setCreateTime(String createTime) {
69
        this.createTime = createTime;
70
    }
71
72
    public boolean isActive() {
73
        return active;
74
    }
75
76
    public void setActive(boolean active) {
77
        this.active = active;
78
    }
79
}

+ 65 - 0
src/main/java/com/ekexiu/project/storage/system/dao/UserDao.java

@ -0,0 +1,65 @@
1
package com.ekexiu.project.storage.system.dao;
2
3
import com.ekexiu.project.storage.system.po.User;
4
import org.jfw.apt.annotation.Nullable;
5
import org.jfw.apt.orm.annotation.dao.DAO;
6
import org.jfw.apt.orm.annotation.dao.method.Exclude;
7
import org.jfw.apt.orm.annotation.dao.method.From;
8
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
9
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
12
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
13
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
14
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
15
import org.jfw.apt.orm.annotation.dao.param.Set;
16
import org.jfw.apt.orm.annotation.dao.param.UnEquals;
17
import org.jfw.util.PageQueryResult;
18
19
import java.sql.Connection;
20
import java.sql.SQLException;
21
22
/**
23
 * Created by TT on 2018/9/11.
24
 */
25
@DAO
26
public interface UserDao {
27
28
    @Insert
29
    int insert(Connection con, User user) throws SQLException;
30
31
    @Nullable
32
    @SelectOne
33
    User query(Connection con, String id) throws SQLException;
34
35
    @Nullable
36
    @SelectOne
37
    User querybyAccount(Connection con, String account) throws SQLException;
38
39
    @Nullable
40
    @SelectOne
41
    User login(Connection con, String account, String passwd) throws SQLException;
42
43
    @Update
44
    @Exclude({"passwd"})
45
    int update(Connection con, User user) throws SQLException;
46
47
    @UpdateWith
48
    @From(User.class)
49
    int changePw(Connection con, @Set String passwd, String id) throws SQLException;
50
51
    @UpdateWith
52
    @From(User.class)
53
    @SetSentence("active = '0'")
54
    int ban(Connection con, String id) throws SQLException;
55
56
    @Nullable
57
    @SelectOne
58
    User queryByAccount(Connection con, String account, @Nullable @UnEquals String id) throws SQLException;
59
60
    @PageSelect
61
    @OrderBy("ORDER BY CREATE_TIME")
62
    PageQueryResult<User> pageQuery(Connection con, @Nullable Boolean active, int pageSize, int pageNo) throws SQLException;
63
64
65
}

+ 102 - 0
src/main/java/com/ekexiu/project/storage/system/po/User.java

@ -0,0 +1,102 @@
1
package com.ekexiu.project.storage.system.po;
2
3
import com.ekexiu.project.storage.base.po.CreateTimeSupported;
4
import org.jfw.apt.orm.annotation.entry.Column;
5
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
6
import org.jfw.apt.orm.annotation.entry.Table;
7
import org.jfw.apt.orm.annotation.entry.Unique;
8
import org.jfw.apt.orm.annotation.entry.Uniques;
9
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
10
import org.jfw.apt.orm.core.enums.DE;
11
12
/**
13
 * Created by TT on 2018/9/11.
14
 */
15
@Table(descp = "用户表", value = "LUSER")
16
@PrimaryKey("id")
17
@Uniques({@Unique(clolumns = "account", name = "UC_LUSER_ACCOUNT")})
18
public class User implements CreateTimeSupported {
19
20
    private String id;
21
    private String account;
22
    private String passwd;
23
    private String name;
24
    private String hospital;
25
    private String department;
26
    private String createTime;
27
28
    private boolean active;
29
30
    @Column(descp = "用户ID", value = DE.id_32)
31
    public String getId() {
32
        return id;
33
    }
34
35
    public void setId(String id) {
36
        this.id = id;
37
    }
38
39
    @Column(descp = "用户帐号", value = DE.text_de)
40
    public String getAccount() {
41
        return account;
42
    }
43
44
    public void setAccount(String account) {
45
        this.account = account;
46
    }
47
48
    @Column(descp = "密码(MD5)", queryable = false, handlerClass = StringHandler.class, dbType = "TEXT")
49
    public String getPasswd() {
50
        return passwd;
51
    }
52
53
    public void setPasswd(String passwd) {
54
        this.passwd = passwd;
55
    }
56
57
    @Column(descp = "用户姓名", value = DE.text_de)
58
    public String getName() {
59
        return name;
60
    }
61
62
    public void setName(String name) {
63
        this.name = name;
64
    }
65
66
    @Column(descp = "所属医院", value = DE.text_de)
67
    public String getHospital() {
68
        return hospital;
69
    }
70
71
    public void setHospital(String hospital) {
72
        this.hospital = hospital;
73
    }
74
75
    @Column(descp = "所属科室", value = DE.text_de)
76
    public String getDepartment() {
77
        return department;
78
    }
79
80
    public void setDepartment(String department) {
81
        this.department = department;
82
    }
83
84
    @Column(descp = "是否可用", value = DE.boolean_de)
85
    public boolean isActive() {
86
        return active;
87
    }
88
89
    public void setActive(boolean active) {
90
        this.active = active;
91
    }
92
93
    @Override
94
    public String getCreateTime() {
95
        return createTime;
96
    }
97
98
    @Override
99
    public void setCreateTime(String createTime) {
100
        this.createTime = createTime;
101
    }
102
}

+ 142 - 3
src/main/java/com/ekexiu/project/storage/system/service/SysService.java

@ -1,7 +1,23 @@
1 1
package com.ekexiu.project.storage.system.service;
2 2
3
import com.ekexiu.project.storage.system.SessionUser;
4
import com.ekexiu.project.storage.system.dao.UserDao;
5
import com.ekexiu.project.storage.system.po.User;
6
import org.jfw.apt.annotation.Autowrie;
7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.web.annotation.LoginUser;
3 9
import org.jfw.apt.web.annotation.Path;
10
import org.jfw.apt.web.annotation.method.InvalidSession;
11
import org.jfw.apt.web.annotation.method.SetSession;
4 12
import org.jfw.apt.web.annotation.operate.Get;
13
import org.jfw.apt.web.annotation.operate.Post;
14
import org.jfw.apt.web.annotation.param.JdbcConn;
15
import org.jfw.util.PageQueryResult;
16
import org.jfw.util.StringUtil;
17
import org.jfw.util.exception.JfwBaseException;
18
19
import java.sql.Connection;
20
import java.sql.SQLException;
5 21
6 22
/**
7 23
 * Created by TT on 2018/9/11.
@ -9,9 +25,132 @@ import org.jfw.apt.web.annotation.operate.Get;
9 25
@Path("/sys")
10 26
public class SysService {
11 27
12
    @Path("/test")
28
    public static final String DEFAULT_PW_STR = StringUtil.md5("123456");
29
30
    private String rootPw = "123456";
31
    private String rootHospital = "kexiu";
32
    private String rootDepartment = "kexiu";
33
    private String rootCreateTime = "20150622";
34
35
    public String getRootPw() {
36
        return rootPw;
37
    }
38
39
    public void setRootPw(String rootPw) {
40
        this.rootPw = rootPw;
41
    }
42
43
    @Autowrie
44
    private UserDao userDao;
45
46
    public UserDao getUserDao() {
47
        return userDao;
48
    }
49
50
    public void setUserDao(UserDao userDao) {
51
        this.userDao = userDao;
52
    }
53
54
55
    @SetSession("JFW_SESSION_LOGIN_USER=result")
56
    @Path("/login")
57
    @Post
58
    public SessionUser login(@JdbcConn Connection con, String account, String pw) throws SQLException, JfwBaseException {
59
        if(account.equals("admin")){
60
            if (pw.equals(rootPw)) {
61
                SessionUser sessionUser = new SessionUser();
62
                sessionUser.setName("admin");
63
                sessionUser.setAccount("admin");
64
                sessionUser.setHospital(rootHospital);
65
                sessionUser.setDepartment(rootDepartment);
66
                sessionUser.setCreateTime(rootCreateTime);
67
                sessionUser.setActive(true);
68
                sessionUser.setId("11111111111111111111111111111111");
69
                return sessionUser;
70
            }
71
        }else {
72
            User user = userDao.login(con, account, StringUtil.md5(pw));
73
            if (user != null) {
74
                if (!user.isActive()) {
75
                    throw new JfwBaseException(-60005, "user is disabled");
76
                }
77
                SessionUser sessionUser = new SessionUser();
78
                sessionUser.setAccount(user.getAccount());
79
                sessionUser.setActive(user.isActive());
80
                sessionUser.setId(user.getId());
81
                sessionUser.setName(user.getName());
82
                sessionUser.setHospital(user.getHospital());
83
                sessionUser.setDepartment(user.getDepartment());
84
                sessionUser.setCreateTime(user.getCreateTime());
85
                return sessionUser;
86
            }
87
        }
88
        return null;
89
    }
90
13 91
    @Get
14
    public String test() {
15
        return "xmtt";
92
    @Path("/user")
93
    public SessionUser get(@LoginUser SessionUser user) {
94
        return user;
16 95
    }
96
97
    @Get
98
    @Path("/logout")
99
    @InvalidSession
100
    public void logout() {
101
    }
102
103
    @Post
104
    @Path("/insert")
105
    @LoginUser
106
    public String insert(@JdbcConn(true) Connection con, User user) throws SQLException {
107
        String id = StringUtil.buildUUID();
108
        user.setId(id);
109
        user.setActive(true);
110
        user.setPasswd(DEFAULT_PW_STR);
111
        this.userDao.insert(con, user);
112
        return id;
113
    }
114
115
    @Get
116
    @Path("/check")
117
    @LoginUser
118
    public Boolean check(@JdbcConn Connection con,String account,@Nullable String id)throws SQLException {
119
        return this.userDao.queryByAccount(con, account,id)==null;
120
    }
121
122
    @Get
123
    @Path("/qo")
124
    @LoginUser
125
    public User query(@JdbcConn Connection con, String id) throws SQLException {
126
        return this.userDao.query(con, id);
127
    }
128
129
    @Post
130
    @Path("/update")
131
    @LoginUser
132
    public void update(@JdbcConn(true) Connection con, User user) throws SQLException {
133
        this.userDao.update(con, user);
134
    }
135
136
    @Get
137
    @Path("/ban")
138
    @LoginUser
139
    public void ban(@JdbcConn(true) Connection con, String id) throws SQLException {
140
        this.userDao.ban(con, id);
141
    }
142
143
    @Get
144
    @Path("/pq")
145
    @LoginUser
146
    public PageQueryResult<User> pageQuery(@JdbcConn Connection con,@Nullable Boolean active,int pageSize,int pageNo)throws SQLException {
147
        return this.userDao.pageQuery(con, active, pageSize, pageNo);
148
    }
149
150
    @Post
151
    @Path("/changePw")
152
    public void changePw(@JdbcConn(true) Connection con, @LoginUser SessionUser u, String newPw) throws SQLException, JfwBaseException {
153
        this.userDao.changePw(con, StringUtil.md5(newPw), u.getId());
154
    }
155
17 156
}

+ 43 - 0
src/main/resources/database.sql

@ -0,0 +1,43 @@
1
CREATE TABLE STORAGE (
2
        ID CHAR(32) NOT NULL,
3
        NAME TEXT NOT NULL,
4
        TYPE TEXT NOT NULL,
5
        SIZE BIGINT NOT NULL,
6
        HOSPITAL TEXT NOT NULL,
7
        DEPARTMENT TEXT NOT NULL,
8
        OWNER CHAR(32) NOT NULL,
9
        ACTIVE CHAR(1) NOT NULL,
10
        URL TEXT NOT NULL,
11
        FILE_NAME TEXT NOT NULL,
12
        CREATE_TIME CHAR(14) NOT NULL);
13
ALTER TABLE STORAGE ADD PRIMARY KEY (ID);
14
COMMENT ON TABLE STORAGE IS '医疗影像表';
15
COMMENT ON COLUMN STORAGE.ID IS '文件ID';
16
COMMENT ON COLUMN STORAGE.NAME IS '文件名称';
17
COMMENT ON COLUMN STORAGE.TYPE IS '文件类型';
18
COMMENT ON COLUMN STORAGE.SIZE IS '文件大小';
19
COMMENT ON COLUMN STORAGE.HOSPITAL IS '所属医院';
20
COMMENT ON COLUMN STORAGE.DEPARTMENT IS '文件科室';
21
COMMENT ON COLUMN STORAGE.OWNER IS '上传人ID';
22
COMMENT ON COLUMN STORAGE.ACTIVE IS '是否可用';
23
COMMENT ON COLUMN STORAGE.URL IS '文件路径';
24
COMMENT ON COLUMN STORAGE.FILE_NAME IS '文件名';
25
CREATE TABLE LUSER (
26
        ID CHAR(32) NOT NULL,
27
        ACCOUNT TEXT NOT NULL,
28
        PASSWD TEXT NOT NULL,
29
        NAME TEXT NOT NULL,
30
        HOSPITAL TEXT NOT NULL,
31
        DEPARTMENT TEXT NOT NULL,
32
        ACTIVE CHAR(1) NOT NULL,
33
        CREATE_TIME CHAR(14) NOT NULL);
34
ALTER TABLE LUSER ADD PRIMARY KEY (ID);
35
ALTER TABLE LUSER ADD UNIQUE (ACCOUNT);
36
COMMENT ON TABLE LUSER IS '用户表';
37
COMMENT ON COLUMN LUSER.ID IS '用户ID';
38
COMMENT ON COLUMN LUSER.ACCOUNT IS '用户帐号';
39
COMMENT ON COLUMN LUSER.PASSWD IS '密码(MD5)';
40
COMMENT ON COLUMN LUSER.NAME IS '用户姓名';
41
COMMENT ON COLUMN LUSER.HOSPITAL IS '所属医院';
42
COMMENT ON COLUMN LUSER.DEPARTMENT IS '所属科室';
43
COMMENT ON COLUMN LUSER.ACTIVE IS '是否可用';

+ 4 - 2
src/main/resources/project.properties

@ -1,6 +1,6 @@
1 1
dataSource=com.alibaba.druid.pool.DruidDataSource
2 2
#数据库连接地址、名称、密码
3
dataSource.url=jdbc:postgresql://localhost:5432/storage
3
dataSource.url=jdbc:postgresql://192.168.3.233:5432/storage
4 4
dataSource.username=postgres
5 5
dataSource.password=postgres
6 6
#连接池启动时的初始值(初始化连接)
@ -28,4 +28,6 @@ dataSource.poolPreparedStatements::boolean=true
28 28
#statement池能够同时分配的打开的statements的最大数量
29 29
dataSource.maxPoolPreparedStatementPerConnectionSize::int=20
30 30
#默认的SQL语句自动提交状态(开启或关闭)设置由连接池本身设置(false由连接池定)
31
dataSource.defaultAutoCommit::boolean=false
31
dataSource.defaultAutoCommit::boolean=false
32
33
com_ekexiu_project_storage_resource_service_StorageService.filePath::java.io.File=/kexiu/storage/data