Browse Source

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

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

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

@ -9,8 +9,8 @@ import org.jfw.apt.orm.annotation.dao.DAO;
9 9
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
10 10

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

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

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

@ -8,6 +8,7 @@ import org.jfw.apt.orm.core.defaultImpl.WIntHandler;
8 8
import org.jfw.apt.orm.core.enums.DE;
9 9

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

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

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

@ -143,19 +143,6 @@ public class ImageService {
143 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 148
	 * @param id 专家ID
@ -322,5 +309,19 @@ public class ImageService {
322 309
		IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_m.jpg")), mi, true);
323 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,8 +99,12 @@ public class TidingsService {
99 99
	
100 100
	@Get
101 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 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
}