Explorar el Código

Merge branch 'KeyWord' into Next

XMTT %!s(int64=7) %!d(string=hace) años
padre
commit
09ee12e0a2

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

@ -0,0 +1,25 @@
1
package com.ekexiu.console.system.dao;
2
3
import com.ekexiu.console.system.po.OrgKeyWord;
4
import org.jfw.apt.orm.annotation.dao.Batch;
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.operator.DeleteWith;
8
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
9
10
import java.sql.Connection;
11
import java.sql.SQLException;
12
13
/**
14
 * Created by TT on 2017/8/10.
15
 */
16
@DAO
17
public interface OrgKeyWordDao {
18
    @Insert
19
    @Batch
20
    int[] insert(Connection con, OrgKeyWord[] okws)throws SQLException;
21
22
    @DeleteWith
23
    @From(OrgKeyWord.class)
24
    int delete(Connection con,String id)throws SQLException;
25
}

+ 27 - 0
src/main/java/com/ekexiu/console/system/dao/ProKeyWordDao.java

@ -0,0 +1,27 @@
1
package com.ekexiu.console.system.dao;
2
3
import com.ekexiu.console.system.po.ProKeyWord;
4
import org.jfw.apt.orm.annotation.dao.Batch;
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.operator.DeleteWith;
8
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
9
10
import java.sql.Connection;
11
import java.sql.SQLException;
12
13
/**
14
 * Created by TT on 2017/8/10.
15
 */
16
@DAO
17
public interface ProKeyWordDao {
18
19
    @Insert
20
    @Batch
21
    int[] insert(Connection con, ProKeyWord[] pkw) throws SQLException;
22
23
    @DeleteWith
24
    @From(ProKeyWord.class)
25
    int delete(Connection con, String id) throws SQLException;
26
27
}

+ 33 - 0
src/main/java/com/ekexiu/console/system/po/OrgKeyWord.java

@ -0,0 +1,33 @@
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.enums.DE;
6
7
/**
8
 * Created by TT on 2017/8/10.
9
 */
10
@Table
11
public class OrgKeyWord {
12
13
    private String id;
14
    private String kw;
15
16
    @Column(DE.id_32)
17
    public String getId() {
18
        return id;
19
    }
20
21
    public void setId(String id) {
22
        this.id = id;
23
    }
24
25
    @Column(DE.text_de)
26
    public String getKw() {
27
        return kw;
28
    }
29
30
    public void setKw(String kw) {
31
        this.kw = kw;
32
    }
33
}

+ 34 - 0
src/main/java/com/ekexiu/console/system/po/ProKeyWord.java

@ -0,0 +1,34 @@
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.enums.DE;
6
7
/**
8
 * Created by TT on 2017/8/10.
9
 */
10
@Table
11
public class ProKeyWord {
12
13
    private String id;
14
    private String kw;
15
16
    @Column(DE.id_32)
17
    public String getId() {
18
        return id;
19
    }
20
21
    public void setId(String id) {
22
        this.id = id;
23
    }
24
25
    @Column(DE.text_de)
26
    public String getKw() {
27
        return kw;
28
    }
29
30
    public void setKw(String kw) {
31
        this.kw = kw;
32
    }
33
34
}

+ 90 - 0
src/main/java/com/ekexiu/console/system/service/KeyWordService.java

@ -0,0 +1,90 @@
1
package com.ekexiu.console.system.service;
2
3
import com.ekexiu.console.system.dao.OrgKeyWordDao;
4
import com.ekexiu.console.system.dao.ProKeyWordDao;
5
import com.ekexiu.console.system.po.OrgKeyWord;
6
import com.ekexiu.console.system.po.ProKeyWord;
7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.annotation.Bean;
9
10
import java.sql.Connection;
11
import java.sql.SQLException;
12
import java.util.Collections;
13
import java.util.HashSet;
14
15
/**
16
 * Created by TT on 2017/8/10.
17
 */
18
@Bean
19
public class KeyWordService {
20
21
    @Autowrie
22
    private ProKeyWordDao proKeyWordDao;
23
    @Autowrie
24
    private OrgKeyWordDao orgKeyWordDao;
25
26
    public ProKeyWordDao getProKeyWordDao() {
27
        return proKeyWordDao;
28
    }
29
30
    public void setProKeyWordDao(ProKeyWordDao proKeyWordDao) {
31
        this.proKeyWordDao = proKeyWordDao;
32
    }
33
34
    public OrgKeyWordDao getOrgKeyWordDao() {
35
        return orgKeyWordDao;
36
    }
37
38
    public void setOrgKeyWordDao(OrgKeyWordDao orgKeyWordDao) {
39
        this.orgKeyWordDao = orgKeyWordDao;
40
    }
41
42
    public void refreshProfessor(Connection con, String id, String[] kws) throws SQLException {
43
        proKeyWordDao.delete(con, id);
44
        if (kws != null && kws.length > 0) {
45
            ProKeyWord[] okws = new ProKeyWord[kws.length];
46
            for (int i = 0; i < kws.length; ++i) {
47
                ProKeyWord okw = new ProKeyWord();
48
                okw.setId(id);
49
                okw.setKw(kws[i]);
50
                okws[i] = okw;
51
            }
52
            proKeyWordDao.insert(con, okws);
53
        }
54
    }
55
56
    public void refreshOrg(Connection con, String id, String[] kws) throws SQLException {
57
        orgKeyWordDao.delete(con, id);
58
        if (kws != null && kws.length > 0) {
59
            OrgKeyWord[] okws = new OrgKeyWord[kws.length];
60
            for (int i = 0; i < kws.length; ++i) {
61
                OrgKeyWord okw = new OrgKeyWord();
62
                okw.setId(id);
63
                okw.setKw(kws[i]);
64
                okws[i] = okw;
65
            }
66
            orgKeyWordDao.insert(con, okws);
67
        }
68
    }
69
70
    public static String[] splitKeyWord(String kws) {
71
        if (kws == null || kws.trim().length() == 0) return null;
72
        kws = kws.trim();
73
        String[] s = kws.split(",");
74
        HashSet<String> result = new HashSet<String>();
75
        Collections.addAll(result, s);
76
        result.remove("");
77
78
        return result.isEmpty() ? null : result.toArray(new String[result.size()]);
79
80
    }
81
82
    public static void main(String[] args) {
83
        String s = ",asd,asd,dsa,dsa,we,we,xmtt,ttmx ,ttmx,";
84
        String[] s1 = splitKeyWord(s);
85
        for (String aS1 : s1) {
86
            System.out.println(aS1);
87
        }
88
    }
89
90
}

