XMTT 5 years ago
commit
e6727ce49f

+ 4 - 0
.gitignore

@ -0,0 +1,4 @@
1
# Created by .ignore support plugin (hsz.mobi)
2
.idea
3
target
4
medical-share-web.iml

+ 85 - 0
pom.xml

@ -0,0 +1,85 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0"
3
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
    <modelVersion>4.0.0</modelVersion>
6
7
    <groupId>com.ekexiu</groupId>
8
    <artifactId>medical-share-web</artifactId>
9
    <version>1.0-SNAPSHOT</version>
10
    <packaging>war</packaging>
11
12
    <properties>
13
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14
        <maven.compiler.source>1.7</maven.compiler.source>
15
        <maven.compiler.target>1.7</maven.compiler.target>
16
        <maven.war.filteringDeploymentDescriptors>true</maven.war.filteringDeploymentDescriptors>
17
        <maven.tomcat.path>/</maven.tomcat.path>
18
    </properties>
19
    <dependencies>
20
        <dependency>
21
            <groupId>org.postgresql</groupId>
22
            <artifactId>postgresql</artifactId>
23
            <version>9.4.1207.jre7</version>
24
        </dependency>
25
        <dependency>
26
            <groupId>org.jfw</groupId>
27
            <artifactId>jfwApt</artifactId>
28
            <version>0.0.2-SNAPSHOT</version>
29
            <optional>true</optional>
30
        </dependency>
31
        <dependency>
32
            <groupId>org.jfw</groupId>
33
            <artifactId>jfwAptOrm</artifactId>
34
            <version>0.0.2-SNAPSHOT</version>
35
            <optional>true</optional>
36
        </dependency>
37
        <dependency>
38
            <groupId>org.jfw</groupId>
39
            <artifactId>jfwAptWeb</artifactId>
40
            <version>0.0.2-SNAPSHOT</version>
41
            <optional>true</optional>
42
        </dependency>
43
        <dependency>
44
            <groupId>org.jfw</groupId>
45
            <artifactId>jfwUtil</artifactId>
46
            <version>0.0.2-SNAPSHOT</version>
47
        </dependency>
48
        <dependency>
49
            <groupId>org.jfw</groupId>
50
            <artifactId>jfwWebUtil</artifactId>
51
            <version>0.0.2-SNAPSHOT</version>
52
        </dependency>
53
        <dependency>
54
            <groupId>javax.servlet</groupId>
55
            <artifactId>servlet-api</artifactId>
56
            <scope>provided</scope>
57
            <version>2.5</version>
58
        </dependency>
59
        <dependency>
60
            <groupId>com.alibaba</groupId>
61
            <artifactId>druid</artifactId>
62
            <version>1.0.20</version>
63
        </dependency>
64
    </dependencies>
65
    <build>
66
        <plugins>
67
            <plugin>
68
                <groupId>org.mortbay.jetty</groupId>
69
                <artifactId>jetty-maven-plugin</artifactId>
70
                <version>8.1.0.RC5</version>
71
                <configuration>
72
                    <stopPort>9966</stopPort>
73
                    <stopKey>foo</stopKey>
74
                    <webAppConfig>
75
                        <contextPath>/msweb</contextPath>
76
                    </webAppConfig>
77
                </configuration>
78
            </plugin>
79
        </plugins>
80
        <finalName>msweb</finalName>
81
    </build>
82
83
84
85
</project>

+ 35 - 0
src/main/java/com/ekexiu/project/base/po/BaseTable.java

@ -0,0 +1,35 @@
1
package com.ekexiu.project.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
import org.jfw.apt.orm.core.enums.DE;
8
9
/**
10
 * Created by TT on 2019/5/30.
11
 */
12
@JfwAptConfig("DB:PostgreSQL")
13
@VirtualTable
14
public interface BaseTable {
15
    @Column(descp = "创建时间(YYYYMMDDHH24MISS)不可修改", handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = false)
16
    String getCreateTime();
17
18
    void setCreateTime(String createTime);
19
20
    @Column(descp = "最后修改时间(YYYYMMDDHH24MISS),初始值:20000101010101", handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "'20000101010101'", fixSqlValueWithUpdate = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = true)
21
    String getModifyTime();
22
23
    void setModifyTime(String modifyTime);
24
25
    @Column(descp = "创建人ID", value = DE.id_32)
26
    String getCreator();
27
28
    void setCreator(String creator);
29
30
    @Column(descp = "最后修改人ID", value = DE.refid_32)
31
    String getModifier();
32
33
    void setModifier(String modifier);
34
35
}

+ 140 - 0
src/main/java/com/ekexiu/project/department/Department.java

@ -0,0 +1,140 @@
1
package com.ekexiu.project.department;
2
3
import com.ekexiu.project.base.po.BaseTable;
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 2019/5/30.
11
 */
12
@Table(descp = "科室",value = "DEPARTMENT")
13
@PrimaryKey("id")
14
public class Department implements BaseTable {
15
    private String id;
16
    private String hospital;
17
    private String name;
18
    private String type;
19
    private String phone;
20
    private String location;
21
    private String descp;
22
    private boolean active;
23
24
    private String createTime;
25
    private String modifyTime;
26
    private String creator;
27
    private String modifier;
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 = "所属医院ID", value = DE.id_32)
39
    public String getHospital() {
40
        return hospital;
41
    }
42
43
    public void setHospital(String hospital) {
44
        this.hospital = hospital;
45
    }
46
47
    @Column(descp = "科室名称", value = DE.text_de)
48
    public String getName() {
49
        return name;
50
    }
51
52
    public void setName(String name) {
53
        this.name = name;
54
    }
55
56
    @Column(descp = "科室ID", value = DE.singleChar)
57
    public String getType() {
58
        return type;
59
    }
60
61
    public void setType(String type) {
62
        this.type = type;
63
    }
64
65
    @Column(descp = "科室电话", value = DE.Text_de)
66
    public String getPhone() {
67
        return phone;
68
    }
69
70
    public void setPhone(String phone) {
71
        this.phone = phone;
72
    }
73
74
    @Column(descp = "科室地址", value = DE.Text_de)
75
    public String getLocation() {
76
        return location;
77
    }
78
79
    public void setLocation(String location) {
80
        this.location = location;
81
    }
82
83
    @Column(descp = "科室简介", value = DE.Text_de)
84
    public String getDescp() {
85
        return descp;
86
    }
87
88
    public void setDescp(String descp) {
89
        this.descp = descp;
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
    @Override
102
    public String getCreateTime() {
103
        return createTime;
104
    }
105
106
    @Override
107
    public void setCreateTime(String createTime) {
108
        this.createTime = createTime;
109
    }
110
111
    @Override
112
    public String getModifyTime() {
113
        return modifyTime;
114
    }
115
116
    @Override
117
    public void setModifyTime(String modifyTime) {
118
        this.modifyTime = modifyTime;
119
    }
120
121
    @Override
122
    public String getCreator() {
123
        return creator;
124
    }
125
126
    @Override
127
    public void setCreator(String creator) {
128
        this.creator = creator;
129
    }
130
131
    @Override
132
    public String getModifier() {
133
        return modifier;
134
    }
135
136
    @Override
137
    public void setModifier(String modifier) {
138
        this.modifier = modifier;
139
    }
140
}

