jiapeng 6 years ago
parent
commit
e4d7558878

+ 2 - 2
src/main/java/com/ekexiu/portal/dao/DemandDao.java

@ -84,7 +84,7 @@ public abstract class DemandDao {
84 84
	@Column(handlerClass=IntHandler.class,value="COUNT(1)")
85 85
	@From(Demand.class)
86 86
	@DefaultValue("0")
87
	public abstract int cnt(Connection con,@Nullable @In String[] state,@Nullable String creator,@Nullable String orgId)throws SQLException;
87
	public abstract int cnt(Connection con,@Nullable @In String[] state,@Nullable String creator,@Nullable String orgName)throws SQLException;
88 88
	
89 89
	@SelectOne
90 90
	@Nullable
@ -105,7 +105,7 @@ public abstract class DemandDao {
105 105
	
106 106
	@PageSelect
107 107
	@OrderBy(" ORDER BY STATE ASC,CREATE_TIME DESC")
108
	public abstract PageQueryResult<Demand> pageQuery(Connection con,@Nullable @In String[] state,@Nullable String creator,@Nullable String orgId,int pageSize,int pageNo) throws SQLException;
108
	public abstract PageQueryResult<Demand> pageQuery(Connection con,@Nullable @In String[] state,@Nullable String creator,@Nullable String orgName,int pageSize,int pageNo) throws SQLException;
109 109
	
110 110
	
111 111
	@PageSelect

+ 7 - 0
src/main/java/com/ekexiu/portal/dao/OrgDao.java

@ -176,6 +176,13 @@ public abstract class OrgDao {
176 176
	@Column(handlerClass = StringHandler.class, value = "id")
177 177
	@From(Organization.class)
178 178
	public abstract String queryByName(Connection con, String name) throws SQLException;
179
	
180
	
181
	@Nullable 
182
	@QueryOne
183
	@From(Organization.class)
184
	@Select(Organization.class)
185
	public abstract EditOrganization queryOneByName(Connection con,String name) throws SQLException;
179 186
180 187
	@Nullable
181 188
	@QueryVal

+ 15 - 5
src/main/java/com/ekexiu/portal/platform/PlatformDao.java

@ -21,6 +21,7 @@ import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
21 21
import org.jfw.apt.orm.annotation.dao.param.In;
22 22
import org.jfw.apt.orm.annotation.dao.param.Set;
23 23
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
24
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
24 25
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
25 26
import org.jfw.util.PageQueryResult;
26 27

@ -66,9 +67,6 @@ public interface PlatformDao {
66 67
	@Update
67 68
	int update(Connection con, PlatformInfo pi) throws SQLException;
68 69

69
	@Insert
70
	int insert(Connection con, PlatformOrg org) throws SQLException;
71

72 70
	@Insert
73 71
	int insert(Connection con, ResidentOrg org) throws SQLException;
74 72

@ -172,8 +170,20 @@ public interface PlatformDao {
172 170
	PageQueryResult<ButtedProfessorInfo> queryButtedProfessorInfo(Connection con,
173 171
			@SqlColumn(handlerClass = StringHandler.class, value = { "B.PID=?" }) String pid, int pageSize, int pageNo) throws SQLException;
174 172

173
	@LimitQuery
174
	@OrderBy(cols = { @LimitColumn(value = "time", column = "PTIME", handlerClass = StringHandler.class, asc = false),
175
			@LimitColumn(value = "shareId", handlerClass = LongHandler.class) }, value = "")
176
	List<PlatformWare> queryWare(Connection con, @GroupSqlColumn(handlerClass = StringHandler.class, value = { "WNAME LIKE ?", "KEYWORDS LIKE ?",
177
			"FNAME LIKE ?", "SNAME LIKE ?", "CNT LIKE ?" }) @Nullable String key, String pid, String time, long shareId, int rows) throws SQLException;
178

179
	@LimitQuery
180
	@OrderBy(cols = { @LimitColumn(value = "time", column = "PTIME", handlerClass = StringHandler.class, asc = false),
181
			@LimitColumn(value = "shareId", handlerClass = LongHandler.class) }, value = "")
182
	List<PlatformResource> queryResource(Connection con, @GroupSqlColumn(handlerClass = StringHandler.class, value = { "RNAME LIKE ?", "KEYWORDS LIKE ?",
183
			"FNAME LIKE ?", "SNAME LIKE ?", "CNT LIKE ?" ,"COMP LIKE ?"},isAnd = false) @Nullable String key, String pid, String time, long shareId, int rows) throws SQLException;
184

175 185
	/*
176
	运营系统
186
	 * 运营系统
177 187
	 */
178 188
	@Insert
179 189
	int insert(Connection con, PlatformInfo platformInfo) throws SQLException;
@ -187,7 +197,7 @@ public interface PlatformDao {
187 197

188 198
	@UpdateWith
189 199
	@From(PlatformInfo.class)
190
	int updateName(Connection con,String id,@Set String name)throws SQLException;
200
	int updateName(Connection con, String id, @Set String name) throws SQLException;
191 201

192 202
	@Nullable
193 203
	@SelectOne

+ 0 - 112
src/main/java/com/ekexiu/portal/platform/PlatformOrg.java

@ -1,112 +0,0 @@
1
package com.ekexiu.portal.platform;
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
import com.ekexiu.portal.basepo.CreateTimeSupported;
9
/**
10
 * 平台
11
 * @author Saga
12
 *
13
 */
14
@PrimaryKey("id")
15
@Table
16
public class PlatformOrg implements CreateTimeSupported {
17
	/**
18
	 * id
19
	 */
20
	private String id;
21
	/**
22
	 * 平台ID
23
	 */
24
	private String pid;
25
	private String logo;
26
	private String name;
27
	private String email;
28
	private String addr;
29
	private String linkman;
30
	private String linkphone;
31
	private String industry;
32
	private String descp;
33
	private String createTime;
34
	@Column(DE.text_de)
35
	public String getId() {
36
		return id;
37
	}
38
	public void setId(String id) {
39
		this.id = id;
40
	}
41
	public String getPid() {
42
		return pid;
43
	}
44
	@Column(DE.text_de)
45
	public void setPid(String pid) {
46
		this.pid = pid;
47
	}
48
	@Column(DE.text_de)
49
	public String getName() {
50
		return name;
51
	}
52
	public void setName(String name) {
53
		this.name = name;
54
	}
55
	@Column(DE.text_de)
56
	public String getEmail() {
57
		return email;
58
	}
59
	public void setEmail(String email) {
60
		this.email = email;
61
	}
62
	@Column(DE.Text_de)
63
	public String getAddr() {
64
		return addr;
65
	}
66
	public void setAddr(String addr) {
67
		this.addr = addr;
68
	}
69
	@Column(DE.Text_de)
70
	public String getLinkman() {
71
		return linkman;
72
	}
73
	public void setLinkman(String linkman) {
74
		this.linkman = linkman;
75
	}
76
	@Column(DE.Text_de)
77
	public String getLinkphone() {
78
		return linkphone;
79
	}
80
	public void setLinkphone(String linkphone) {
81
		this.linkphone = linkphone;
82
	}
83
	@Column(DE.Text_de)
84
	public String getIndustry() {
85
		return industry;
86
	}
87
	public void setIndustry(String industry) {
88
		this.industry = industry;
89
	}
90
	@Column(DE.Text_de)
91
	public String getDescp() {
92
		return descp;
93
	}
94
	public void setDescp(String descp) {
95
		this.descp = descp;
96
	}
97
	public String getCreateTime() {
98
		return createTime;
99
	}
100
	public void setCreateTime(String createTime) {
101
		this.createTime = createTime;
102
	}
103
	@Column(DE.Text_de)
104
	public String getLogo() {
105
		return logo;
106
	}
107
	public void setLogo(String logo) {
108
		this.logo = logo;
109
	}
110
	
111
	
112
}

+ 113 - 0
src/main/java/com/ekexiu/portal/platform/PlatformResource.java

@ -0,0 +1,113 @@
1
package com.ekexiu.portal.platform;
2

3
import org.jfw.apt.orm.annotation.entry.CalcColumn;
4
import org.jfw.apt.orm.annotation.entry.View;
5
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
6
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
7

8
@View("(SELECT P.ID OID,'1' OTYPE, R.RESOURCE_ID RID,R.RESOURCE_NAME RNAME, R.SUBJECT KEYWORDS,R.SUPPORTED_SERVICES CNT,I.IMAGE_SRC IMAGES,P.NAME FNAME,'' SNAME,B.PID PID,R.PUBLISH_TIME PTIME,R.SHARE_ID SHARE_ID,R.COMP COMP "+
9
	    "FROM RESOURCE R INNER JOIN PROFESSOR P ON R.PROFESSOR_ID=P.ID  INNER JOIN BUTTED_PROFESSOR B ON P.ID = B.UID  LEFT JOIN IMAGE I ON R.RESOURCE_ID=I.RESOURCE_ID "+
10
	    "WHERE R.STATUS='1' AND R.RESOURCE_TYPE='1' "+
11
	    "UNION ALL "+
12
	    "SELECT  O.ID OID,'2' OTYPE,R.RESOURCE_ID RID,R.RESOURCE_NAME RNAME, R.SUBJECT KEYWORDS,R.SUPPORTED_SERVICES CNT,I.IMAGE_SRC IMAGES,O.NAME FNAME,O.FOR_SHORT SNAME,B.PID PID,R.PUBLISH_TIME PTIME,R.SHARE_ID SHARE_ID,R.COMP COMP "+ 
13
	    "FROM RESOURCE R INNER JOIN ORGANIZATION O ON R.ORG_ID=O.ID  INNER JOIN BUTTED_ORG B ON O.ID = B.OID  LEFT JOIN IMAGE I ON R.RESOURCE_ID=I.RESOURCE_ID "+
14
	    "WHERE R.STATUS='1' AND R.RESOURCE_TYPE='2' ) T ")
15
public class PlatformResource {
16
	private String id;
17
	private String name;
18
//	private String keywords;
19
	private String cnt;
20
	private String images;
21
//	private String fname;
22
//	private String sname;
23
	private String pid;
24
	private String time;
25
	private long shareId;
26
	private String oid;
27
	private String otype;
28
	
29
	@CalcColumn(column="OID",handlerClass=StringHandler.class,nullable = false)
30
	public String getOid() {
31
		return oid;
32
	}
33
	public void setOid(String oid) {
34
		this.oid = oid;
35
	}
36
	@CalcColumn(column="OTYPE",handlerClass=StringHandler.class,nullable = false)
37
	public String getOtype() {
38
		return otype;
39
	}
40
	public void setOtype(String otype) {
41
		this.otype = otype;
42
	}
43
	@CalcColumn(column="RID",handlerClass=StringHandler.class,nullable = false)
44
	public String getId() {
45
		return id;
46
	}
47
	public void setId(String id) {
48
		this.id = id;
49
	}
50
	@CalcColumn(column="RNAME",handlerClass=StringHandler.class,nullable = false)
51
	public String getName() {
52
		return name;
53
	}
54
	public void setName(String name) {
55
		this.name = name;
56
	}
57
//	@CalcColumn(column="KEYWORDS",handlerClass=StringHandler.class,nullable = true)
58
//	public String getKeywords() {
59
//		return keywords;
60
//	}
61
//	public void setKeywords(String keywords) {
62
//		this.keywords = keywords;
63
//	}
64
	@CalcColumn(column="CNT",handlerClass=StringHandler.class,nullable = true)
65
	public String getCnt() {
66
		return cnt;
67
	}
68
	public void setCnt(String cnt) {
69
		this.cnt = cnt;
70
	}
71
	@CalcColumn(column="IMAGES",handlerClass=StringHandler.class,nullable = true)
72
	public String getImages() {
73
		return images;
74
	}
75
	public void setImages(String images) {
76
		this.images = images;
77
	}
78
//	@CalcColumn(column="FNAME",handlerClass=StringHandler.class,nullable = false)
79
//	public String getFname() {
80
//		return fname;
81
//	}
82
//	public void setFname(String fname) {
83
//		this.fname = fname;
84
//	}
85
//	@CalcColumn(column="SNAME",handlerClass=StringHandler.class,nullable = true)
86
//	public String getSname() {
87
//		return sname;
88
//	}
89
//	public void setSname(String sname) {
90
//		this.sname = sname;
91
//	}
92
	@CalcColumn(column="PID",handlerClass=StringHandler.class,nullable = false)
93
	public String getPid() {
94
		return pid;
95
	}
96
	public void setPid(String pid) {
97
		this.pid = pid;
98
	}
99
	@CalcColumn(column="PTIME",handlerClass=StringHandler.class,nullable = false)
100
	public String getTime() {
101
		return time;
102
	}
103
	public void setTime(String time) {
104
		this.time = time;
105
	}
106
	@CalcColumn(column="SHARE_ID",handlerClass=LongHandler.class,nullable = false)
107
	public long getShareId() {
108
		return shareId;
109
	}
110
	public void setShareId(long shareId) {
111
		this.shareId = shareId;
112
	}
113
}

+ 16 - 7
src/main/java/com/ekexiu/portal/platform/PlatformService.java

@ -289,13 +289,17 @@ public class PlatformService {
289 289

290 290
	@Post
291 291
	@Path("/bindMail")
292
	public void bindMail(@JdbcConn(true) Connection con, String code) throws SQLException, JfwBaseException {
292
	public void bindMail(@JdbcConn(true) Connection con, String code,String pw) throws SQLException, JfwBaseException {
293 293
		@SuppressWarnings("unchecked")
294 294
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(code);
295 295
		if (sc == null) {
296 296
			throw new JfwBaseException(-600001, " code expire");
297 297
		}
298 298
		JfwAppContext.removeCachedObject(code);
299
		
300
		if(!StringUtil.md5(pw).equals(sc.getValue())){
301
			throw new JfwBaseException(-600003, "invalid passwd"); 
302
		}
299 303

300 304
		if (this.platformDao.updateMail(con, sc.getCode(), sc.getKey(), sc.getValue(), sc.getDescp()) == 0) {
301 305
			throw new JfwBaseException(-600002, "user too fresh");
@ -320,12 +324,6 @@ public class PlatformService {
320 324
		return this.platformDao.queryInfo(con, id);
321 325
	}
322 326

323
	@Post
324
	@Path("/add/org")
325
	public int addOrg(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "createTime", "id" }) PlatformOrg po) throws SQLException {
326
		po.setId(StringUtil.buildUUID());
327
		return this.platformDao.insert(con, po);
328
	}
329 327

330 328
	@Post
331 329
	@Path("/resident")
@ -429,6 +427,17 @@ public class PlatformService {
429 427
		}
430 428
		return ret;
431 429
	}
430
	
431
	@Get
432
	@Path("/info/wares")
433
	public List<PlatformWare> queryWares(@JdbcConn Connection con,@Nullable String key,@DefaultValue("\"z\"") String time, @DefaultValue("Long.MAX_VALUE") long shareId,String pid,int rows)throws SQLException{
434
		return platformDao.queryWare(con, key, pid, time, shareId, rows);
435
	}
436
	@Get
437
	@Path("/info/resources")
438
	public List<PlatformResource> queryResources(@JdbcConn Connection con,@Nullable String key,@DefaultValue("\"z\"") String time, @DefaultValue("Long.MAX_VALUE") long shareId,String pid,int rows)throws SQLException{
439
		return platformDao.queryResource(con, key, pid, time, shareId, rows);
440
	}
432 441

433 442
	@Get
434 443
	@Path("/info/pqButtedProfessors")

+ 113 - 0
src/main/java/com/ekexiu/portal/platform/PlatformWare.java

@ -0,0 +1,113 @@
1
package com.ekexiu.portal.platform;
2

3
import org.jfw.apt.orm.annotation.entry.CalcColumn;
4
import org.jfw.apt.orm.annotation.entry.View;
5
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
6
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
7

8
@View("(SELECT P.ID OID,'1' OTYPE, W.ID WID,W.NAME WNAME, W.KEYWORDS KEYWORDS,W.CNT CNT,W.IMAGES IMAGES,P.NAME FNAME,'' SNAME,B.PID PID,W.MODIFY_TIME PTIME,W.SHARE_ID SHARE_ID "+
9
		    "FROM WARE W INNER JOIN PROFESSOR P ON W.OWNER=P.ID  INNER JOIN BUTTED_PROFESSOR B ON P.ID = B.UID "+
10
		    "WHERE W.STATE='1' AND W.CATEGORY='1' "+
11
		    "UNION ALL "+
12
		    "SELECT  O.ID OID,'2' OTYPE,W.ID WID,W.NAME WNAME, W.KEYWORDS KEYWORDS,W.CNT CNT,W.IMAGES IMAGES,O.NAME FNAME,O.FOR_SHORT SNAME,B.PID PID,W.MODIFY_TIME PTIME,W.SHARE_ID SHARE_ID "+ 
13
		    "FROM WARE W INNER JOIN ORGANIZATION O ON W.OWNER=O.ID  INNER JOIN BUTTED_ORG B ON O.ID = B.OID "+
14
		    "WHERE W.STATE='1' AND W.CATEGORY='2') T ")
15
public class PlatformWare {
16
	private String id;
17
	private String name;
18
//	private String keywords;
19
	private String cnt;
20
	private String images;
21
//	private String fname;
22
//	private String sname;
23
	private String pid;
24
	private String time;
25
	private long shareId;
26
	private String oid;
27
	private String otype;
28
	
29
	@CalcColumn(column="OID",handlerClass=StringHandler.class,nullable = false)
30
	public String getOid() {
31
		return oid;
32
	}
33
	public void setOid(String oid) {
34
		this.oid = oid;
35
	}
36
	@CalcColumn(column="OTYPE",handlerClass=StringHandler.class,nullable = false)
37
	public String getOtype() {
38
		return otype;
39
	}
40
	public void setOtype(String otype) {
41
		this.otype = otype;
42
	}
43
	@CalcColumn(column="WID",handlerClass=StringHandler.class,nullable = false)
44
	public String getId() {
45
		return id;
46
	}
47
	public void setId(String id) {
48
		this.id = id;
49
	}
50
	@CalcColumn(column="WNAME",handlerClass=StringHandler.class,nullable = false)
51
	public String getName() {
52
		return name;
53
	}
54
	public void setName(String name) {
55
		this.name = name;
56
	}
57
//	@CalcColumn(column="KEYWORDS",handlerClass=StringHandler.class,nullable = true)
58
//	public String getKeywords() {
59
//		return keywords;
60
//	}
61
//	public void setKeywords(String keywords) {
62
//		this.keywords = keywords;
63
//	}
64
	@CalcColumn(column="CNT",handlerClass=StringHandler.class,nullable = true)
65
	public String getCnt() {
66
		return cnt;
67
	}
68
	public void setCnt(String cnt) {
69
		this.cnt = cnt;
70
	}
71
	@CalcColumn(column="IMAGES",handlerClass=StringHandler.class,nullable = true)
72
	public String getImages() {
73
		return images;
74
	}
75
	public void setImages(String images) {
76
		this.images = images;
77
	}
78
//	@CalcColumn(column="FNAME",handlerClass=StringHandler.class,nullable = false)
79
//	public String getFname() {
80
//		return fname;
81
//	}
82
//	public void setFname(String fname) {
83
//		this.fname = fname;
84
//	}
85
//	@CalcColumn(column="SNAME",handlerClass=StringHandler.class,nullable = true)
86
//	public String getSname() {
87
//		return sname;
88
//	}
89
//	public void setSname(String sname) {
90
//		this.sname = sname;
91
//	}
92
	@CalcColumn(column="PID",handlerClass=StringHandler.class,nullable = false)
93
	public String getPid() {
94
		return pid;
95
	}
96
	public void setPid(String pid) {
97
		this.pid = pid;
98
	}
99
	@CalcColumn(column="PTIME",handlerClass=StringHandler.class,nullable = false)
100
	public String getTime() {
101
		return time;
102
	}
103
	public void setTime(String time) {
104
		this.time = time;
105
	}
106
	@CalcColumn(column="SHARE_ID",handlerClass=LongHandler.class,nullable = false)
107
	public long getShareId() {
108
		return shareId;
109
	}
110
	public void setShareId(long shareId) {
111
		this.shareId = shareId;
112
	}
113
}

+ 20 - 7
src/main/java/com/ekexiu/portal/po/Demand.java

@ -24,12 +24,13 @@ public class Demand implements CreateTimeSupported,ModifyTimeSupported {
24 24
	private String contactNum;
25 25
	
26 26
	private String state;
27
	private String orgId;
27
	private String orgName;
28 28
	private String modifier;
29 29
	private String creator;
30 30
	private String createTime;
31 31
	private String modifyTime;
32 32
	private String descp;
33
	private String source;
33 34
	
34 35
	
35 36
	private long pageViews;
@ -136,15 +137,27 @@ public class Demand implements CreateTimeSupported,ModifyTimeSupported {
136 137
		this.state = state;
137 138
	}
138 139
	/**
139
	 * 发布人发布时所在机构ID
140
	 * 发布人发布时所在机构
140 141
	 * @return
141 142
	 */
142
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(32)",insertable=true,nullable=false,queryable=true,renewable=false)
143
	public String getOrgId() {
144
		return orgId;
143
	@Column(DE.text_de)
144
	public String getOrgName() {
145
		return orgName;
146
	}
147
	public void setOrgName(String orgName) {
148
		this.orgName = orgName;
149
	}
150
	
151
	/**
152
	 * 发布来源
153
	 * @return
154
	 */
155
	@Column(DE.text_de)
156
	public String getSource() {
157
		return source;
145 158
	}
146
	public void setOrgId(String orgId) {
147
		this.orgId = orgId;
159
	public void setSource(String source) {
160
		this.source = source;
148 161
	}
149 162
	/**
150 163
	 * 最后修改人

+ 10 - 0
src/main/java/com/ekexiu/portal/po/Resource.java

@ -83,6 +83,16 @@ public class Resource implements CreateTimeSupported, ModifyTimeSupported{
83 83
	 */
84 84
	private long sortNum;
85 85
	
86
	private String category;
87
	
88
	
89
	@Column(DE.text_de)
90
	public String getCategory() {
91
		return category;
92
	}
93
	public void setCategory(String category) {
94
		this.category = category;
95
	}
86 96
	public List<Image> getImages() {
87 97
		return images;
88 98
	}

+ 223 - 39
src/main/java/com/ekexiu/portal/service/DemandService.java

@ -2,6 +2,7 @@ package com.ekexiu.portal.service;
2 2

3 3
import java.sql.Connection;
4 4
import java.sql.SQLException;
5
import java.util.Date;
5 6
import java.util.List;
6 7

7 8
import org.jfw.apt.annotation.Autowrie;
@ -14,17 +15,50 @@ import org.jfw.apt.web.annotation.param.JdbcConn;
14 15
import org.jfw.apt.web.annotation.param.RequestParam;
15 16
import org.jfw.util.PageQueryResult;
16 17
import org.jfw.util.StringUtil;
18
import org.jfw.util.context.JfwAppContext;
19
import org.jfw.util.exception.JfwBaseException;
20
import org.jfw.util.jdbc.JdbcUtil;
21
import org.jfw.util.state.StateCode;
17 22

18 23
import com.ekexiu.portal.dao.DemandDao;
24
import com.ekexiu.portal.dao.UserDao;
19 25
import com.ekexiu.portal.po.Demand;
26
import com.ekexiu.portal.po.Organization;
27
import com.ekexiu.portal.po.Professor;
28
import com.ekexiu.portal.po.User;
20 29

21 30
@Path("/demand")
22 31
public class DemandService {
23 32
	public static final String MAX_CREATETIME = "9";
24 33

34
	@Autowrie
35
	private UserDao userDao;
36

37
	@Autowrie
38
	private ProfessorService professorService;
39

40
	@Autowrie
41
	private OrgService orgService;
42

25 43
	@Autowrie
26 44
	private DemandDao demandDao;
27 45

46
	public OrgService getOrgService() {
47
		return orgService;
48
	}
49

50
	public void setOrgService(OrgService orgService) {
51
		this.orgService = orgService;
52
	}
53

54
	public ProfessorService getProfessorService() {
55
		return professorService;
56
	}
57

58
	public void setProfessorService(ProfessorService professorService) {
59
		this.professorService = professorService;
60
	}
61

28 62
	public DemandDao getDemandDao() {
29 63
		return demandDao;
30 64
	}
@ -33,22 +67,33 @@ public class DemandService {
33 67
		this.demandDao = demandDao;
34 68
	}
35 69

70
	public UserDao getUserDao() {
71
		return userDao;
72
	}
73

74
	public void setUserDao(UserDao userDao) {
75
		this.userDao = userDao;
76
	}
77

36 78
	/**
37 79
	 * 发布需求
80
	 * 
38 81
	 * @param con
39
	 * @param demand  
82
	 * @param demand
40 83
	 * @throws SQLException
41 84
	 */
42 85
	@Post
43 86
	@Path
44
	public String  insert(@JdbcConn(true) Connection con,@RequestParam(excludeFields={"id","state","createTime","modifyTime","shareId","pageViews","modifier"})  Demand demand)throws SQLException{
87
	public String insert(@JdbcConn(true) Connection con,
88
			@RequestParam(excludeFields = { "id", "state", "createTime", "modifyTime", "shareId", "pageViews", "modifier" }) Demand demand)
89
			throws SQLException {
45 90
		String demandId = StringUtil.buildUUID();
46 91
		demand.setId(demandId);
47 92
		demand.setState("1");
48
		if(demand.getCost()==null){
93
		if (demand.getCost() == null) {
49 94
			demand.setCost("0");
50 95
		}
51
		if(demand.getDuration()==null){
96
		if (demand.getDuration() == null) {
52 97
			demand.setDuration("0");
53 98
		}
54 99
		demand.setModifier(demand.getCreator());
@ -56,127 +101,263 @@ public class DemandService {
56 101
		return demandId;
57 102
	}
58 103

104
	/**
105
	 * 发布需求
106
	 * 
107
	 * @param con
108
	 * @param demand
109
	 * @throws SQLException
110
	 */
111
	@Post
112
	@Path("/publishInPlatform")
113
	public String insert(@JdbcConn Connection con,
114
			@RequestParam(excludeFields = { "creator", "id", "state", "createTime", "modifyTime", "shareId", "pageViews", "modifier" }) Demand demand,
115
			String state, String vc, String name) throws Exception {
116

117
		@SuppressWarnings("unchecked")
118
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
119
		if (sc == null || sc.getExpiredTime() < System.currentTimeMillis())
120
			throw new JfwBaseException(-600001, "验证超时");
121
		if (!sc.getKey().equals(demand.getContactNum())) {
122
			throw new JfwBaseException(-2, "手机号与验证手机不匹配");
123
		}
124
		if (!sc.getValue().equals(vc)) {
125
			throw new JfwBaseException(-3, "验证码错误");
126
		}
127
		String orgId = null;
128
		try {
129
			orgId = this.orgService.createOrganization(con, demand.getOrgName());
130
			con.commit();
131
		} catch (Exception e) {
132
			JdbcUtil.rollback(con);
133
			throw e;
134
		}
135
		String demandId = null;
136
		try {
137
			User user = null;
138
			boolean exists = false;
139
			String uid = StringUtil.buildUUID();
140
			try {
141
				user = new User();
142
				user.setId(uid);
143
				String passwd = StringUtil.md5("123456");
144
				user.setMobilePhone(demand.getContactNum());
145
				user.setPasswd(passwd);
146
				user.setUserType("0");
147
				user.setActiveTime(SysService.DATE.format(new Date()));
148
				this.userDao.insert(con, user);
149
			} catch (SQLException e) {
150
				if ("23505".equals(e.getSQLState())) {
151
					con.rollback();
152
					user = userDao.queryByEmailOrMobilePhone(con, demand.getContactNum());
153
					if (user == null)
154
						throw new RuntimeException("not fonud  with query user by phone");
155
					exists = true;
156
					uid = user.getId();
157
				} else {
158
					throw e;
159
				}
160
			}
161
			if (exists) {
162
				Professor professor = this.professorService.query(con, uid);
163
				if (professor == null) {
164
					professor = new Professor();
165
					professor.setId(uid);
166
					professor.setName(name);
167
					professor.setPhone(demand.getContactNum());
168
					professor.setOrgId(orgId);
169
					this.professorService.insert(con, professor, null);
170
				}
171
			} else {
172
				Professor professor = new Professor();
173
				professor.setId(uid);
174
				professor.setName(name);
175
				professor.setPhone(demand.getContactNum());
176
				professor.setOrgId(orgId);
177
				this.professorService.insert(con, professor, null);
178
			}
179
			Organization org = this.orgService.query(con, orgId);
180
			if (!demand.getOrgName().equals(org.getName())) {
181
				demand.setOrgName(org.getName());
182
			}
183
			demandId = StringUtil.buildUUID();
184
			demand.setId(demandId);
185
			demand.setState("1");
186
			if (demand.getCost() == null) {
187
				demand.setCost("0");
188
			}
189
			if (demand.getDuration() == null) {
190
				demand.setDuration("0");
191
			}
192
			demand.setCreator(user.getId());
193
			demand.setModifier(user.getId());
194
			this.demandDao.insert(con, demand);
195
			con.commit();
196
		} catch (Exception e) {
197
			JdbcUtil.rollback(con);
198
			throw e;
199
		} finally {
200
			JfwAppContext.removeCachedObject(state);
201
		}
202
		return demandId;
203
	}
204

59 205
	/**
60 206
	 * 修改需求
207
	 * 
61 208
	 * @param con
62 209
	 * @param demand
63 210
	 * @throws SQLException
64 211
	 */
65 212
	@Post
66 213
	@Path("/modify")
67
	public boolean update(@JdbcConn(true) Connection con,@RequestParam(excludeFields={"state","createTime","modifyTime","title","descp","orgId","creator","pageViews","shareId"}) Demand demand)throws SQLException{
68
		if(demand.getCost()==null){
214
	public boolean update(@JdbcConn(true) Connection con,
215
			@RequestParam(excludeFields = { "state", "createTime", "modifyTime", "title","source", "descp", "creator", "pageViews", "shareId" }) Demand demand)
216
			throws SQLException {
217
		if (demand.getCost() == null) {
69 218
			demand.setCost("0");
70 219
		}
71
		if(demand.getDuration()==null){
220
		if (demand.getDuration() == null) {
72 221
			demand.setDuration("0");
73 222
		}
74 223
		demand.setState("1");
75
		return this.demandDao.update(con, demand)>0;	
224
		return this.demandDao.update(con, demand) > 0;
76 225
	}
226

77 227
	/**
78 228
	 * 完成需求
229
	 * 
79 230
	 * @param con
80
	 * @param id  需求ID
81
	 * @param uid 操作用户ID
231
	 * @param id
232
	 *            需求ID
233
	 * @param uid
234
	 *            操作用户ID
82 235
	 * @return
83 236
	 * @throws SQLException
84 237
	 */
85 238
	@Post
86 239
	@Path("/over")
87
	public boolean over(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
88
		return this.demandDao.over(con, id, uid)>0;
240
	public boolean over(@JdbcConn(true) Connection con, String id, String uid) throws SQLException {
241
		return this.demandDao.over(con, id, uid) > 0;
89 242
	}
243

90 244
	/**
91 245
	 * 关闭需求
246
	 * 
92 247
	 * @param con
93
	 * @param id 需求ID
94
	 * @param uid 需求ID
248
	 * @param id
249
	 *            需求ID
250
	 * @param uid
251
	 *            需求ID
95 252
	 * @return
96 253
	 * @throws SQLException
97 254
	 */
98 255
	@Post
99 256
	@Path("/close")
100
	public boolean close(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
101
		return this.demandDao.close(con, id, uid)>0;
257
	public boolean close(@JdbcConn(true) Connection con, String id, String uid) throws SQLException {
258
		return this.demandDao.close(con, id, uid) > 0;
102 259
	}
260

103 261
	/**
104 262
	 * 延期需求
263
	 * 
105 264
	 * @param con
106
	 * @param id 需求ID
107
	 * @param uid 操作用户ID
108
	 * @param day 延期日期 YYYYMMD
265
	 * @param id
266
	 *            需求ID
267
	 * @param uid
268
	 *            操作用户ID
269
	 * @param day
270
	 *            延期日期 YYYYMMD
109 271
	 * @return
110 272
	 * @throws SQLException
111 273
	 */
112 274
	@Post
113 275
	@Path("/defer")
114
	public boolean defer(@JdbcConn(true) Connection con,String id,String uid,String day)throws SQLException{
115
		return this.demandDao.defer(con, id,uid,day)>0;
276
	public boolean defer(@JdbcConn(true) Connection con, String id, String uid, String day) throws SQLException {
277
		return this.demandDao.defer(con, id, uid, day) > 0;
116 278
	}
279

117 280
	/**
118 281
	 * 增加浏览量
282
	 * 
119 283
	 * @param con
120
	 * @param id 需求ID
284
	 * @param id
285
	 *            需求ID
121 286
	 * @throws SQLException
122 287
	 */
123 288
	@Post
124 289
	@Path("/incPageViews")
125
	public void incPageViews(@JdbcConn(true) Connection con,String id)throws SQLException{
290
	public void incPageViews(@JdbcConn(true) Connection con, String id) throws SQLException {
126 291
		this.demandDao.incPageViews(con, id);
127 292
	}
293

128 294
	/**
129 295
	 * 查询需求数量
296
	 * 
130 297
	 * @param con
131
	 * @param state  需求状态
132
	 * @param uid    发布者ID
133
	 * @param oid   发布者发布时机构ID
298
	 * @param state
299
	 *            需求状态
300
	 * @param uid
301
	 *            发布者ID
302
	 * @param oid
303
	 *            发布者发布时机构ID
134 304
	 * @return
135 305
	 * @throws SQLException
136 306
	 */
137 307
	@Get
138 308
	@Path("/qc")
139
	public int queryCount(@JdbcConn Connection con,@Nullable String[] state,@Nullable String uid,@Nullable String oid)throws SQLException{
140
		return this.demandDao.cnt(con, state, uid,oid);
309
	public int queryCount(@JdbcConn Connection con, @Nullable String[] state, @Nullable String uid, @Nullable String oid) throws SQLException {
310
		return this.demandDao.cnt(con, state, uid, oid);
141 311
	}
312

142 313
	/**
143 314
	 * 查询需求
315
	 * 
144 316
	 * @param con
145
	 * @param id  需求ID
317
	 * @param id
318
	 *            需求ID
146 319
	 * @return
147 320
	 * @throws SQLException
148 321
	 */
149 322
	@Get
150 323
	@Path("/qo")
151
	public Demand queryOne(@JdbcConn Connection con, String id)throws SQLException{
324
	public Demand queryOne(@JdbcConn Connection con, String id) throws SQLException {
152 325
		return this.demandDao.query(con, id);
153 326
	}
327

154 328
	/**
155 329
	 * 根据分享ID 查询需求
330
	 * 
156 331
	 * @param con
157
	 * @param id 分享ID
332
	 * @param id
333
	 *            分享ID
158 334
	 * @return
159 335
	 * @throws SQLException
160 336
	 */
161 337
	@Get
162 338
	@Path("/byShareId")
163
	public Demand queryByShareId(@JdbcConn Connection con ,long id)throws SQLException{
339
	public Demand queryByShareId(@JdbcConn Connection con, long id) throws SQLException {
164 340
		return this.demandDao.query(con, id);
165 341
	}
342

166 343
	/**
167 344
	 * 查询需求列表
345
	 * 
168 346
	 * @param con
169
	 * @param id 需求ID 数组
347
	 * @param id
348
	 *            需求ID 数组
170 349
	 * @return
171 350
	 * @throws SQLException
172 351
	 */
173 352
	@Get
174 353
	@Path("/qm")
175
	public List<Demand> queryOne(@JdbcConn Connection con, String[] id)throws SQLException{
354
	public List<Demand> queryOne(@JdbcConn Connection con, String[] id) throws SQLException {
176 355
		return this.demandDao.query(con, id);
177 356
	}
357

178 358
	/**
179 359
	 * 分页查询需求(按状态及发布时间排序)
360
	 * 
180 361
	 * @param con
181 362
	 * @param state
182 363
	 * @param uid
@ -186,12 +367,14 @@ public class DemandService {
186 367
	 */
187 368
	@Get
188 369
	@Path("/pq")
189
	public PageQueryResult<Demand> query(@JdbcConn Connection con,@Nullable String[] state,@Nullable String uid,@Nullable String oid,@DefaultValue("1") int pageNo,@DefaultValue("5") int pageSize)throws SQLException{
190
		return this.demandDao.pageQuery(con, state, uid, oid,pageSize,pageNo);
370
	public PageQueryResult<Demand> query(@JdbcConn Connection con, @Nullable String[] state, @Nullable String uid, @Nullable String oname,
371
			@DefaultValue("1") int pageNo, @DefaultValue("5") int pageSize) throws SQLException {
372
		return this.demandDao.pageQuery(con, state, uid, oname, pageSize, pageNo);
191 373
	}
192
	
374

193 375
	/**
194 376
	 * 分页查询需求(按发布时间排序)
377
	 * 
195 378
	 * @param con
196 379
	 * @param state
197 380
	 * @param uid
@ -201,7 +384,8 @@ public class DemandService {
201 384
	 */
202 385
	@Get
203 386
	@Path("/search")
204
	public PageQueryResult<Demand> query(@JdbcConn Connection con,@Nullable String[] state,@Nullable String key,@DefaultValue("1") int pageNo,@DefaultValue("5") int pageSize)throws SQLException{
205
		return this.demandDao.pageQuery(con,state, key==null?key:("%"+key+"%"),pageSize,pageNo);
387
	public PageQueryResult<Demand> query(@JdbcConn Connection con, @Nullable String[] state, @Nullable String key, @DefaultValue("1") int pageNo,
388
			@DefaultValue("5") int pageSize) throws SQLException {
389
		return this.demandDao.pageQuery(con, state, key == null ? key : ("%" + key + "%"), pageSize, pageNo);
206 390
	}
207 391
}

+ 8 - 0
src/main/java/com/ekexiu/portal/service/OrgService.java

@ -178,6 +178,14 @@ public class OrgService {
178 178
		return organizations;
179 179
	}
180 180
	
181
	@Get
182
	@Path("/queryByName")
183
	public EditOrganization queryByName(@JdbcConn Connection con,String name)throws SQLException{
184
		EditOrganization o = this.orgDao.queryOneByName(con, name);
185
		o.setHasOrgLogo(this.imageService.hasOrgLogo(o.getId()));
186
		return o;
187
	}
188
	
181 189
	public String createOrganization(Connection con, String orgName) throws SQLException, IOException {
182 190
		String id = StringUtil.buildUUID();
183 191
		Organization org = new Organization();

+ 13 - 0
src/main/java/com/ekexiu/portal/service/SysService.java

@ -1952,6 +1952,19 @@ public class SysService {
1952 1952
		}
1953 1953
		return key;
1954 1954
	}
1955
	
1956
	@Post
1957
	@Path("/phoneValidCode/check")
1958
	public boolean checkPhoneValidCode(String key,String phone,String code){
1959
		@SuppressWarnings("unchecked")
1960
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(key);
1961
		if(sc!=null){
1962
			if(sc.getExpiredTime() > System.currentTimeMillis()){
1963
				return phone.equals(sc.getKey()) && code.equals(sc.getValue());
1964
			}
1965
		}
1966
		return false;
1967
	}
1955 1968
1956 1969
	@Get
1957 1970
	@Path("/sendMobileForLogin")

+ 2 - 0
src/main/java/com/ekexiu/portal/ware/Ware.java

@ -62,6 +62,8 @@ public class Ware implements CreateTimeSupported, ModifyTimeSupported{
62 62
	
63 63
	
64 64
	
65
	
66
	
65 67
	@Column(handlerClass=LongHandler.class,dbType="INT8",nullable=true,renewable=false,fixSqlValueWithInsert="0")
66 68
	public long getPageViews() {
67 69
		return pageViews;

+ 8 - 25
src/main/resources/database.sql

@ -2353,31 +2353,14 @@ COMMENT ON COLUMN BUTTED_PROFESSOR.PID is '平台ID';
2353 2353
COMMENT ON COLUMN BUTTED_PROFESSOR.UID is '对接的专家ID';
2354 2354
COMMENT ON COLUMN BUTTED_PROFESSOR.CREATE_TIME is '对接时间';
2355 2355

2356
CREATE TABLE PLATFORM_ORG (
2357
	ID TEXT NOT NULL,
2358
	PID TEXT NOT NULL,
2359
	LOGO TEXT,
2360
	NAME TEXT NOT NULL,
2361
	EMAIL TEXT NOT NULL,
2362
	ADDR TEXT,
2363
	LINKMAN TEXT,
2364
	LINKPHONE TEXT,
2365
	INDUSTRY TEXT,
2366
	DESCP TEXT,
2367
	CREATE_TIME CHAR(14) NOT NULL);
2368
ALTER TABLE PLATFORM_ORG ADD PRIMARY KEY (ID);
2369

2370
COMMENT ON TABLE PLATFORM_ORG is '平台待入驻企业表';
2371
COMMENT ON COLUMN PLATFORM_ORG.PID is '平台ID';
2372
COMMENT ON COLUMN PLATFORM_ORG.NAME is '企业全称';
2373
COMMENT ON COLUMN PLATFORM_ORG.EMAIL is '企业邮箱';
2374
COMMENT ON COLUMN PLATFORM_ORG.ADDR is '企业地址';
2375
COMMENT ON COLUMN PLATFORM_ORG.LINKMAN is '联系人';
2376
COMMENT ON COLUMN PLATFORM_ORG.LINKPHONE is '联系电话';
2377
COMMENT ON COLUMN PLATFORM_ORG.INDUSTRY is '所属行业';
2378
COMMENT ON COLUMN PLATFORM_ORG.DESCP is '企业介绍';
2379

2380

2356
--ALTER TABLE RESOURCE ADD COLUMN CATEGORY TEXT DEFAULT '0';
2357
--COMMENT ON COLUMN resource.CATEGORY IS '资源分类';
2358
--ALTER TABLE RESOURCE ALTER COLUMN CATEGORY SET NOT NULL;
2359

2360
ALTER TABLE DEMAND ADD COLUMN ORG_NAME TEXT DEFAULT '1';
2361
update DEMAND set ORG_NAME =(SELECT NAME FROM ORGANIZATION WHERE ID =  DEMAND.ORG_ID);
2362
ALTER TABLE DEMAND DROP COLUMN ORG_ID;
2363
ALTER TABLE DEMAND ALTER COLUMN ORG_NAME SET  NOT NULL;
2381 2364

2382 2365

2383 2366


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

@ -104,7 +104,7 @@ com_ekexiu_portal_service_SysService.phoneRetrievePasswordReplaceKey=yzm
104 104
com_ekexiu_portal_service_SysService.phoneRetrievePasswordContentTemplate=\u3010\u79D1\u8896\u3011\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801yzm\uFF0C\u5B8C\u6210\u5BC6\u7801\u91CD\u7F6E\u3002\u8BF7\u4E8E3\u5206\u949F\u5185\u6B63\u786E\u8F93\u5165\u9A8C\u8BC1\u7801\u3002\u5982\u975E\u672C\u4EBA\u64CD\u4F5C\uFF0C\u8BF7\u5FFD\u7565\u672C\u77ED\u4FE1\u3002
105 105
#手机验证-注册用户
106 106
com_ekexiu_portal_service_SysService.regMobilePhoneReplaceKey=yzm
107
com_ekexiu_portal_service_SysService.regMobilePhoneContentTemplate=\u3010\u79D1\u8896\u3011\u60A8\u7684\u9A8C\u8BC1\u7801\u4E3Ayzm\uFF0C\u8BF7\u4E8E3\u5206\u949F\u5185\u6B63\u786E\u8F93\u5165\uFF0C\u5982\u975E\u672C\u4EBA\u64CD\u4F5C\uFF0C\u8BF7\u5FFD\u7565\u6B64\u77ED\u4FE1\u3002
107
com_ekexiu_portal_service_SysService.regMobilePhoneContentTemplate=\u3010\u79D1\u8896\u3011\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801yzm\uFF0C\u5B8C\u6210\u624B\u673A\u9A8C\u8BC1\u3002\u8BF7\u4E8E3\u5206\u949F\u5185\u6B63\u786E\u8F93\u5165\u9A8C\u8BC1\u7801\u3002\u5982\u975E\u672C\u4EBA\u64CD\u4F5C\uFF0C\u8BF7\u5FFD\u7565\u672C\u77ED\u4FE1\u3002
108 108
#手机验证-用户登录
109 109
com_ekexiu_portal_service_SysService.loginMobilePhoneReplaceKey=yzm
110 110
com_ekexiu_portal_service_SysService.loginMobilePhoneContentTemplate=\u3010\u79D1\u8896\u3011\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801yzm\uFF0C\u5B8C\u6210\u77ED\u4FE1\u767B\u5F55\u3002\u8BF7\u4E8E3\u5206\u949F\u5185\u6B63\u786E\u8F93\u5165\u9A8C\u8BC1\u7801\u3002\u5982\u975E\u672C\u4EBA\u64CD\u4F5C\uFF0C\u8BF7\u5FFD\u7565\u672C\u77ED\u4FE1\u3002