XMTT vor 7 Jahren
Ursprung
Commit
7b79f3a4c2

+ 23 - 0
src/main/java/com/ekexiu/console/system/dao/ResearchAreaDao.java

@ -2,10 +2,17 @@ package com.ekexiu.console.system.dao;
2 2
3 3
import com.ekexiu.console.system.po.ResearchArea;
4 4
import org.jfw.apt.orm.annotation.dao.DAO;
5
import org.jfw.apt.orm.annotation.dao.method.From;
6
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
7
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
5 8
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
9
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
10
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
11
import org.jfw.apt.orm.annotation.dao.param.Set;
6 12
7 13
import java.sql.Connection;
8 14
import java.sql.SQLException;
15
import java.util.List;
9 16
10 17
/**
11 18
 * Created by TT on 2017/7/13.
@ -14,4 +21,20 @@ import java.sql.SQLException;
14 21
public interface ResearchAreaDao {
15 22
    @Insert
16 23
    int insert(Connection con, ResearchArea area) throws SQLException;
24
25
    @OrderBy("ORDER BY COUNT DESC,SORT_NUM ASC")
26
    @SelectList
27
    List<ResearchArea> query(Connection con, String professorId) throws SQLException;
28
29
    @DeleteWith
30
    @From(ResearchArea.class)
31
    int delete(Connection con, String professorId) throws SQLException;
32
33
    @DeleteWith
34
    @From(ResearchArea.class)
35
    int delete(Connection con, String professorId, String caption) throws SQLException;
36
37
    @UpdateWith
38
    @From(ResearchArea.class)
39
    int updateDescp(Connection con, String professorId, String caption, @Set String descp, @Set int sortNum) throws SQLException;
17 40
}

+ 25 - 0
src/main/java/com/ekexiu/console/system/dao/ResearchAreaLogDao.java

@ -0,0 +1,25 @@
1
package com.ekexiu.console.system.dao;
2
3
import com.ekexiu.console.system.po.ResearchAreaLog;
4
import org.jfw.apt.orm.annotation.dao.DAO;
5
import org.jfw.apt.orm.annotation.dao.method.From;
6
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
7
8
import java.sql.Connection;
9
import java.sql.SQLException;
10
11
/**
12
 * Created by TT on 2017/8/17.
13
 */
14
@DAO
15
public abstract class ResearchAreaLogDao {
16
17
    @DeleteWith
18
    @From(ResearchAreaLog.class)
19
    public abstract int delete(Connection con, String professorId) throws SQLException;
20
21
    @DeleteWith
22
    @From(ResearchAreaLog.class)
23
    public abstract int delete(Connection con, String professorId, String caption) throws SQLException;
24
25
}

+ 14 - 3
src/main/java/com/ekexiu/console/system/po/Professor.java