+ 31 - 0
src/main/java/com/ekexiu/project/department/DepartmentDao.java

@ -0,0 +1,31 @@
1
package com.ekexiu.project.department;
2
3
import org.jfw.apt.annotation.Nullable;
4
import org.jfw.apt.orm.annotation.dao.DAO;
5
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
6
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
7
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
8
import org.jfw.apt.orm.annotation.dao.param.Like;
9
import org.jfw.util.PageQueryResult;
10
11
import java.sql.Connection;
12
import java.sql.SQLException;
13
14
/**
15
 * Created by TT on 2019/5/30.
16
 */
17
@DAO
18
public interface DepartmentDao {
19
20
    @Nullable
21
    @SelectOne
22
    Department query(Connection con, String id) throws SQLException;
23
24
    @PageSelect
25
    @OrderBy("ORDER BY CREATE_TIME DESC")
26
    PageQueryResult<Department> pageQuery(Connection con, @Nullable Boolean active, @Nullable @Like String name, int pageSize, int pageNo) throws SQLException;
27
28
    @PageSelect
29
    @OrderBy("ORDER BY CREATE_TIME DESC")
30
    PageQueryResult<Department> pageQuery(Connection con,String hospital, @Nullable Boolean active, int pageSize, int pageNo) throws SQLException;
31
}

+ 101 - 0
src/main/java/com/ekexiu/project/department/DepartmentService.java

@ -0,0 +1,101 @@
1
package com.ekexiu.project.department;
2
3
import org.jfw.apt.annotation.Autowrie;
4
import org.jfw.apt.annotation.Nullable;
5
import org.jfw.apt.web.annotation.Path;
6
import org.jfw.apt.web.annotation.operate.Get;
7
import org.jfw.apt.web.annotation.param.JdbcConn;
8
import org.jfw.util.PageQueryResult;
9
import org.jfw.util.jdbc.JdbcUtil;
10
import org.jfw.util.jdbc.PreparedStatementConfig;
11
12
import java.sql.Connection;
13
import java.sql.PreparedStatement;
14
import java.sql.SQLException;
15
import java.util.ArrayList;
16
import java.util.List;
17
import java.util.Map;
18
19
/**
20
 * Created by TT on 2019/5/30.
21
 */
22
@Path("/department")
23
public class DepartmentService {
24
25
    @Autowrie
26
    private DepartmentDao departmentDao;
27
28
    public DepartmentDao getDepartmentDao() {
29
        return departmentDao;
30
    }
31
32
    public void setDepartmentDao(DepartmentDao departmentDao) {
33
        this.departmentDao = departmentDao;
34
    }
35
36
    @Path("/qo")
37
    @Get
38
    public Department query(@JdbcConn Connection con, String id) throws SQLException {
39
        return departmentDao.query(con, id);
40
    }
41
42
    @Path("/pq")
43
    @Get
44
    public PageQueryResult<Department> pageQuery(@JdbcConn Connection con, @Nullable Boolean active, @Nullable String name, int pageSize, int pageNo) throws SQLException {
45
        return departmentDao.pageQuery(con, active, name == null ? null : "%" + name + "%", pageSize, pageNo);
46
    }
47
48
    @Path("/hospital")
49
    @Get
50
    public PageQueryResult<Department> pqgeQuery(@JdbcConn Connection con,@Nullable Boolean active,String hospital,int pageSize,int pageNo)throws SQLException {
51
        return departmentDao.pageQuery(con, hospital, active, pageSize, pageNo);
52
    }
53
54
    @Path("/name")
55
    @Get
56
    public List<TypeaheadItem> queryName(@JdbcConn Connection con, String name, int size) throws SQLException {
57
        if (name != null) {
58
            name = "%" + name + "%";
59
        }
60
        List<TypeaheadItem> ret = new ArrayList<>(size);
61
        final String finalKey = name;
62
        List<Map<String, Object>> typehead = JdbcUtil.queryMaps(con, "SELECT NAME,ID FROM DEPARTMENT WHERE NAME LIKE ? ", new PreparedStatementConfig() {
63
            @Override
64
            public void config(PreparedStatement preparedStatement) throws SQLException {
65
                preparedStatement.setString(1, finalKey);
66
            }
67
        });
68
69
        for (Map<String, Object> map : typehead) {
70
            TypeaheadItem item = new TypeaheadItem();
71
            item.setId((String) map.get("id"));
72
            item.setName((String) map.get("name"));
73
            ret.add(item);
74
        }
75
        return ret;
76
    }
77
78
79
    public static class TypeaheadItem {
80
        private String id;
81
        private String name;
82
83
        public String getId() {
84
            return id;
85
        }
86
87
        public void setId(String id) {
88
            this.id = id;
89
        }
90
91
        public String getName() {
92
            return name;
93
        }
94
95
        public void setName(String name) {
96
            this.name = name;
97
        }
98
99
    }
100
101
}

+ 194 - 0
src/main/java/com/ekexiu/project/doctor/Doctor.java

@ -0,0 +1,194 @@
1
package com.ekexiu.project.doctor;
2
3
import com.ekexiu.project.base.po.BaseTable;
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 2019/5/30.
14
 */
