目录
一、后端
1、MeetingInfoDao
package com.zking.dao;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import com.zking.entity.MeetingInfo;
import com.zking.util.BaseDao;
import com.zking.util.PageBean;
import com.zking.util.StringUtils;
public class MeetingInfoDao extends BaseDao<MeetingInfo> {
// 添加会议信息
public int add(MeetingInfo info) throws Exception {
String sql = "insert into t_oa_meeting_info(title,content,canyuze,liexize,zhuchiren,\r\n"
+ "location,startTime,endTime,remark) values(?,?,?,?,?,?,?,?,?)";
return super.executeUpdate(sql, info, new String[] { "title", "content", "canyuze", "liexize", "zhuchiren",
"location", "startTime", "endTime", "remark" });
}
//我的会议SQL,后续其他的菜单也会使用
private String getSQL() {
return "select a.id,a.title,a.content,a.canyuze,a.liexize,a.zhuchiren\r\n" +
",b.name zhuchirenname,\r\n" +
"a.location,\r\n" +
"DATE_FORMAT(a.startTime,'%Y-%m-%d %H-%m-%s') startTime,\r\n" +
"DATE_FORMAT(a.endTime,'%Y-%m-%d %H-%m-%s') endTime,\r\n" +
"a.state,\r\n" +
"(\r\n" +
" case a.state\r\n" +
" when 0 then '取消会议'\r\n" +
" when 1 then '新建'\r\n" +
" when 2 then '待审核'\r\n" +
" when 3 then '驳回'\r\n" +
" when 4 then '待开'\r\n" +
" when 5 then '进行中'\r\n" +
" when 6 then '开启投票'\r\n" +
" when 7 then '结束会议'\r\n" +
" else '其他' end\r\n" +
") meetingstate,\r\n" +
"a.seatPic,a.remark,a.auditor,\r\n" +
"c.name auditorname\r\n" +
"from t_oa_meeting_info a\r\n" +
"inner join t_oa_user b on a.zhuchiren=b.id\r\n" +
"left join t_oa_user c on a.auditor=c.id and 1=1 ";
}
//我的会议
public List<Map<String, Object>> myInfos(MeetingInfo info, PageBean pageBean)
throws SQLException, InstantiationException, IllegalAccessException {
String sql = getSQL();
//会议标题
String title = info.getTitle();
if(StringUtils.isNotBlank(title)) {
sql+=" and title like '%"+title+"%'";
}
sql+=" and zhuchiren="+info.getZhuchiren();
return super.executeQuery(sql, pageBean);
}
// 设置会议排座图片
public int updateSeatPicById(MeetingInfo info) throws Exception {
String sql =" update t_oa_meeting_info set seatPic=? where id=?";
return super.executeUpdate(sql, info, new String[] {"seatPic","id"});
}
// 根据会议ID更新会议的审批人(送审)
public int updateAuditorById(MeetingInfo info) throws Exception {
String sql="update t_oa_meeting_info set auditor=?,state=2 where id=?";
return super.executeUpdate(sql, info, new String[] {"auditor","id"});
}
}
2、MeetingInfoAction
package com.zking.web;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.ConvertUtils;
import com.zking.dao.MeetingInfoDao;
import com.zking.entity.MeetingInfo;
import com.zking.framework.ActionSupport;
import com.zking.framework.ModelDriver;
import com.zking.util.Base64ImageUtils;
import com.zking.util.MyDateConverter;
import com.zking.util.PageBean;
import com.zking.util.PropertiesUtil;
import com.zking.util.R;
import com.zking.util.ResponseUtil;
public class MeetingInfoAction extends ActionSupport implements ModelDriver<MeetingInfo>{
private MeetingInfo info = new MeetingInfo();
private MeetingInfoDao meetingInfoDao = new MeetingInfoDao();
@Override
public MeetingInfo getModel() {
//方式二:
ConvertUtils.register(new MyDateConverter(),Date.class);
return info;
}
public String updateSeatPicById(HttpServletRequest req, HttpServletResponse resp) {
/*
* 1.接收前端页面传递到后台的图片对应的字符串
* 2.借助工具类将字符串生成一个图片,保存到配置文件所配置的路径下
* 3.添加服务器硬盘与请求地址的映射,即可访问
* 4.将请求地址保存到数据库中
*/
try {
// E:/temp/images/T280/abcdefg.png
// 获取图片的存放地址 dirPath=E:/temp/images/T280/
String dirPath = PropertiesUtil.getValue("dirPath");
// 获取浏览器请求路径,为了后续保存到数据库 serverPath=/upload/paizuo/
String serverPath = PropertiesUtil.getValue("serverPath");
// 随机生成一个图片名称
String fileName = UUID.randomUUID().toString().replaceAll("-", "")+".png";
info.getSeatPic();//图片字符串
Base64ImageUtils.GenerateImage(info.getSeatPic().replaceAll(