@ -12,6 +12,7 @@ import org.jfw.apt.orm.core.defaultImpl.WIntHandler;
12 12
import org.jfw.apt.orm.core.enums.DE;
13 13
14 14
import java.math.BigDecimal;
15
import java.util.List;
15 16
16 17
/**
17 18
 * Created by TT on 2017/4/6.
@ -56,6 +57,8 @@ public class Professor implements CreateTimeSupported,ModifyTimeSupported {
56 57
    private Integer professorState;
57 58
    private Integer sortFirst;
58 59
    private long pageViews;
60
61
    private List<ResearchArea> researchAreas;
59 62
    
60 63
    @Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(1)",renewable=false)
61 64
@ -103,7 +106,7 @@ public class Professor implements CreateTimeSupported,ModifyTimeSupported {
103 106
        this.office = office;
104 107
    }
105 108
106
    @Column(handlerClass=StringHandler.class,dbType="TEXT",insertable=true,nullable=true,renewable=false,queryable=true)
109
    @Column(handlerClass=StringHandler.class,dbType="TEXT",insertable=true,nullable=true,renewable=true,queryable=true)
107 110
    public String getSubject() {
108 111
        return subject;
109 112
    }
@ -111,7 +114,7 @@ public class Professor implements CreateTimeSupported,ModifyTimeSupported {
111 114
    public void setSubject(String subject) {
112 115
        this.subject = subject;
113 116
    }
114
    @Column(handlerClass=StringHandler.class,dbType="TEXT",insertable=true,nullable=true,renewable=false,queryable=true)
117
    @Column(handlerClass=StringHandler.class,dbType="TEXT",insertable=true,nullable=true,renewable=true,queryable=true)
115 118
    public String getIndustry() {
116 119
        return industry;
117 120
    }
@ -202,7 +205,7 @@ public class Professor implements CreateTimeSupported,ModifyTimeSupported {
202 205
    public void setName(String name) {
203 206
        this.name = name;
204 207
    }
205
    @Column(handlerClass=StringHandler.class,dbType="TEXT",insertable=true,nullable=true,renewable=false,queryable=true)
208
    @Column(handlerClass=StringHandler.class,dbType="TEXT",insertable=true,nullable=true,renewable=true,queryable=true)
206 209
    public String getDescp() {
207 210
        return descp;
208 211
    }
@ -325,5 +328,13 @@ public class Professor implements CreateTimeSupported,ModifyTimeSupported {
325 328
    public void setPageViews(long pageViews) {
326 329
        this.pageViews = pageViews;
327 330
    }
331
332
    public List<ResearchArea> getResearchAreas() {
333
        return researchAreas;
334
    }
335
336
    public void setResearchAreas(List<ResearchArea> researchAreas) {
337
        this.researchAreas = researchAreas;
338
    }
328 339
}
329 340

+ 55 - 0
src/main/java/com/ekexiu/console/system/po/ResearchAreaLog.java

@ -0,0 +1,55 @@
1
package com.ekexiu.console.system.po;
2
3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
6
import org.jfw.apt.orm.core.enums.DE;
7
8
/**
9
 * Created by TT on 2017/8/17.
10
 */
11
@Table
12
public class ResearchAreaLog {
13
    private String professorId;
14
    private String caption;
15
    private String opreteProfessorId;
16
    private String createTime;
17
18
    @Column(DE.id_32)
19
    public String getOpreteProfessorId() {
20
        return opreteProfessorId;
21
    }
22
23
    public void setOpreteProfessorId(String opreteProfessorId) {
24
        this.opreteProfessorId = opreteProfessorId;
25
    }
26
27
    @Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = false)
28
    public String getCreateTime() {
29
        return createTime;
30
    }
31
32
    public void setCreateTime(String createTime) {
33
        this.createTime = createTime;
34
    }
35
36
    @Column(DE.id_32)
37
    public String getProfessorId() {
38
        return professorId;
39
    }
40
41
    public void setProfessorId(String orgId) {
42
        this.professorId = orgId;
43
    }
44
45
    @Column(DE.string_de)
46
    public String getCaption() {
47
        return caption;
48
    }
49
50
    public void setCaption(String catpion) {
51
        this.caption = catpion;
52
    }
53
54
55
}

+ 77 - 23
src/main/java/com/ekexiu/console/system/service/ProfessorService.java