15
@Table(descp = "医生", value = "DOCTOR")
16
@PrimaryKey("id")
17
@Uniques({@Unique(clolumns = "account", name = "UC_DOCTOR_ACCOUNT")})
18
public class Doctor implements BaseTable {
19
    private String id;
20
    private String hospital;
21
    private String department;
22
    private String account;
23
    private String name;
24
    private String clinicalTitle;
25
    private String teachTitle;
26
    private String position;
27
    private String direction;
28
    private String image;
29
    private String descp;
30
    private boolean active;
31
    private String passwd;
32
33
    private String createTime;
34
    private String modifyTime;
35
    private String creator;
36
    private String modifier;
37
38
    @Column(descp = "医生ID", value = DE.id_32)
39
    public String getId() {
40
        return id;
41
    }
42
43
    public void setId(String id) {
44
        this.id = id;
45
    }
46
47
    @Column(descp = "医院ID", value = DE.id_32)
48
    public String getHospital() {
49
        return hospital;
50
    }
51
52
    public void setHospital(String hospital) {
53
        this.hospital = hospital;
54
    }
55
56
    @Column(descp = "医院ID", value = DE.REFID_32)
57
    public String getDepartment() {
58
        return department;
59
    }
60
61
    public void setDepartment(String department) {
62
        this.department = department;
63
    }
64
65
    @Column(descp = "帐号", value = DE.text_de)
66
    public String getAccount() {
67
        return account;
68
    }
69
70
    public void setAccount(String account) {
71
        this.account = account;
72
    }
73
74
    @Column(descp = "医生姓名", value = DE.text_de)
75
    public String getName() {
76
        return name;
77
    }
78
79
    public void setName(String name) {
80
        this.name = name;
81
    }
82
83
    @Column(descp = "临床职称", value = DE.Text_de)
84
    public String getClinicalTitle() {
85
        return clinicalTitle;
86
    }
87
88
    public void setClinicalTitle(String clinicalTitle) {
89
        this.clinicalTitle = clinicalTitle;
90
    }
91
92
    @Column(descp = "教学职称", value = DE.Text_de)
93
    public String getTeachTitle() {
94
        return teachTitle;
95
    }
96
97
    public void setTeachTitle(String teachTitle) {
98
        this.teachTitle = teachTitle;
99
    }
100
101
    @Column(descp = "行政职务", value = DE.Text_de)
102
    public String getPosition() {
103
        return position;
104
    }
105
106
    public void setPosition(String position) {
107
        this.position = position;
108
    }
109
110
    @Column(descp = "擅长方向", value = DE.Text_de)
111
    public String getDirection() {
112
        return direction;
113
    }
114
115
    public void setDirection(String direction) {
116
        this.direction = direction;
117
    }
118
119
    @Column(descp = "图片", value = DE.String_de)
120
    public String getImage() {
121
        return image;
122
    }
123
124
    public void setImage(String image) {
125
        this.image = image;
126
    }
127
128
    @Column(descp = "个人简介", value = DE.Text_de)
129
    public String getDescp() {
130
        return descp;
131
    }
132
133
    public void setDescp(String descp) {
134
        this.descp = descp;
135
    }
136
137
    @Column(descp = "是否可用", value = DE.boolean_de)
138
    public boolean isActive() {
139
        return active;
140
    }
141
142
    public void setActive(boolean active) {
143
        this.active = active;
144
    }
145
146
    @Column(descp = "密码(MD5)", queryable = false, handlerClass = StringHandler.class, dbType = "TEXT")
147
    public String getPasswd() {
148
        return passwd;
149
    }
150
151
    public void setPasswd(String passwd) {
152
        this.passwd = passwd;
153
    }
154
155
    @Override
156
    public String getCreateTime() {
157
        return createTime;
158
    }
159
160
    @Override
161
    public void setCreateTime(String createTime) {
162
        this.createTime = createTime;
163
    }
164
165
    @Override
166
    public String getModifyTime() {
167
        return modifyTime;
168
    }
169
170
    @Override
171
    public void setModifyTime(String modifyTime) {
172
        this.modifyTime = modifyTime;
173
    }
174
175
    @Override
176
    public String getCreator() {
177
        return creator;
178
    }
179
180
    @Override
181
    public void setCreator(String creator) {
182
        this.creator = creator;
183
    }
184
185
    @Override
186
    public String getModifier() {
187
        return modifier;
188
    }
189
190
    @Override
191
    public void setModifier(String modifier) {
192
        this.modifier = modifier;
193
    }
194
}

+ 37 - 0
src/main/java/com/ekexiu/project/doctor/DoctorDao.java

@ -0,0 +1,37 @@
1
package com.ekexiu.project.doctor;
2
3
import org.jfw.apt.annotation.Nullable;
4
import org.jfw.apt.orm.annotation.dao.DAO;
5
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
6
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
7
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
8
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
9
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
10
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
11
import org.jfw.util.PageQueryResult;
12
13
import java.sql.Connection;
14
import java.sql.SQLException;
15
16
/**
17
 * Created by TT on 2019/5/30.
18
 */
19
@DAO
20
public interface DoctorDao {
21
22
    @SelectOne
23
    @Nullable
24
    Doctor query(Connection con, String id) throws SQLException;
25
26
    @PageSelect
27
    @OrderBy("ORDER BY CREATE_TIME DESC")
28
    PageQueryResult<Doctor> pageQuery(Connection con, @Nullable Boolean active, @Nullable @SqlColumn(handlerClass = StringHandler.class, value = "HOSPITAL IN (SELECT ID FROM HOSPITAL WHERE ADDR LIKE ?)") String addr, @Nullable String clinicalTitle, @Nullable @SqlColumn(handlerClass = StringHandler.class, value = "HOSPITAL in (select id from hospital where level = ?)") String level, @Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = {"NAME LIKE ?", "DIRECTION LIKE ?", "DEPARTMENT IN (SELECT ID FROM DEPARTMENT WHERE NAME LIKE ?)"}, isAnd = false) String key, int pageSize, int pageNo) throws SQLException;
29
30
    @PageSelect
31
    @OrderBy("ORDER BY CREATE_TIME DESC")
32
    PageQueryResult<Doctor> pageQuery(Connection con, String hospital, @Nullable Boolean active, int pageSize, int pageNo) throws SQLException;
33
34
    @PageSelect
35
    @OrderBy("ORDER BY CREATE_TIME DESC")
36
    PageQueryResult<Doctor> pageQuery(Connection con, String hospital, String department, @Nullable boolean active, int pageSize, int pageNo) throws SQLException;
37
}

+ 55 - 0
src/main/java/com/ekexiu/project/doctor/DoctorService.java

@ -0,0 +1,55 @@
1
package com.ekexiu.project.doctor;
2
3
4
import org.jfw.apt.annotation.Autowrie;
5
import org.jfw.apt.annotation.Nullable;
6
import org.jfw.apt.web.annotation.Path;
7
import org.jfw.apt.web.annotation.operate.Get;
8
import org.jfw.apt.web.annotation.param.JdbcConn;
9
import org.jfw.util.PageQueryResult;
10
11
import java.sql.Connection;
12
import java.sql.SQLException;
13
14
/**
15
 * Created by TT on 2019/5/30.
16
 */
17
@Path("/doctor")
18
public class DoctorService {
19
20
    @Autowrie
21
    private DoctorDao doctorDao;
22
23
    public DoctorDao getDoctorDao() {
24
        return doctorDao;
25
    }
26
27
    public void setDoctorDao(DoctorDao doctorDao) {
28
        this.doctorDao = doctorDao;
29
    }
30
31
32
    @Get
33
    @Path("/qo")
34
    public Doctor query(@JdbcConn Connection con, String id) throws SQLException {
35
        return doctorDao.query(con, id);
36
    }
37
38
    @Get
39
    @Path("/pq")
40
    public PageQueryResult<Doctor> pageQuery(@JdbcConn Connection con, @Nullable Boolean active, @Nullable String addr, @Nullable String clinicalTitle, @Nullable String level, @Nullable String key, int pageSize, int pageNo) throws SQLException {
41
        return doctorDao.pageQuery(con, active, addr == null ? null : addr + "%", clinicalTitle, level, key == null ? null : "%" + key + "%", pageSize, pageNo);
42
    }
43
44
    @Path("/hospital")
45
    @Get
46
    public PageQueryResult<Doctor> pageQuery(@JdbcConn Connection con, @Nullable Boolean active, String hospital, int pageSize, int pageNo) throws SQLException {
47
        return doctorDao.pageQuery(con, hospital, active, pageSize, pageNo);
48
    }
49
50
    @Path("/department")
51
    @Get
52
    public PageQueryResult<Doctor> pageQuery(@JdbcConn Connection con, @Nullable Boolean active, String hospital, String department, int pageSize, int pageNo) throws SQLException {
53
        return doctorDao.pageQuery(con, hospital, department, active, pageSize, pageNo);
54
    }
55
}