+ 23 - 0
src/main/java/com/ekexiu/console/system/service/OrgService.java

@ -67,6 +67,8 @@ public class OrgService extends com.ekexiu.console.service.Upload {
67 67
    private OrgUserDao orgUserDao;
68 68
    @Autowrie
69 69
    private OrgRecordDao orgRecordDao;
70
    @Autowrie
71
    private KeyWordService keyWordService;
70 72

71 73
    public OrgRecordDao getOrgRecordDao() {
72 74
        return orgRecordDao;
@ -157,6 +159,14 @@ public class OrgService extends com.ekexiu.console.service.Upload {
157 159
        this.orgDao = orgDao;
158 160
    }
159 161

162
    public KeyWordService getKeyWordService() {
163
        return keyWordService;
164
    }
165

166
    public void setKeyWordService(KeyWordService keyWordService) {
167
        this.keyWordService = keyWordService;
168
    }
169

160 170
    public int getLargeHeadPhotoWidth() {
161 171
        return largeHeadPhotoWidth;
162 172
    }
@ -427,6 +437,19 @@ public class OrgService extends com.ekexiu.console.service.Upload {
427 437
        }else {
428 438
            this.orgRecordDao.updateModifier(con, orgn.getId(), user.getId(),DateUtil.formatDateTime(System.currentTimeMillis()));
429 439
        }
440

441
        Organization no = this.orgDao.query(con, orgn.getId());
442
        if(no!=null && "1".equals(no.getIsJoin())){
443
            String s = no.getSubject();
444
            String in = no.getIndustry();
445
            String kw = s==null?"":s.trim();
446
            kw = kw + (in==null?"":(","+in.trim()));
447
            this.keyWordService.refreshOrg(con,orgn.getId(),KeyWordService.splitKeyWord(kw));
448
        }else{
449
            this.keyWordService.refreshOrg(con,orgn.getId(),null);
450
        }
451

452

430 453
    }
431 454

432 455
    @Post

+ 13 - 0
src/main/java/com/ekexiu/console/system/service/UserInfoService.java

@ -46,6 +46,8 @@ public class UserInfoService {
46 46
    private ProfessorEduBgDao professorEduBgDao;
47 47
    @Autowrie
48 48
    private ProfessorService professorService;
49
    @Autowrie
50
    private KeyWordService keyWordService;
49 51
50 52
    public PartTimeJobDao getPartTimeJobDao() {
51 53
        return partTimeJobDao;
@ -115,6 +117,14 @@ public class UserInfoService {
115 117
        this.userInfoDao = userInfoDao;
116 118
    }
117 119
120
    public KeyWordService getKeyWordService() {
121
        return keyWordService;
122
    }
123
124
    public void setKeyWordService(KeyWordService keyWordService) {
125
        this.keyWordService = keyWordService;
126
    }
127
118 128
    @Path("/insert")
119 129
    @Put
120 130
    public void insert(@JdbcConn(true) Connection con, @RequestBody UserInfo userInfo, @LoginUser ConsoleAuthUser user) throws SQLException {
@ -239,6 +249,8 @@ public class UserInfoService {
239 249
                this.luserDao.insert(con, luser);
240 250
241 251
                Professor professor = new Professor();
252
                String subject = (String) userInfo.get("subject");
253
                String industry = (String) userInfo.get("industry");
242 254
                professor.setId(userInfo.getId());
243 255
                professor.setName(userInfo.getName());
244 256
                professor.setEmail((String) userInfo.get("pEmail"));
@ -276,6 +288,7 @@ public class UserInfoService {
276 288
                }
277 289
                professor.setProfessorState(0);
278 290
                this.professorService.insert(con, professor, userInfo.getOrgName());
291
                this.keyWordService.refreshProfessor(con, id, KeyWordService.splitKeyWord(subject + "," + industry));
279 292
280 293
                ArrayList<String> areas = (ArrayList<String>) userInfo.get("researchArea");
281 294
                if (areas != null) {