@ -3,6 +3,7 @@ package com.ekexiu.console.system.service;
3 3
import com.ekexiu.console.system.dao.LuserDao;
4 4
import com.ekexiu.console.system.dao.OrgDao;
5 5
import com.ekexiu.console.system.dao.ProfessorDao;
6
import com.ekexiu.console.system.dao.ResearchAreaDao;
6 7
import com.ekexiu.console.system.po.Luser;
7 8
import com.ekexiu.console.system.po.Professor;
8 9
import com.ekexiu.console.system.pojo.ProfessorInfo;
@ -46,6 +47,12 @@ public class ProfessorService {
46 47
    private OrgService orgService;
47 48
    @Autowrie
48 49
    private LuserDao luserDao;
50
    @Autowrie
51
    private KeyWordService keyWordService;
52
    @Autowrie
53
    private ResearchAreaDao researchAreaDao;
54
    @Autowrie
55
    private ResearchAreaService researchAreaService;
49 56
50 57
    public OrgService getOrgService() {
51 58
        return orgService;
@ -79,6 +86,30 @@ public class ProfessorService {
79 86
        this.luserDao = luserDao;
80 87
    }
81 88
89
    public KeyWordService getKeyWordService() {
90
        return keyWordService;
91
    }
92
93
    public void setKeyWordService(KeyWordService keyWordService) {
94
        this.keyWordService = keyWordService;
95
    }
96
97
    public ResearchAreaDao getResearchAreaDao() {
98
        return researchAreaDao;
99
    }
100
101
    public void setResearchAreaDao(ResearchAreaDao researchAreaDao) {
102
        this.researchAreaDao = researchAreaDao;
103
    }
104
105
    public ResearchAreaService getResearchAreaService() {
106
        return researchAreaService;
107
    }
108
109
    public void setResearchAreaService(ResearchAreaService researchAreaService) {
110
        this.researchAreaService = researchAreaService;
111
    }
112
82 113
    @Post
83 114
    @Path
84 115
    public String insert(@JdbcConn(true) Connection con, Professor professor, @Nullable String orgName)
@ -102,18 +133,39 @@ public class ProfessorService {
102 133
103 134
    @Put
104 135
    @Path
105
    public void update(@JdbcConn(true) Connection con, @RequestBody Professor professor) throws SQLException,JfwBaseException {
136
    public void update(@JdbcConn(true) Connection con, @RequestBody ProfessorInfo professor) throws SQLException, JfwBaseException, IOException {
106 137
        UserDetail userDetail = this.professorDao.queryDetail(con, professor.getId());
107 138
        if (!Objects.equals(userDetail.getActiveStatus(), "1")) {
139
            if (professor.getOrgName() != null) {
140
                if (null != this.orgDao.queryByName(con, professor.getOrgName())) {
141
                    professor.setOrgId(this.orgDao.queryByName(con, professor.getOrgName()));
142
                } else {
143
                    professor.setOrgId(this.orgService.createOrganization(con, professor.getOrgName()));
144
                }
145
            }
108 146
            this.professorDao.update(con, professor);
109
        }else {
147
            if (professor.getResearchAreas() != null && !professor.getResearchAreas().isEmpty()) {
148
                this.researchAreaService.saveResearchArea(con, professor.getResearchAreas());
149
            } else {
150
                this.researchAreaService.delete(con, professor.getId());
151
            }
152
            Professor p = this.professorDao.query(con, professor.getId());
153
            String subject = p.getSubject();
154
            if (subject == null) {
155
                subject = "";
156
            }
157
            String industry = p.getIndustry();
158
            if (industry == null)
159
                industry = "";
160
            this.keyWordService.refreshProfessor(con, professor.getId(), KeyWordService.splitKeyWord(subject + "," + industry));
161
        } else {
110 162
            throw new JfwBaseException(50000, "只能修改未激活用户信息");
111 163
        }
112 164
    }
113 165
114 166
    @Get
115 167
    @Path("/pq")
116
    public PageQueryResult<ProfessorInfo> pageQuery(@JdbcConn Connection con, @Nullable String enter,@Nullable String orgName, @Nullable String name, @Nullable Integer professorState, @Nullable String bt, @Nullable String et, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
168
    public PageQueryResult<ProfessorInfo> pageQuery(@JdbcConn Connection con, @Nullable String enter, @Nullable String orgName, @Nullable String name, @Nullable Integer professorState, @Nullable String bt, @Nullable String et, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
117 169
        String oName = null;
118 170
        if (orgName != null) {
119 171
            oName = "%" + orgName + "%";
@ -122,27 +174,27 @@ public class ProfessorService {
122 174
        if (name != null) {
123 175
            pname = "%" + name + "%";
124 176
        }
125
        if (et!=null) {
177
        if (et != null) {
126 178
            et = et + "235959";
127 179
        }
128
        return this.professorDao.pageQuery(con,enter, oName, pname, professorState, bt, et, pageSize, pageNo);
180
        return this.professorDao.pageQuery(con, enter, oName, pname, professorState, bt, et, pageSize, pageNo);
129 181
    }
130 182
131 183
    @Get
132 184
    @Path("/id/{id}")
133
    public ProfessorInfo query(@JdbcConn Connection con,@PathVar String id) throws SQLException {
185
    public ProfessorInfo query(@JdbcConn Connection con, @PathVar String id) throws SQLException {
134 186
        return this.professorDao.query(con, id);
135 187
    }
136 188
137 189
    @Post
138 190
    @Path("/sortFirst")
139
    public void updateSortFirst(@JdbcConn(true) Connection con,String id,Integer sortFirst)throws SQLException {
191
    public void updateSortFirst(@JdbcConn(true) Connection con, String id, Integer sortFirst) throws SQLException {
140 192
        this.professorDao.updateSortFirst(con, id, sortFirst);
141 193
    }
142 194
143 195
    @Get
144 196
    @Path("/pqperson")
145
    public PageQueryResult<ProfessorInfo> pageQueryPerson(@JdbcConn Connection con, @LoginUser ConsoleAuthUser cau,@Nullable String orgName, @Nullable String name, @Nullable Integer professorState,@Nullable String bt, @Nullable String et, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
197
    public PageQueryResult<ProfessorInfo> pageQueryPerson(@JdbcConn Connection con, @LoginUser ConsoleAuthUser cau, @Nullable String orgName, @Nullable String name, @Nullable Integer professorState, @Nullable String bt, @Nullable String et, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
146 198
        String oName = null;
147 199
        if (orgName != null) {
148 200
            oName = "%" + orgName + "%";
@ -155,12 +207,12 @@ public class ProfessorService {
155 207
            bt = bt + "000000";
156 208
        if (et != null)
157 209
            et = et + "235959";
158
        return this.professorDao.pageQueryPerson(con,cau.getId(),oName, pname, professorState, bt, et, pageSize, pageNo);
210
        return this.professorDao.pageQueryPerson(con, cau.getId(), oName, pname, professorState, bt, et, pageSize, pageNo);
159 211
    }
160 212
161 213
    @Post
162 214
    @Path("/check")
163
    public void check(@JdbcConn(true) Connection con, String[] ids, Integer professorState, Integer authType, Integer authStatusExpert)throws SQLException {
215
    public void check(@JdbcConn(true) Connection con, String[] ids, Integer professorState, Integer authType, Integer authStatusExpert) throws SQLException {
164 216
        this.professorDao.updateProfessorState(con, ids, professorState);
165 217
        this.professorDao.updateAuthType(con, ids, authType);
166 218
        this.professorDao.updateAuthStatusExpert(con, ids, authStatusExpert);
@ -168,23 +220,23 @@ public class ProfessorService {
168 220
169 221
    @Get
170 222
    @Path("/getName/{id}")
171
    public String getName(@JdbcConn Connection con,@PathVar String id) throws SQLException {
223
    public String getName(@JdbcConn Connection con, @PathVar String id) throws SQLException {
172 224
        return this.professorDao.queryById(con, id);
173 225
    }
174 226
175 227
    @Get
176 228
    @Path("/pqUserDetail")
177
    public PageQueryResult<UserDetail> userDetailPageQueryResult(@JdbcConn Connection con, @Nullable String name, @Nullable String activeStatus,@Nullable Integer sendMailStatus,@Nullable String bt, @Nullable String et, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo)throws SQLException {
178
        return this.professorDao.pageQueryUserDetail(con, name == null ? null : "%" + name + "%", activeStatus,sendMailStatus, bt, et, pageSize, pageNo);
229
    public PageQueryResult<UserDetail> userDetailPageQueryResult(@JdbcConn Connection con, @Nullable String name, @Nullable String activeStatus, @Nullable Integer sendMailStatus, @Nullable String bt, @Nullable String et, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
230
        return this.professorDao.pageQueryUserDetail(con, name == null ? null : "%" + name + "%", activeStatus, sendMailStatus, bt, et, pageSize, pageNo);
179 231
    }
180 232
181 233
    @Post
182 234
    @Path("/updateBusinessData")
183
    public void updateBusinessData(@JdbcConn(true) Connection con,String id,@Nullable int authentication,@Nullable int authStatus,@Nullable int authStatusExpert,int sortFirst)throws SQLException{
235
    public void updateBusinessData(@JdbcConn(true) Connection con, String id, @Nullable int authentication, @Nullable int authStatus, @Nullable int authStatusExpert, int sortFirst) throws SQLException {
184 236
        this.professorDao.updateBusinessData(con, id, authentication, authStatus, authStatusExpert, sortFirst);
185
        if (authStatusExpert == 3){
237
        if (authStatusExpert == 3) {
186 238
            this.professorDao.updateAuthType(con, id, 1);
187
        }else {
239
        } else {
188 240
            this.professorDao.updateAuthType(con, id, 0);
189 241
        }
190 242
    }
@ -199,9 +251,9 @@ public class ProfessorService {
199 251
200 252
    @Path("/updateCheck")
201 253
    @Get
202
    public int editCheck(@JdbcConn Connection con,@Nullable String mobile, @Nullable String email,String id) throws SQLException {
254
    public int editCheck(@JdbcConn Connection con, @Nullable String mobile, @Nullable String email, String id) throws SQLException {
203 255
        String luserId = this.luserDao.queryByEmail(con, email);
204
        if ((luserId != null)&&(!Objects.equals(luserId, id))) {
256
        if ((luserId != null) && (!Objects.equals(luserId, id))) {
205 257
            return 2;//该邮箱已被注册
206 258
        }
207 259
        String luserId1 = this.luserDao.queryByPhone(con, mobile);
@ -213,7 +265,7 @@ public class ProfessorService {
213 265
214 266
    @Post
215 267
    @Path("/createAccount")
216
    public void insert(@JdbcConn(true) Connection con,String name, @Nullable String mobile,@Nullable String email)throws SQLException,JfwBaseException {
268
    public void insert(@JdbcConn(true) Connection con, String name, @Nullable String mobile, @Nullable String email) throws SQLException, JfwBaseException {
217 269
218 270
        String luserId = this.luserDao.queryByEmail(con, email);
219 271
        if (luserId != null) {
@ -254,9 +306,9 @@ public class ProfessorService {
254 306
255 307
    @Post
256 308
    @Path("/updateAccount")
257
    public void updateAccount(@JdbcConn(true) Connection con,@Nullable String mobile, @Nullable String email,String id) throws SQLException, JfwBaseException {
309
    public void updateAccount(@JdbcConn(true) Connection con, @Nullable String mobile, @Nullable String email, String id) throws SQLException, JfwBaseException {
258 310
        String luserId = this.luserDao.queryByEmail(con, email);
259
        if ((luserId != null)&&(!Objects.equals(luserId, id))) {
311
        if ((luserId != null) && (!Objects.equals(luserId, id))) {
260 312
            throw new JfwBaseException(40001, "该邮箱已被注册");
261 313
        }
262 314
        String luserId1 = this.luserDao.queryByPhone(con, mobile);
@ -268,7 +320,7 @@ public class ProfessorService {
268 320
269 321
    @Get
270 322
    @Path("/luserId/{id}")
271
    public Luser queryAccount(@JdbcConn Connection con, @PathVar String id)throws SQLException {
323
    public Luser queryAccount(@JdbcConn Connection con, @PathVar String id) throws SQLException {
272 324
        Luser luser = this.luserDao.query(con, id);
273 325
        if (luser != null) {
274 326
            luser.setPasswd(null);
@ -279,6 +331,8 @@ public class ProfessorService {
279 331
    @Get
280 332
    @Path("/detail/{id}")
281 333
    public UserDetail queryDetail(@JdbcConn Connection con, @PathVar String id) throws SQLException {
282
        return this.professorDao.queryDetail(con, id);
334
        UserDetail professor = this.professorDao.queryDetail(con, id);
335
        professor.setResearchAreas(this.researchAreaDao.query(con, id));
336
        return professor;
283 337
    }
284 338
}

+ 88 - 0
src/main/java/com/ekexiu/console/system/service/ResearchAreaService.java

@ -0,0 +1,88 @@
1
package com.ekexiu.console.system.service;
2
3
import com.ekexiu.console.system.dao.ResearchAreaDao;
4
import com.ekexiu.console.system.dao.ResearchAreaLogDao;
5
import com.ekexiu.console.system.po.ResearchArea;
6
import org.jfw.apt.annotation.Autowrie;
7
import org.jfw.apt.web.annotation.Path;
8
import org.jfw.apt.web.annotation.operate.Delete;
9
import org.jfw.apt.web.annotation.operate.Put;
10
import org.jfw.apt.web.annotation.param.JdbcConn;
11
import org.jfw.apt.web.annotation.param.PathVar;
12
import org.jfw.apt.web.annotation.param.RequestBody;
13
14
import java.sql.Connection;
15
import java.sql.SQLException;
16
import java.util.List;
17
18
/**
19
 * Created by TT on 2017/8/17.
20
 */
21
@Path("/researchArea")
22
public class ResearchAreaService {
23
24
    @Autowrie
25
    private ResearchAreaDao researchAreaDao;
26
    @Autowrie
27
    private ResearchAreaLogDao researchAreaLogDao;
28
29
    public ResearchAreaDao getResearchAreaDao() {
30
        return researchAreaDao;
31
    }
32
33
    public void setResearchAreaDao(ResearchAreaDao researchAreaDao) {
34
        this.researchAreaDao = researchAreaDao;
35
    }
36
37
    public ResearchAreaLogDao getResearchAreaLogDao() {
38
        return researchAreaLogDao;
39
    }
40
41
    public void setResearchAreaLogDao(ResearchAreaLogDao researchAreaLogDao) {
42
        this.researchAreaLogDao = researchAreaLogDao;
43
    }
44
45
    @Delete
46
    @Path("/{professorId}")
47
    public void delete(@JdbcConn(true) Connection con, @PathVar String professorId) throws SQLException {
48
        this.researchAreaDao.delete(con, professorId);
49
        this.researchAreaLogDao.delete(con, professorId);
50
    }
51
52
    @Put
53
    @Path
54
    public void saveResearchArea(@JdbcConn(true) Connection con, @RequestBody List<ResearchArea> areas) throws SQLException {
55
        String professorId = areas.get(0).getProfessorId();
56
        List<ResearchArea> olds = this.researchAreaDao.query(con, professorId);
57
        int sortNum = 1;
58
        for (ResearchArea area : areas) {
59
            area.setSortNum(sortNum++);
60
            boolean found = false;
61
            for (ResearchArea old : olds) {
62
                if (area.getCaption().equals(old.getCaption())) {
63
                    found = true;
64
                    this.researchAreaDao.updateDescp(con, professorId, area.getCaption(), area.getDescp(), area.getSortNum());
65
                    break;
66
                }
67
            }
68
            if (!found) {
69
                area.setProfessorId(professorId);
70
                this.researchAreaDao.insert(con, area);
71
            }
72
        }
73
        for (ResearchArea old : olds) {
74
            boolean found = false;
75
            for (ResearchArea area : areas) {
76
                if (area.getCaption().equals(old.getCaption())) {
77
                    found = true;
78
                    break;
79
                }
80
            }
81
            if (!found) {
82
                this.researchAreaDao.delete(con, professorId, old.getCaption());
83
                this.researchAreaLogDao.delete(con, professorId, old.getCaption());
84
            }
85
        }
86
    }
87
}
88