+ 197 - 0
src/main/java/com/ekexiu/project/hospital/Hospital.java

@ -0,0 +1,197 @@
1
package com.ekexiu.project.hospital;
2
3
import com.ekexiu.project.base.po.BaseTable;
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 2019/5/30.
14
 */
15
@Table(descp = "医院登录表", value = "HOSPITAL")
16
@PrimaryKey("id")
17
@Uniques({@Unique(clolumns = "account", name = "UC_HOSPITAL_ACCOUNT")})
18
public class Hospital implements BaseTable {
19
    private String id;
20
    private String passwd;
21
22
    private String account;
23
    private String name;
24
    private String level;
25
    private String subLevel;
26
    private String type;
27
    private String phone;
28
    private String location;
29
    private String addr;
30
    private String descp;
31
    private String image;
32
    private boolean active;
33
34
    private String createTime;
35
    private String modifyTime;
36
    private String creator;
37
    private String modifier;
38
39
40
    @Column(descp = "医院ID", value = DE.id_32)
41
    public String getId() {
42
        return id;
43
    }
44
45
    public void setId(String id) {
46
        this.id = id;
47
    }
48
49
    @Column(descp = "密码(MD5)", queryable = false, handlerClass = StringHandler.class, dbType = "TEXT")
50
    public String getPasswd() {
51
        return passwd;
52
    }
53
54
    public void setPasswd(String passwd) {
55
        this.passwd = passwd;
56
    }
57
58
    @Column(descp = "医院帐号", value = DE.text_de)
59
    public String getAccount() {
60
        return account;
61
    }
62
63
    public void setAccount(String account) {
64
        this.account = account;
65
    }
66
67
    @Column(descp = "医院名称", value = DE.text_de)
68
    public String getName() {
69
        return name;
70
    }
71
72
    public void setName(String name) {
73
        this.name = name;
74
    }
75
76
    @Column(descp = "医院级别", value = DE.singleChar)
77
    public String getLevel() {
78
        return level;
79
    }
80
81
82
    public void setLevel(String level) {
83
        this.level = level;
84
    }
85
86
    @Column(descp = "医院子级别", value = DE.singleChar)
87
    public String getSubLevel() {
88
        return subLevel;
89
    }
90
91
    public void setSubLevel(String subLevel) {
92
        this.subLevel = subLevel;
93
    }
94
95
    @Column(descp = "医院类型", value = DE.singleChar)
96
    public String getType() {
97
        return type;
98
    }
99
100
    public void setType(String type) {
101
        this.type = type;
102
    }
103
104
    @Column(descp = "电话", value = DE.Text_de)
105
    public String getPhone() {
106
        return phone;
107
    }
108
109
    public void setPhone(String phone) {
110
        this.phone = phone;
111
    }
112
113
    @Column(descp = "医院详细地址", value = DE.Text_de)
114
    public String getLocation() {
115
        return location;
116
    }
117
118
    public void setLocation(String location) {
119
        this.location = location;
120
    }
121
122
    @Column(descp = "医院所在城市编码", value = DE.String_de)
123
    public String getAddr() {
124
        return addr;
125
    }
126
127
    public void setAddr(String addr) {
128
        this.addr = addr;
129
    }
130
131
    @Column(descp = "医院简介", value = DE.Text_de)
132
    public String getDescp() {
133
        return descp;
134
    }
135
136
    public void setDescp(String descp) {
137
        this.descp = descp;
138
    }
139
140
    @Column(descp = "医院图片", value = DE.Text_de)
141
    public String getImage() {
142
        return image;
143
    }
144
145
    public void setImage(String image) {
146
        this.image = image;
147
    }
148
149
    @Column(descp = "是否可用", value = DE.boolean_de)
150
    public boolean isActive() {
151
        return active;
152
    }
153
154
    public void setActive(boolean active) {
155
        this.active = active;
156
    }
157
158
    @Override
159
    public String getCreateTime() {
160
        return createTime;
161
    }
162
163
    @Override
164
    public void setCreateTime(String createTime) {
165
        this.createTime = createTime;
166
    }
167
168
    @Override
169
    public String getModifyTime() {
170
        return modifyTime;
171
    }
172
173
    @Override
174
    public void setModifyTime(String modifyTime) {
175
        this.modifyTime = modifyTime;
176
    }
177
178
    @Override
179
    public String getCreator() {
180
        return creator;
181
    }
182
183
    @Override
184
    public void setCreator(String creator) {
185
        this.creator = creator;
186
    }
187
188
    @Override
189
    public String getModifier() {
190
        return modifier;
191
    }
192
193
    @Override
194
    public void setModifier(String modifier) {
195
        this.modifier = modifier;
196
    }
197
}

+ 30 - 0
src/main/java/com/ekexiu/project/hospital/HospitalDao.java

@ -0,0 +1,30 @@
1
package com.ekexiu.project.hospital;
2
3
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.OrderBy;
7
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
8
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
9
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
10
import org.jfw.apt.orm.annotation.dao.param.Like;
11
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
12
import org.jfw.util.PageQueryResult;
13
14
import java.sql.Connection;
15
import java.sql.SQLException;
16
17
/**
18
 * Created by TT on 2019/5/30.
19
 */
20
@DAO
21
public interface HospitalDao {
22
23
    @Nullable
24
    @SelectOne
25
    Hospital query(Connection con, String id) throws SQLException;
26
27
    @PageSelect
28
    @OrderBy("ORDER BY CREATE_TIME DESC")
29
    PageQueryResult<Hospital> pageQuery(Connection con, @Nullable @Like String addr, @Nullable Boolean active, @Nullable String level, @Nullable String type, @Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = {"NAME LIKE ?", "ID IN (SELECT HOSPITAL FROM DEPARTMENT WHERE NAME LIKE ?)"}) String key, int pageSize, int pageNo) throws SQLException;
30
}

+ 97 - 0
src/main/java/com/ekexiu/project/hospital/HospitalService.java

@ -0,0 +1,97 @@
1
package com.ekexiu.project.hospital;
2
3
import com.ekexiu.project.system.vo.SessionHospital;
4
import org.jfw.apt.annotation.Autowrie;
5
import org.jfw.apt.annotation.Nullable;
6
import org.jfw.apt.web.annotation.Path;
7
import org.jfw.apt.web.annotation.operate.Get;
8
import org.jfw.apt.web.annotation.param.JdbcConn;
9
import org.jfw.util.PageQueryResult;
10
import org.jfw.util.jdbc.JdbcUtil;
11
import org.jfw.util.jdbc.ResultSetExtractor;
12
13
import java.sql.Connection;
14
import java.sql.ResultSet;
15
import java.sql.SQLException;
16
import java.util.ArrayList;
17
import java.util.HashMap;
18
import java.util.List;
19
import java.util.Map;
20
21
/**
22
 * Created by TT on 2019/6/5.
23
 */
