XMTT 5 years ago
parent
commit
780751ee2c

+ 56 - 3
src/main/java/com/ekexiu/project/msconsole/department/DepartmentService.java

@ -10,9 +10,15 @@ import org.jfw.apt.web.annotation.operate.Post;
10 10
import org.jfw.apt.web.annotation.param.JdbcConn;
11 11
import org.jfw.util.PageQueryResult;
12 12
import org.jfw.util.StringUtil;
13
import org.jfw.util.jdbc.JdbcUtil;
14
import org.jfw.util.jdbc.PreparedStatementConfig;
13 15
14 16
import java.sql.Connection;
17
import java.sql.PreparedStatement;
15 18
import java.sql.SQLException;
19
import java.util.ArrayList;
20
import java.util.List;
21
import java.util.Map;
16 22
17 23
/**
18 24
 * Created by TT on 2019/5/30.
@ -65,14 +71,61 @@ public class DepartmentService {
65 71
66 72
    @Path("/pq")
67 73
    @Get
68
    public PageQueryResult<Department> pageQuery(@JdbcConn Connection con,@LoginUser SessionUser user, @Nullable Boolean active, @Nullable String name, int pageSize, int pageNo) throws SQLException {
69
        return departmentDao.pageQuery(con,user.getId(), active, name == null ? null : "%" + name + "%", pageSize, pageNo);
74
    public PageQueryResult<Department> pageQuery(@JdbcConn Connection con, @LoginUser SessionUser user, @Nullable Boolean active, @Nullable String name, int pageSize, int pageNo) throws SQLException {
75
        return departmentDao.pageQuery(con, user.getId(), active, name == null ? null : "%" + name + "%", pageSize, pageNo);
70 76
    }
71 77
72 78
    @Path("/checkName")
73 79
    @Get
74
    public Department queryByName(@JdbcConn Connection con,@LoginUser SessionUser user, String name)throws SQLException {
80
    public Department queryByName(@JdbcConn Connection con, @LoginUser SessionUser user, String name) throws SQLException {
75 81
        return departmentDao.queryByName(con, user.getId(), name);
76 82
    }
77 83
84
    @Path("/name")
85
    @Get
86
    public List<TypeaheadItem> queryName(@JdbcConn Connection con, String name, int size) throws SQLException {
87
        if (name != null) {
88
            name = "%" + name + "%";
89
        }
90
        List<TypeaheadItem> ret = new ArrayList<>(size);
91
        final String finalKey = name;
92
        List<Map<String, Object>> typehead = JdbcUtil.queryMaps(con, "SELECT NAME,ID FROM DEPARTMENT WHERE NAME LIKE ? ", new PreparedStatementConfig() {
93
            @Override
94
            public void config(PreparedStatement preparedStatement) throws SQLException {
95
                preparedStatement.setString(1, finalKey);
96
            }
97
        });
98
99
        for (Map<String, Object> map : typehead) {
100
            TypeaheadItem item = new TypeaheadItem();
101
            item.setId((String) map.get("id"));
102
            item.setName((String) map.get("name"));
103
            ret.add(item);
104
        }
105
        return ret;
106
    }
107
108
109
    public static class TypeaheadItem {
110
        private String id;
111
        private String name;
112
113
        public String getId() {
114
            return id;
115
        }
116
117
        public void setId(String id) {
118
            this.id = id;
119
        }
120
121
        public String getName() {
122
            return name;
123
        }
124
125
        public void setName(String name) {
126
            this.name = name;
127
        }
128
129
    }
130
78 131
}

+ 1 - 1
src/main/java/com/ekexiu/project/msconsole/system/service/SysService.java

@ -48,7 +48,7 @@ public class SysService {
48 48
    @Path("/login")
49 49
    @Post
50 50
    public SessionUser login(@JdbcConn Connection con, String account, String pw) throws SQLException, JfwBaseException {
51
        Hospital hospital = hospitalDao.login(con, account, pw);
51
        Hospital hospital = hospitalDao.login(con, account, StringUtil.md5(pw));
52 52
        if (hospital != null) {
53 53
            if (!hospital.isActive()) {
54 54
                throw new JfwBaseException(-60005, "hospital is disabled");

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

@ -31,7 +31,7 @@ dataSource.maxPoolPreparedStatementPerConnectionSize::int=20
31 31
dataSource.defaultAutoCommit::boolean=false
32 32
33 33
34
com_ekexiu_project_msconsole_system_service_CommonUtilService.rootPath=http://192.168.3.233:84
35
com_ekexiu_project_msconsole_system_service_CommonUtilService.hospitalPath::java.io.File=/medical/data/hospitalPath/logo
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 36
com_ekexiu_project_msconsole_system_service_CommonUtilService.doctorPath::java.io.File=/medical/data/doctor/logo
37 37
com_ekexiu_project_msconsole_system_service_CommonUtilService.instrumentPath::java.io.File=/medical/data/instrument/logo