Просмотр исходного кода

--add EditOrganization.java;update orgService.query();

zzy.zhiyuan.foxmail лет назад: 8
Родитель
Сommit
6ebf716105

+ 100 - 13
src/main/java/com/ekexiu/portal/dao/OrgDao.java

@ -1,6 +1,8 @@
1 1
package com.ekexiu.portal.dao;
2 2
3 3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
4 6
import java.sql.SQLException;
5 7
import java.util.List;
6 8
@ -24,54 +26,139 @@ import org.jfw.util.PageQueryResult;
24 26
25 27
import com.ekexiu.portal.basepo.BaseOrganization;
26 28
import com.ekexiu.portal.po.Organization;
29
import com.ekexiu.portal.pojo.EditOrganization;
27 30
28 31
@DAO
29
public interface OrgDao {
32
public abstract class OrgDao {
30 33
	
31 34
	@Insert
32
	int insert(Connection con, Organization org)throws SQLException;
35
	public abstract int insert(Connection con, Organization org)throws SQLException;
33 36
	
34 37
	@UpdateWith
35 38
	@From(Organization.class)
36
	int updateIsJoin(Connection con,String id,@Set String isJoin)throws SQLException;
39
	public abstract int updateIsJoin(Connection con,String id,@Set String isJoin)throws SQLException;
37 40
	
38 41
	@UpdateWith
39 42
	@From(Organization.class)
40
	int updateAuthStatus(Connection con,String id,@Set String authStatus)throws SQLException;
43
	public abstract int updateAuthStatus(Connection con,String id,@Set String authStatus)throws SQLException;
41 44
	
42 45
	@Update
43
	int update(Connection con,Organization org)throws SQLException;
46
	public abstract int update(Connection con,Organization org)throws SQLException;
44 47
	
45 48
46 49
	@Nullable
47 50
	@SelectOne
48
	Organization query(Connection con,String id) throws SQLException;
51
	public abstract Organization query(Connection con,String id) throws SQLException;
52
	
53
	public EditOrganization queryEditOrg(Connection con,String id) throws SQLException{
54
        int index = 1;
55
        String sql = "SELECT FOR_SHORT,ORG_URL,FOUND_TIME,PROVINCE,CITY,SUBJECT,INDUSTRY,ORG_SIZE,QUALIFICATION,IS_JOIN,AUTH_STATUS,ORG_ATTR,ID,NAME,ORG_TYPE,CREATE_TIME,MODIFY_TIME,DESCP FROM ORGANIZATION WHERE ID = ?";
56
        PreparedStatement ps = con.prepareStatement(sql);
57
        try{
58
            ps.setString(index++,id);
59
            ResultSet rs = ps.executeQuery();
60
            try{
61
                if(rs.next()){
62
                    EditOrganization editOrg = new EditOrganization();
63
                    String forShort = rs.getString(1);
64
                    if(rs.wasNull()){
65
                    	forShort = null;
66
                    }
67
                    editOrg.setForShort(forShort);
68
                    String orgUrl = rs.getString(2);
69
                    if(rs.wasNull()){
70
                    	orgUrl = null;
71
                    }
72
                    editOrg.setOrgUrl(orgUrl);
73
                    String foundTime = rs.getString(3);
74
                    if(rs.wasNull()){
75
                    	foundTime = null;
76
                    }
77
                    editOrg.setFoundTime(foundTime);
78
                    String province = rs.getString(4);
79
                    if(rs.wasNull()){
80
                    	province = null;
81
                    }
82
                    editOrg.setProvince(province);
83
                    String city = rs.getString(5);
84
                    if(rs.wasNull()){
85
                    	city = null;
86
                    }
87
                    editOrg.setCity(city);
88
                    String subject = rs.getString(6);
89
                    if(rs.wasNull()){
90
                    	subject = null;
91
                    }
92
                    editOrg.setSubject(subject);
93
                    String industry = rs.getString(7);
94
                    if(rs.wasNull()){
95
                    	industry = null;
96
                    }
97
                    editOrg.setIndustry(industry);
98
                    String orgSize = rs.getString(8);
99
                    if(rs.wasNull()){
100
                    	orgSize = null;
101
                    }
102
                    editOrg.setOrgSize(orgSize);
103
                    String qualification = rs.getString(9);
104
                    if(rs.wasNull()){
105
                    	qualification = null;
106
                    }
107
                    editOrg.setQualification(qualification);
108
                    editOrg.setIsJoin(rs.getString(10));
109
                    editOrg.setAuthStatus(rs.getString(11));
110
                    String orgAttr = rs.getString(12);
111
                    if(rs.wasNull()){
112
                    	orgAttr = null;
113
                    }
114
                    editOrg.setOrgAttr(orgAttr);
115
                    editOrg.setId(rs.getString(13));
116
                    editOrg.setName(rs.getString(14));
117
                    editOrg.setOrgType(rs.getString(15));
118
                    editOrg.setCreateTime(rs.getString(16));
119
                    editOrg.setModifyTime(rs.getString(17));
120
                    String descp = rs.getString(18);
121
                    if(rs.wasNull()){
122
                    	descp = null;
123
                    }
124
                    editOrg.setDescp(descp);
125
                    return editOrg;
126
                }else{
127
                    return null;
128
                }
129
            }finally{
130
                try{rs.close();}catch(Exception e1){}
131
            }
132
        }finally{
133
            try{ps.close();}catch(Exception e2){}
134
        }
135
    }
49 136
	
50 137
	@SelectList
51
	List<Organization> query(Connection con)throws SQLException;
138
	public abstract List<Organization> query(Connection con)throws SQLException;
52 139
	@LimitQuery
53
	List<Organization> limitQuery(Connection con, @Like String name,int rows)throws SQLException;
140
	public abstract List<Organization> limitQuery(Connection con, @Like String name,int rows)throws SQLException;
54 141
	
55 142
	@Nullable
56 143
	@QueryVal
57 144
	@Column(handlerClass=StringHandler.class,value="id")
58 145
	@From(Organization.class)
59
	String queryByName(Connection con,String name)throws SQLException;
146
	public abstract String queryByName(Connection con,String name)throws SQLException;
60 147
	
61 148
	@Nullable
62 149
	@QueryVal
63 150
	@Column(handlerClass=StringHandler.class,value="auth_status")
64 151
	@From(Organization.class)
65
	String queryAuthStatus(Connection con,String id)throws SQLException;
152
	public abstract String queryAuthStatus(Connection con,String id)throws SQLException;
66 153
	
67 154
	@PageSelect
68
	PageQueryResult<Organization> query(Connection con,@Nullable  @Like String name,@Nullable String orgType,int pageSize,int pageNo) throws SQLException;
155
	public abstract PageQueryResult<Organization> query(Connection con,@Nullable  @Like String name,@Nullable String orgType,int pageSize,int pageNo) throws SQLException;
69 156
70 157
	@From(Organization.class)
71 158
	@LimitQuery
72
	List<BaseOrganization> query(Connection con,@Nullable @Like String name,int rows) throws SQLException;
159
	public abstract List<BaseOrganization> query(Connection con,@Nullable @Like String name,int rows) throws SQLException;
73 160
	
74 161
	@From(Organization.class)
75 162
	@DeleteWith
76
	int delete(Connection con,String id)throws SQLException;
163
	public abstract int delete(Connection con,String id)throws SQLException;
77 164
}

+ 1 - 1
src/main/java/com/ekexiu/portal/po/Organization.java

@ -124,7 +124,7 @@ public class Organization extends BaseOrganization implements CreateTimeSupporte
124 124
	public void setIsJoin(String isJoin) {
125 125
		this.isJoin = isJoin;
126 126
	}
127
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(1)",renewable=false)
127
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(2)",renewable=false)
128 128
	public String getAuthStatus() {
129 129
		return authStatus;
130 130
	}

+ 16 - 0
src/main/java/com/ekexiu/portal/pojo/EditOrganization.java

@ -0,0 +1,16 @@
1
package com.ekexiu.portal.pojo;
2

3
import com.ekexiu.portal.po.Organization;
4

5
public class EditOrganization extends Organization {
6
	private boolean hasOrgLogo;
7

8
	public boolean isHasOrgLogo() {
9
		return hasOrgLogo;
10
	}
11

12
	public void setHasOrgLogo(boolean hasOrgLogo) {
13
		this.hasOrgLogo = hasOrgLogo;
14
	}
15
	
16
}

+ 15 - 0
src/main/java/com/ekexiu/portal/service/ImageService.java

@ -162,6 +162,21 @@ public class ImageService {
162 162
			return 0;
163 163
		}
164 164
	}