24
@Path("/hospital")
25
public class HospitalService {
26
27
    @Autowrie
28
    private HospitalDao hospitalDao;
29
30
    public HospitalDao getHospitalDao() {
31
        return hospitalDao;
32
    }
33
34
    public void setHospitalDao(HospitalDao hospitalDao) {
35
        this.hospitalDao = hospitalDao;
36
    }
37
38
    @Path("/qo")
39
    @Get
40
    public SessionHospital query(@JdbcConn Connection con, String id) throws SQLException {
41
        return makeSessionHospital(hospitalDao.query(con, id));
42
    }
43
44
    @Path("/pq")
45
    @Get
46
    public PageQueryResult<SessionHospital> pageQuery(@JdbcConn Connection con, @Nullable Boolean active, @Nullable String addr, @Nullable String level, @Nullable String type, @Nullable String key, int pageSize, int pageNo) throws SQLException {
47
        PageQueryResult<Hospital> pageQueryResult = hospitalDao.pageQuery(con, addr == null ? null : addr + "%", active, level, type, key == null ? null : "%" + key + "%", pageSize, pageNo);
48
        if (pageQueryResult != null) {
49
            List<Hospital> hospitals = pageQueryResult.getData();
50
            List<SessionHospital> sessionHospitals = new ArrayList<>();
51
            if (!hospitals.isEmpty()) {
52
                for (Hospital hospital : hospitals) {
53
                    sessionHospitals.add(makeSessionHospital(hospital));
54
                }
55
                PageQueryResult<SessionHospital> ret = new PageQueryResult<>();
56
                ret.setPageNo(pageQueryResult.getPageNo());
57
                ret.setPageSize(pageQueryResult.getPageSize());
58
                ret.setTotal(pageQueryResult.getTotal());
59
                ret.setData(sessionHospitals);
60
                return ret;
61
            }
62
        }
63
        return null;
64
    }
65
66
    @Path("/city")
67
    @Get
68
    public List<Map<String, Object>> rank(@JdbcConn Connection con) throws SQLException {
69
        return JdbcUtil.queryList(con, "select substring(h.addr from 0 for 5) as city,count(*) as num from doctor d LEFT JOIN hospital h on d.hospital = h.id GROUP BY city ORDER BY num DESC", new ResultSetExtractor<Map<String, Object>>() {
70
            @Override
71
            public Map<String, Object> extractData(ResultSet resultSet) throws SQLException {
72
                Map<String, Object> map = new HashMap<>();
73
                map.put("city", resultSet.getString(1));
74
                map.put("num", resultSet.getInt(2));
75
                return map;
76
            }
77
        });
78
    }
79
80
81
    private static SessionHospital makeSessionHospital(Hospital hospital) {
82
        SessionHospital sessionHospital = new SessionHospital();
83
        sessionHospital.setAccount(hospital.getAccount());
84
        sessionHospital.setName(hospital.getName());
85
        sessionHospital.setLevel(hospital.getLevel());
86
        sessionHospital.setSubLevel(hospital.getSubLevel());
87
        sessionHospital.setId(hospital.getId());
88
        sessionHospital.setType(hospital.getType());
89
        sessionHospital.setPhone(hospital.getPhone());
90
        sessionHospital.setLocation(hospital.getLocation());
91
        sessionHospital.setAddr(hospital.getAddr());
92
        sessionHospital.setDesc(hospital.getDescp());
93
        sessionHospital.setImage(hospital.getImage());
94
        sessionHospital.setActive(hospital.isActive());
95
        return sessionHospital;
96
    }
97
}

+ 161 - 0
src/main/java/com/ekexiu/project/instrument/Instrument.java

@ -0,0 +1,161 @@
1
package com.ekexiu.project.instrument;
2
3
4
import com.ekexiu.project.base.po.BaseTable;
5
import org.jfw.apt.orm.annotation.entry.Column;
6
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
7
import org.jfw.apt.orm.annotation.entry.Table;
8
import org.jfw.apt.orm.core.enums.DE;
9
10
/**
11
 * Created by TT on 2019/5/30.
12
 */
13
@Table(descp = "器械表", value = "INSTRUMENT")
14
@PrimaryKey("id")
15
public class Instrument implements BaseTable {
16
    private String id;
17
    private String name;
18
    private String status;
19
    private String department;
20
    private String hospital;
21
    private String spec;
22
    private String application;
23
    private String descp;
24
    private String image;
25
    private boolean active;
26
27
    private String createTime;
28
    private String modifyTime;
29
    private String creator;
30
    private String modifier;
31
32
    @Column(descp = "器械ID", value = DE.id_32)
33
    public String getId() {
34
        return id;
35
    }
36
37
    public void setId(String id) {
38
        this.id = id;
39
    }
40
41
    @Column(descp = "器械名称", value = DE.text_de)
42
    public String getName() {
43
        return name;
44
    }
45
46
    public void setName(String name) {
47
        this.name = name;
48
    }
49
50
    @Column(descp = "器械状态", value = DE.singleChar)
51
    public String getStatus() {
52
        return status;
53
    }
54
55
    public void setStatus(String status) {
56
        this.status = status;
57
    }
58
59
    @Column(descp = "所属科室", value = DE.REFID_32)
60
    public String getDepartment() {
61
        return department;
62
    }
63
64
    public void setDepartment(String department) {
65
        this.department = department;
66
    }
67
68
    @Column(descp = "所属医院", value = DE.id_32)
69
    public String getHospital() {
70
        return hospital;
71
    }
72
73
    public void setHospital(String hospital) {
74
        this.hospital = hospital;
75
    }
76
77
    @Column(descp = "厂商型号", value = DE.Text_de)
78
    public String getSpec() {
79
        return spec;
80
    }
81
82
    public void setSpec(String spec) {
83
        this.spec = spec;
84
    }
85
86
    @Column(descp = "功能用途", value = DE.Text_de)
87
    public String getApplication() {
88
        return application;
89
    }
90
91
    public void setApplication(String application) {
92
        this.application = application;
93
    }
94
95
    @Column(descp = "器械简介", value = DE.Text_de)
96
    public String getDescp() {
97
        return descp;
98
    }
99
100
    public void setDescp(String descp) {
101
        this.descp = descp;
102
    }
103
104
    @Column(descp = "器械图片", value = DE.Text_de)
105
    public String getImage() {
106
        return image;
107
    }
108
109
    public void setImage(String image) {
110
        this.image = image;
111
    }
112
113
    @Column(descp = "是否可用", value = DE.boolean_de)
114
    public boolean isActive() {
115
        return active;
116
    }
117
118
    public void setActive(boolean active) {
119
        this.active = active;
120
    }
121
122
    @Override
123
    public String getCreateTime() {
124
        return createTime;
125
    }
126
127
    @Override
128
    public void setCreateTime(String createTime) {
129
        this.createTime = createTime;
130
    }
131
132
    @Override
133
    public String getModifyTime() {
134
        return modifyTime;
135
    }
136
137
    @Override
138
    public void setModifyTime(String modifyTime) {
139
        this.modifyTime = modifyTime;
140
    }
141
142
    @Override
143
    public String getCreator() {
144
        return creator;
145
    }
146
147
    @Override
148
    public void setCreator(String creator) {
149
        this.creator = creator;
150
    }
151
152
    @Override
153
    public String getModifier() {
154
        return modifier;
155
    }
156
157
    @Override
158
    public void setModifier(String modifier) {
159
        this.modifier = modifier;
160
    }
161
}

