Browse Source

查询咨询信息记录的方法返回值添加发送者是否有头像的字段;保存头像方法添加图像裁剪。

zzy.zhiyuan.foxmail 8 years ago
parent
commit
2f01641904

+ 3 - 3
src/main/java/com/ekexiu/portal/dao/TidingsDao.java

9
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
9
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
10

10

11
import com.ekexiu.portal.po.Consult;
11
import com.ekexiu.portal.po.Consult;
12
import com.ekexiu.portal.po.Professor;
13
import com.ekexiu.portal.po.Tidings;
12
import com.ekexiu.portal.po.Tidings;
13
import com.ekexiu.portal.pojo.EditProfessor;
14

14

15
@DAO
15
@DAO
16
public abstract class TidingsDao {
16
public abstract class TidingsDao {
145
                    Tidings _result = new Tidings();
145
                    Tidings _result = new Tidings();
146
                    _result.setTidingsId(rs.getString(1));
146
                    _result.setTidingsId(rs.getString(1));
147
                    _result.setTidingsContant(rs.getString(2));
147
                    _result.setTidingsContant(rs.getString(2));
148
                    Professor professor = new Professor();
148
                    EditProfessor professor = new EditProfessor();
149
                    professor.setId(rs.getString(3));
149
                    professor.setId(rs.getString(3));
150
                    _result.setConsultId(rs.getString(4));
150
                    _result.setConsultId(rs.getString(4));
151
                    _result.setCreateTime(rs.getString(5));
151
                    _result.setCreateTime(rs.getString(5));
177
                    Tidings _obj =  new Tidings();
177
                    Tidings _obj =  new Tidings();
178
                    _obj.setTidingsId(rs.getString(1));
178
                    _obj.setTidingsId(rs.getString(1));
179
                    _obj.setTidingsContant(rs.getString(2));
179
                    _obj.setTidingsContant(rs.getString(2));
180
                    Professor professor = new Professor();
180
                    EditProfessor professor = new EditProfessor();
181
                    professor.setId(rs.getString(3));
181
                    professor.setId(rs.getString(3));
182
                    _obj.setConsultId(rs.getString(4));
182
                    _obj.setConsultId(rs.getString(4));
183
                    _obj.setCreateTime(rs.getString(5));
183
                    _obj.setCreateTime(rs.getString(5));

+ 4 - 3
src/main/java/com/ekexiu/portal/po/Tidings.java

8
import org.jfw.apt.orm.core.enums.DE;
8
import org.jfw.apt.orm.core.enums.DE;
9

9

10
import com.ekexiu.portal.basepo.CreateTimeSupported;
10
import com.ekexiu.portal.basepo.CreateTimeSupported;
11
import com.ekexiu.portal.pojo.EditProfessor;
11

12

12
@PrimaryKey("tidingsId")
13
@PrimaryKey("tidingsId")
13
@Table
14
@Table
18
	private String consultId;
19
	private String consultId;
19
	private String createTime;
20
	private String createTime;
20
	private Integer readStatus;
21
	private Integer readStatus;
21
	private Professor professor;
22
	private EditProfessor professor;
22
	private Consult consult;
23
	private Consult consult;
23
	
24
	
24
	public Professor getProfessor() {
25
	public EditProfessor getProfessor() {
25
		return professor;
26
		return professor;
26
	}
27
	}
27
	public void setProfessor(Professor professor) {
28
	public void setProfessor(EditProfessor professor) {
28
		this.professor = professor;
29
		this.professor = professor;
29
	}
30
	}
30
	
31
	

+ 14 - 13
src/main/java/com/ekexiu/portal/service/ImageService.java

143
		this.defaultResourcePhoto = defaultResourcePhoto;
143
		this.defaultResourcePhoto = defaultResourcePhoto;
144
	}
144
	}
145
	
145
	
146
	@Post
147
	@Path("/saveHead")
148
	public boolean saveImage(String id, String base64) throws IOException {
149
		Base64 bs64 = new Base64();
150
		byte[] bs = bs64.decode(base64.getBytes("UTF-8"));
151
		String fileName=this.headPath+"/"+id+".jpg";
152
		FileOutputStream fos = new FileOutputStream(fileName);
153
		fos.write(bs);
154
		fos.flush();
155
		fos.close();
156
		return true;
157
	}
158
	
159
	/**
146
	/**
160
	 * 判断是否有专家头像
147
	 * 判断是否有专家头像
161
	 * @param id 专家ID
148
	 * @param id 专家ID
322
		IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_m.jpg")), mi, true);
309
		IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_m.jpg")), mi, true);
323
		IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_l.jpg")), li, true);
310
		IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_l.jpg")), li, true);
324
	}
311
	}
312
	
313
	@Post
314
	@Path("/saveHead")
315
	public boolean saveImage(String id, String base64) throws IOException {
316
		Base64 bs64 = new Base64();
317
		byte[] bs = bs64.decode(base64.getBytes("UTF-8"));
318
		byte[] li = this.zoomImage(bs, this.largeHeadPhotoWidth, this.largeHeadPhotoHeight);
319
		byte[] mi = this.zoomImage(bs, this.middleHeadPhotoWidth, this.middleHeadPhotoHeight);
320
		byte[] si = this.zoomImage(bs, this.smallHeadPhotoWidth, this.smallHeadPhotoHeight);
321
		IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_s.jpg")), si, true);
322
		IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_m.jpg")), mi, true);
323
		IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_l.jpg")), li, true);
324
		return true;
325
	}
325
326
326
}
327
}

+ 6 - 2
src/main/java/com/ekexiu/portal/service/TidingsService.java

99
	
99
	
100
	@Get
100
	@Get
101
	@Path("/qacon")
101
	@Path("/qacon")
102
	public List<Tidings> queryCon(@JdbcConn Connection con, String consultId) throws SQLException {
102
	public List<Tidings> queryCon(@JdbcConn(true) Connection con, String consultId) throws SQLException {
103
		this.consultDao.updateReadStatus(con, consultId);
103
		this.consultDao.updateReadStatus(con, consultId);
104
		return this.tidingsDao.queryCon(con, consultId);
104
		List<Tidings> tidings = this.tidingsDao.queryCon(con, consultId);
105
		for (Tidings tiding : tidings) {
106
			tiding.getProfessor().setHasHeadImage(this.imageService.hasProfessorImage(tiding.getProfessor().getId()));
107
		}
108
		return tidings;
105
	}
109
	}
106
}
110
}