165
	
166
	/**
167
	 * 判断是否有企业logo
168
	 * @param id 企业ID
169
	 * @return 有企业logo返回true,否则返回false
170
	 */
171
	public boolean hasOrgLogo(String id) {
172
		String orgPath = this.orgPath+"/"+id+".jpg";
173
		File file = new File(orgPath);
174
		if(file.exists()){
175
			return true;
176
		}else{
177
			return false;
178
		}
179
	}
165 180
166 181
	private File getTemplateFielName(File path, String suffix) {
167 182
		File result = null;

+ 5 - 2
src/main/java/com/ekexiu/portal/service/OrgService.java

@ -17,6 +17,7 @@ import org.jfw.util.StringUtil;
17 17
18 18
import com.ekexiu.portal.dao.OrgDao;
19 19
import com.ekexiu.portal.po.Organization;
20
import com.ekexiu.portal.pojo.EditOrganization;
20 21
21 22
@Path("/org")
22 23
public class OrgService {
@ -85,8 +86,10 @@ public class OrgService {
85 86
	
86 87
	@Get
87 88
	@Path("/{id}")
88
	public Organization query(@JdbcConn(false) Connection con ,@PathVar String id)throws SQLException{
89
		return this.orgDao.query(con, id);
89
	public EditOrganization query(@JdbcConn(false) Connection con ,@PathVar String id)throws SQLException{
90
		EditOrganization editOrg = this.orgDao.queryEditOrg(con, id);
91
		editOrg.setHasOrgLogo(this.imageService.hasOrgLogo(id));
92
		return editOrg;
90 93
	}
91 94
	
92 95
	@Get