+ 37 - 0
src/main/java/com/ekexiu/project/instrument/InstrumentDao.java

@ -0,0 +1,37 @@
1
package com.ekexiu.project.instrument;
2
3
import org.jfw.apt.annotation.Nullable;
4
import org.jfw.apt.orm.annotation.dao.DAO;
5
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
6
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
7
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
8
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
9
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
10
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
11
import org.jfw.util.PageQueryResult;
12
13
import java.sql.Connection;
14
import java.sql.SQLException;
15
16
/**
17
 * Created by TT on 2019/5/30.
18
 */
19
@DAO
20
public interface InstrumentDao {
21
22
    @Nullable
23
    @SelectOne
24
    Instrument query(Connection con, String id) throws SQLException;
25
26
    @PageSelect
27
    @OrderBy("ORDER BY CREATE_TIME DESC")
28
    PageQueryResult<Instrument> pageQuery(Connection con, @Nullable Boolean active, @Nullable @SqlColumn(handlerClass = StringHandler.class, value = "HOSPITAL IN (SELECT ID FROM HOSPITAL WHERE ADDR LIKE ?)") String addr, @Nullable @SqlColumn(handlerClass = StringHandler.class, value = "HOSPITAL IN (SELECT ID FROM HOSPITAL WHERE LEVEL = ?)") String level, @Nullable String status, @Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = {"NAME LIKE ?", "HOSPITAL IN (SELECT ID FROM HOSPITAL WHERE NAME LIKE ?)", "SPEC LIKE ?"}, isAnd = false) String key, int pageSize, int pageNo) throws SQLException;
29
30
    @PageSelect
31
    @OrderBy("ORDER BY CREATE_TIME DESC")
32
    PageQueryResult<Instrument> pageQuery(Connection con, String hospital, @Nullable Boolean active, int pageSize, int pageNo) throws SQLException;
33
34
    @PageSelect
35
    @OrderBy("ORDER BY CREATE_TIME DESC")
36
    PageQueryResult<Instrument> pageQuery(Connection con, String hospital,String department, @Nullable Boolean active, int pageSize, int pageNo) throws SQLException;
37
}

+ 56 - 0
src/main/java/com/ekexiu/project/instrument/InstrumentService.java

@ -0,0 +1,56 @@
1
package com.ekexiu.project.instrument;
2
3
import org.jfw.apt.annotation.Autowrie;
4
import org.jfw.apt.annotation.Nullable;
5
import org.jfw.apt.web.annotation.Path;
6
import org.jfw.apt.web.annotation.operate.Get;
7
import org.jfw.apt.web.annotation.param.JdbcConn;
8
import org.jfw.util.PageQueryResult;
9
10
import java.sql.Connection;
11
import java.sql.SQLException;
12
13
/**
14
 * Created by TT on 2019/5/30.
15
 */
16
@Path("/instrument")
17
public class InstrumentService {
18
19
    @Autowrie
20
    private InstrumentDao instrumentDao;
21
22
    public InstrumentDao getInstrumentDao() {
23
        return instrumentDao;
24
    }
25
26
    public void setInstrumentDao(InstrumentDao instrumentDao) {
27
        this.instrumentDao = instrumentDao;
28
    }
29
30
31
    @Path("/qo")
32
    @Get
33
    public Instrument query(@JdbcConn Connection con, String id) throws SQLException {
34
        return instrumentDao.query(con, id);
35
    }
36
37
    @Path("/pq")
38
    @Get
39
    public PageQueryResult<Instrument> pageQuery(@JdbcConn Connection con, @Nullable Boolean active, @Nullable String addr, @Nullable String level, @Nullable String status, @Nullable String key, int pageSize, int pageNo) throws SQLException {
40
        return instrumentDao.pageQuery(con, active, addr == null ? null : addr + "%", level, status, key == null ? null : "%" + key + "%", pageSize, pageNo);
41
    }
42
43
    @Path("/hospital")
44
    @Get
45
    public PageQueryResult<Instrument> pageQuery(@JdbcConn Connection con, @Nullable Boolean active, String hospital, int pageSize, int pageNo) throws SQLException {
46
        return instrumentDao.pageQuery(con, hospital, active, pageSize, pageNo);
47
    }
48
49
    @Path("/department")
50
    @Get
51
    public PageQueryResult<Instrument> pageQuery(@JdbcConn Connection con, @Nullable Boolean active, String hospital, String department, int pageSize, int pageNo) throws SQLException {
52
        return instrumentDao.pageQuery(con, hospital, department, active, pageSize, pageNo);
53
    }
54
55
56
}

+ 46 - 0
src/main/java/com/ekexiu/project/system/dao/DictDao.java

@ -0,0 +1,46 @@
1
package com.ekexiu.project.system.dao;
2
3
4
import com.ekexiu.project.system.po.DictItem;
5
import org.jfw.apt.annotation.Nullable;
6
import org.jfw.apt.orm.annotation.dao.DAO;
7
import org.jfw.apt.orm.annotation.dao.method.From;
8
import org.jfw.apt.orm.annotation.dao.method.IncludeFixSet;
9
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
10
import org.jfw.apt.orm.annotation.dao.method.Where;
11
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
12
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
13
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
14
import org.jfw.apt.orm.annotation.dao.param.Set;
15
16
import java.sql.Connection;
17
import java.sql.SQLException;
18
import java.util.List;
19
20
/**
21
 * Created by TT on 2019/5/30.
22
 */
23
@DAO
24
public interface DictDao {
25
26
    @SelectList
27
    List<DictItem> query(Connection con) throws SQLException;
28
29
    @Insert
30
    int insert(Connection con, DictItem dict) throws SQLException;
31
32
    @UpdateWith
33
    @From(DictItem.class)
34
    @Where("ACTIVE = '1' AND READONLY <> '1'")
35
    @SetSentence("ACTIVE='0'")
36
    @IncludeFixSet
37
    int disable(Connection con, String dictCode, String code) throws SQLException;
38
39
40
    @UpdateWith
41
    @From(DictItem.class)
42
    @Where("ACTIVE = '1' AND READONLY <> '1'")
43
    int update(Connection con, @Nullable @Set String bcode, @Set String caption, @Nullable @Set String fullCaption, @Set @Nullable String shortCut,
44
               @Nullable @Set String remark, String code, String dictCode) throws SQLException;
45
46
}

+ 106 - 0
src/main/java/com/ekexiu/project/system/po/DictItem.java

@ -0,0 +1,106 @@
1
package com.ekexiu.project.system.po;
2
3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7
8
/**
9
 * Created by TT on 2019/5/30.
10
 */
11
@PrimaryKey({"dictCode", "code"})
12
@Table(descp = "数据字典表", value = "SYS_DICT")
13
public class DictItem {
14
    private String code;
15
    private String dictCode;
16
    private String bcode;
17
    private String caption;
18
    private String fullCaption;
19
    private String shortCut;
20
    private String remark;
21
    private boolean readonly;
22
    private boolean active;
23
24
    @Column(descp = "字典项编码", value = DE.rtext_de)
25
    public String getCode() {
26
        return code;
27
    }
28
29
    public void setCode(String code) {
30
        this.code = code;
31
    }
32
33
    @Column(descp = "字典项编码(业务编码)", value = DE.Text_de)
34
    public String getBcode() {
35
        return bcode;
36
    }
37
38
    public void setBcode(String bcode) {
39
        this.bcode = bcode;
40
    }
41
42
    @Column(descp = "字典编码", value = DE.rtext_de)
43
    public String getDictCode() {
44
        return dictCode;
45
    }
46
47
    public void setDictCode(String dictCode) {
48
        this.dictCode = dictCode;
49
    }
50
51
    @Column(descp = "字典项显示", value = DE.text_de)
52
    public String getCaption() {
53
        return caption;
54
    }
55
56
    public void setCaption(String caption) {
57
        this.caption = caption;
58
    }
59
60
    @Column(descp = "字典项显示(全)", value = DE.Text_de)
61
    public String getFullCaption() {
62
        return fullCaption;
63
    }
64
65
    public void setFullCaption(String fullCaption) {
66
        this.fullCaption = fullCaption;
67
    }
68
69
    @Column(descp = "助记码", value = DE.Text_de)
70
    public String getShortCut() {
71
        return shortCut;
72
    }
73
74
    public void setShortCut(String shortCut) {
75
        this.shortCut = shortCut;
76
    }
77
78
    @Column(descp = "备注", value = DE.Text_de)
79
    public String getRemark() {
80
        return remark;
81
    }
82
83
    public void setRemark(String remark) {
84
        this.remark = remark;
85
    }
86
87
    @Column(descp = "是否只读", value = DE.boolean_de)
88
    public boolean isReadonly() {
89
        return readonly;
90
    }
91
92
    public void setReadonly(boolean readonly) {
93
        this.readonly = readonly;
94
    }
95
96
    @Column(descp = "是否有效", value = DE.boolean_de)
97
    public boolean isActive() {
98
        return active;
99
    }
100
101
    public void setActive(boolean active) {
102
        this.active = active;
103
    }
104
105
106
}

+ 164 - 0
src/main/java/com/ekexiu/project/system/service/DictService.java

@ -0,0 +1,164 @@
1
package com.ekexiu.project.system.service;
2
3
4
import com.ekexiu.project.system.dao.DictDao;
5
import com.ekexiu.project.system.po.DictItem;
6
import org.jfw.apt.annotation.Autowrie;
7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.web.annotation.Path;
9
import org.jfw.apt.web.annotation.operate.Get;
10
import org.jfw.apt.web.annotation.operate.Post;
11
import org.jfw.apt.web.annotation.param.AfterCommit;
12
import org.jfw.apt.web.annotation.param.JdbcConn;
13
14
import java.sql.Connection;
15
import java.sql.SQLException;
16
import java.util.Collections;
17
import java.util.HashMap;
18
import java.util.LinkedList;
19
import java.util.List;
20
21
@Path("/dict")
22
public class DictService {
23
	private static final HashMap<String, List<DictItem>> dictCache = new HashMap<String, List<DictItem>>();
24
	private static final List<DictItem> Empty_DICT = Collections.emptyList();
25
26
	@Autowrie
27
	private DictDao dictDao;
28
29
	public DictDao getDictDao() {
30
		return dictDao;
31
	}
32
33
	public void setDictDao(DictDao dictDao) {
34
		this.dictDao = dictDao;
35
	}
36
37
	@Path("/load")
38
	@Get
39
	public void load(@JdbcConn Connection con) throws SQLException {
40
		HashMap<String, List<DictItem>> map = new HashMap<String, List<DictItem>>();
41
		List<DictItem> items = this.dictDao.query(con);
42
		for (DictItem item : items) {
43
			List<DictItem> list = map.get(item.getDictCode());
44
			if (list == null) {
45
				list = new LinkedList<DictItem>();
46
				map.put(item.getDictCode(), list);
47
			}
48
			list.add(item);
49
		}
50
		synchronized(dictCache){
51
			dictCache.clear();
52
			dictCache.putAll(map);
53
		}
54
	}
55
56
	@Path("/items")
57
	@Get
58
	public List<DictItem> query(String dict) {
59
		List<DictItem> ret = null;
60
		synchronized (dictCache) {
61
			ret = dictCache.get(dict);
62
		}
63
		return ret == null ? Empty_DICT : ret;
64
	}
65
66
	@Path("/delete")
67
	@Post
68
	public int delete(@JdbcConn(true) Connection con, final String dict, final String code, @AfterCommit List<Runnable> runs) throws SQLException {
69
		int num = this.dictDao.disable(con, dict, code);
70
		if (num > 0) {
71
			runs.add(new Runnable() {
72
				@Override
73
				public void run() {
74
					synchronized (dictCache) {
75
						List<DictItem> list = dictCache.get(dict);
76
						if (list != null) {
77
							List<DictItem> newlist = new LinkedList<DictItem>();
78
							for (DictItem item : list) {
79
								if (!item.getCode().equals(code)) {
80
									newlist.add(item);
81
								}
82
							}
83
							dictCache.put(dict, newlist);
84
						}
85
					}
86
				}
87
			});
88
		}
89
		return num;
90
	}
91
92
	@Post
93
	@Path("/add")
94
	public void insert(@JdbcConn(true) Connection con, String code, String dict, @Nullable String bcode, String caption, @Nullable String fullCaption,
95
			@Nullable String shortCut, @Nullable String remark, boolean readonly, @AfterCommit List<Runnable> runs) throws SQLException {
96
		final DictItem item = new DictItem();
97
		item.setActive(true);
98
		item.setBcode(bcode);
99
		item.setCaption(caption);
100
		item.setCode(code);
101
		item.setDictCode(dict);
102
		item.setFullCaption(fullCaption);
103
		item.setReadonly(readonly);
104
		item.setRemark(remark);
105
		item.setShortCut(shortCut);
106
		this.dictDao.insert(con, item);
107
		runs.add(new Runnable() {
108
			@Override
109
			public void run() {
110
				synchronized (dictCache) {
111
					List<DictItem> newlist = new LinkedList<DictItem>();
112
					List<DictItem> list = dictCache.get(item.getDictCode());
113
					if (list != null) {
114
						newlist.addAll(list);
115
					}
116
					newlist.add(item);
117
					dictCache.put(item.getDictCode(), newlist);
118
				}
119
			}
120
		});
121
	}
122
123
	@Post
124
	@Path("/modify")
125
	public int update(@JdbcConn(true) Connection con, String code, String dict, @Nullable String bcode, String caption, @Nullable String fullCaption,
126
			@Nullable String shortCut, @Nullable String remark, @AfterCommit List<Runnable> runs) throws SQLException {
127
		int num = this.dictDao.update(con, bcode, caption, fullCaption, shortCut, remark, code, dict);
128
		if (num > 0) {
129
			final DictItem item = new DictItem();
130
			item.setActive(true);
131
			item.setBcode(bcode);
132
			item.setCaption(caption);
133
			item.setCode(code);
134
			item.setDictCode(dict);
135
			item.setFullCaption(fullCaption);
136
			item.setReadonly(false);
137
			item.setRemark(remark);
138
			item.setShortCut(shortCut);
139
140
			runs.add(new Runnable() {
141
				@Override
142
				public void run() {
143
					synchronized (dictCache) {
144
						List<DictItem> newlist = new LinkedList<DictItem>();
145
						List<DictItem> list = dictCache.get(item.getDictCode());
146
						if (list != null) {
147
							for (DictItem nitem : list) {
148
								if (!nitem.getCode().equals(item.getCode())) {
149
									newlist.add(nitem);
150
								}
151
							}
152
						}
153
						newlist.add(item);
154
						dictCache.put(item.getDictCode(), newlist);
155
					}
156
				}
157
			});
158
159
		}
160
		return num;
161
162
	}
163
164
}

+ 10 - 0
src/main/java/com/ekexiu/project/system/service/SysService.java

@ -0,0 +1,10 @@
1
package com.ekexiu.project.system.service;
2
3
import org.jfw.apt.web.annotation.Path;
4
5
/**
6
 * Created by TT on 2019/6/5.
7
 */
8
@Path("/sys")
9
public class SysService {
10
}

+ 123 - 0
src/main/java/com/ekexiu/project/system/vo/SessionHospital.java

@ -0,0 +1,123 @@
1
package com.ekexiu.project.system.vo;
2
3
import org.jfw.util.auth.AuthUser;
4
5
/**
6
 * Created by TT on 2019/5/30.
7
 */
8
public class SessionHospital implements AuthUser {
9
    private String id;
10
    private String account;
11
    private String name;
12
    private String level;
13
    private String subLevel;
14
    private String type;
15
    private String phone;
16
    private String location;
17
    private String addr;
18
    private String desc;
19
    private String image;
20
    private boolean active;
21
22
    @Override
23
    public boolean hasAuthority(int i) {
24
        return false;
25
    }
26
27
    @Override
28
    public String getId() {
29
        return id;
30
    }
31
32
    public void setId(String id) {
33
        this.id = id;
34
    }
35
36
    public String getAccount() {
37
        return account;
38
    }
39
40
    public void setAccount(String account) {
41
        this.account = account;
42
    }
43
44
    public String getName() {
45
        return name;
46
    }
47
48
    public void setName(String name) {
49
        this.name = name;
50
    }
51
52
    public String getLevel() {
53
        return level;
54
    }
55
56
    public void setLevel(String level) {
57
        this.level = level;
58
    }
59
60
    public String getSubLevel() {
61
        return subLevel;
62
    }
63
64
    public void setSubLevel(String subLevel) {
65
        this.subLevel = subLevel;
66
    }
67
68
    public String getType() {
69
        return type;
70
    }
71
72
    public void setType(String type) {
73
        this.type = type;
74
    }
75
76
    public String getPhone() {
77
        return phone;
78
    }
79
80
    public void setPhone(String phone) {
81
        this.phone = phone;
82
    }
83
84
    public String getLocation() {
85
        return location;
86
    }
87
88
    public void setLocation(String location) {
89
        this.location = location;
90
    }
91
92
    public String getAddr() {
93
        return addr;
94
    }
95
96
    public void setAddr(String addr) {
97
        this.addr = addr;
98
    }
99
100
    public String getDesc() {
101
        return desc;
102
    }
103
104
    public void setDesc(String desc) {
105
        this.desc = desc;
106
    }
107
108
    public String getImage() {
109
        return image;
110
    }
111
112
    public void setImage(String image) {
113
        this.image = image;
114
    }
115
116
    public boolean isActive() {
117
        return active;
118
    }
119
120
    public void setActive(boolean active) {
121
        this.active = active;
122
    }
123
}

+ 37 - 0
src/main/resources/project.properties

@ -0,0 +1,37 @@
1
dataSource=com.alibaba.druid.pool.DruidDataSource
2
#数据库连接地址、名称、密码
3
dataSource.url=jdbc:postgresql://192.168.3.233:5432/medical_share
4
dataSource.username=postgres
5
dataSource.password=postgres
6
#连接池启动时的初始值(初始化连接)
7
dataSource.initialSize::int=1
8
#最小空闲连接值
9
dataSource.minIdle::int=1 
10
#连接池的最大值(最大连接数量)
11
dataSource.maxActive::int=1
12
#超时等待时间(maxWait代表当Connection用尽了,多久之后进行回收丢失连接)
13
dataSource.maxWait::long=60000
14
#连接超时任务的时间间隔
15
dataSource.timeBetweenEvictionRunsMillis::long=60000
16
#连接的超时时间
17
dataSource.minEvictableIdleTimeMillis::long=300000  
18
#用来验证从连接池取出的连接
19
dataSource.validationQuery=SELECT 1  
20
#指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败则连接将被从池中去除
21
dataSource.testWhileIdle::boolean=true
22
#在从池中取出连接前进行检验,如果检验失败则从池中去除连接并尝试取出另一个
23
dataSource.testOnBorrow::boolean=true
24
#指明是否在归还到池中前进行检验
25
dataSource.testOnReturn::boolean=true   
26
#开启池的prepared statement 池功能
27
dataSource.poolPreparedStatements::boolean=true 
28
#statement池能够同时分配的打开的statements的最大数量
29
dataSource.maxPoolPreparedStatementPerConnectionSize::int=20
30
#默认的SQL语句自动提交状态(开启或关闭)设置由连接池本身设置(false由连接池定)
31
dataSource.defaultAutoCommit::boolean=false
32
33
34
com_ekexiu_project_msconsole_system_service_CommonUtilService.rootPath=http://192.168.3.233:86
35
com_ekexiu_project_msconsole_system_service_CommonUtilService.hospitalPath::java.io.File=/medical/data/hospital/logo
36
com_ekexiu_project_msconsole_system_service_CommonUtilService.doctorPath::java.io.File=/medical/data/doctor/logo
37
com_ekexiu_project_msconsole_system_service_CommonUtilService.instrumentPath::java.io.File=/medical/data/instrument/logo

+ 29 - 0
src/main/webapp/WEB-INF/web.xml

@ -0,0 +1,29 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
3
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
5
         version="4.0">
6
7
    <servlet>
8
        <servlet-name>ajax</servlet-name>
9
        <servlet-class>org.jfw.web.servlet.core.FilenameConfigServlet</servlet-class>
10
        <init-param>
11
            <param-name>prefixLen</param-name>
12
            <param-value>12</param-value>
13
        </init-param>
14
        <init-param>
15
            <param-name>viewType</param-name>
16
            <param-value>1</param-value>
17
        </init-param>
18
        <init-param>
19
            <param-name>configFileName</param-name>
20
            <param-value>beanConfig.properties,project.properties</param-value>
21
        </init-param>
22
        <load-on-startup>1</load-on-startup>
23
    </servlet>
24
25
    <servlet-mapping>
26
        <servlet-name>ajax</servlet-name>
27
        <url-pattern>/ajax/*</url-pattern>
28
    </servlet-mapping>
29
</web-app>