parent
a97d216194
commit
c6f2bfa06f
@ -0,0 +1,85 @@ |
||||
<%-- |
||||
Created by IntelliJ IDEA. |
||||
User: pan |
||||
Date: 2020/6/10 0010 |
||||
Time: 6:46 |
||||
To change this template use File | Settings | File Templates. |
||||
--%> |
||||
<%@ page language="java" pageEncoding="UTF-8"%> |
||||
|
||||
<%@ taglib uri="/struts-tags" prefix="s"%> |
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> |
||||
<% |
||||
String path = request.getContextPath(); |
||||
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; |
||||
%> |
||||
<html> |
||||
<head> |
||||
<c:import url="../head.jsp"/> |
||||
<script> |
||||
function validateIt(inputelement){ |
||||
if(inputelement.validity.patternMismatch){ |
||||
inputelement.setCustomValidity('只允许输入英文字母'); |
||||
}else{ |
||||
inputelement.setCustomValidity(''); //输入内容符合验证条件 |
||||
} |
||||
return true; |
||||
} |
||||
</script> |
||||
</head> |
||||
<body> |
||||
<div class="box round first" style="margin:15px;"> |
||||
<h2>录入数据</h2> |
||||
<div class="block"> |
||||
<form method="POST" action="<%=basePath%>admin/material/add.do"> |
||||
<table class="form"> |
||||
<tbody> |
||||
<tr> |
||||
<td class="col1"> |
||||
<label>资料名</label> |
||||
</td> |
||||
<td class="col3"> |
||||
<input name="applicationMaterial.materialName" required value="" type="text" class="medium"> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td class="col1"> |
||||
<label>资料类型</label> |
||||
</td> |
||||
<td class="col3"> |
||||
<select name="applicationMaterial.formType" required class="medium"> |
||||
<option value="">请选择资料类型</option> |
||||
<option value="text">文本</option> |
||||
<option value="doc">图片</option> |
||||
</select> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td class="col1"> |
||||
<label>资料表单名</label> |
||||
</td> |
||||
<td class="col3"> |
||||
<input name="applicationMaterial.formName" required class="medium" pattern="[a-zA-Z]+" oninvalid="validateIt(this)" oninput="validateIt(this)"/> |
||||
<span class="text-danger">只允许输入英文字母</span> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td class="col1"> |
||||
<label>资料表单顺序</label> |
||||
</td> |
||||
<td class="col3"> |
||||
<input name="applicationMaterial.formOrder" class="medium" type="number" min="0"> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td colspan="2"> |
||||
<button type="submit" class="btn btn-blue">提交数据</button> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</table> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,84 @@ |
||||
<%-- |
||||
Created by IntelliJ IDEA. |
||||
User: pan |
||||
Date: 2020/6/10 0010 |
||||
Time: 6:46 |
||||
To change this template use File | Settings | File Templates. |
||||
--%> |
||||
<%@ page language="java" pageEncoding="UTF-8"%> |
||||
|
||||
<%@ taglib uri="/struts-tags" prefix="s"%> |
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> |
||||
<% |
||||
String path = request.getContextPath(); |
||||
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; |
||||
%> |
||||
<html> |
||||
<head> |
||||
<c:import url="../head.jsp"/> |
||||
<script> |
||||
function validateIt(inputelement){ |
||||
if(inputelement.validity.patternMismatch){ |
||||
inputelement.setCustomValidity('只允许输入英文字母'); |
||||
}else{ |
||||
inputelement.setCustomValidity(''); //输入内容符合验证条件 |
||||
} |
||||
return true; |
||||
} |
||||
</script> |
||||
</head> |
||||
<body> |
||||
<div class="box round first" style="margin:15px;"> |
||||
<h2>录入数据</h2> |
||||
<div class="block"> |
||||
<form method="POST" action="<%=basePath%>admin/material/update.do"> |
||||
<table class="form"> |
||||
<tbody> |
||||
<tr> |
||||
<td class="col1"> |
||||
<label>资料名</label> |
||||
</td> |
||||
<td class="col3"> |
||||
<input name="applicationMaterial.materialName" required value="${model.materialName}" type="text" class="medium"> |
||||
</td> |
||||
</tr> |
||||
<%-- <tr>--%> |
||||
<%-- <td class="col1">--%> |
||||
<%-- <label>资料类型</label>--%> |
||||
<%-- </td>--%> |
||||
<%-- <td class="col3">--%> |
||||
<%-- <input readonly value="--%> |
||||
<%--<c:choose>--%> |
||||
<%-- <c:when test="${model.formType eq 'text'}">文本</c:when>--%> |
||||
<%-- <c:when test="${model.formType eq 'doc'}">文件</c:when>--%> |
||||
<%--</c:choose>" type="text" class="medium">--%> |
||||
<%-- </td>--%> |
||||
<%-- </tr>--%> |
||||
<%-- <tr>--%> |
||||
<%-- <td class="col1">--%> |
||||
<%-- <label>资料表单名</label>--%> |
||||
<%-- </td>--%> |
||||
<%-- <td class="col3">--%> |
||||
<%-- <input readonly value="${model.formName}" type="text" class="medium">--%> |
||||
<%-- </td>--%> |
||||
<%-- </tr>--%> |
||||
<tr> |
||||
<td class="col1"> |
||||
<label>资料表单顺序</label> |
||||
</td> |
||||
<td class="col3"> |
||||
<input name="applicationMaterial.formOrder" value="${model.formOrder}" class="medium" type="number" min="0"> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td colspan="2"> |
||||
<button type="submit" class="btn btn-blue">更新数据</button> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</table> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,59 @@ |
||||
<%-- |
||||
Created by IntelliJ IDEA. |
||||
User: pan |
||||
Date: 2020/6/10 0010 |
||||
Time: 13:05 |
||||
To change this template use File | Settings | File Templates. |
||||
--%> |
||||
<%@ page language="java" pageEncoding="UTF-8"%> |
||||
|
||||
<%@ taglib uri="/struts-tags" prefix="s"%> |
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> |
||||
<% |
||||
String path = request.getContextPath(); |
||||
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; |
||||
%> |
||||
<html> |
||||
<head> |
||||
<c:import url="../head.jsp"/> |
||||
<style> |
||||
img:hover{ |
||||
width: auto; |
||||
height: auto; |
||||
} |
||||
img{ |
||||
width: 100px; |
||||
height: 100px; |
||||
} |
||||
</style> |
||||
</head> |
||||
<body> |
||||
<div class="box round first" style="margin:15px;"> |
||||
<table> |
||||
<thead> |
||||
<tr> |
||||
<th>资料名</th> |
||||
<th>内容</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<c:forEach items="${materialList}" var="item"> |
||||
<tr> |
||||
<td class="align-middle">${item.materialName}</td> |
||||
<td> |
||||
<c:choose> |
||||
<c:when test="${item.formType eq 'text'}">${item.formValue}</c:when> |
||||
<c:when test="${item.formType eq 'doc'}"> |
||||
<img src="<%=basePath%>${item.formValue}" /> |
||||
</c:when> |
||||
</c:choose> |
||||
</td> |
||||
</tr> |
||||
</c:forEach> |
||||
</tbody> |
||||
</table> |
||||
|
||||
<button onclick="history.back()" class="btn-block col-1 ml-auto mr-auto">返回</button> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,190 @@ |
||||
package com.app.action; |
||||
|
||||
import com.app.bean.ApplicationMaterial; |
||||
import com.app.bean.UserMaterial; |
||||
import com.app.service.ConstantsService; |
||||
import com.app.service.MaterialService; |
||||
import com.app.utils.Constants; |
||||
import com.app.utils.StateType; |
||||
import com.opensymphony.xwork2.ActionContext; |
||||
import org.apache.log4j.Logger; |
||||
import org.apache.struts2.ServletActionContext; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Controller; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
@Controller |
||||
public class MaterialAction { |
||||
|
||||
@Autowired |
||||
private MaterialService materialService; |
||||
|
||||
private static final Logger logger= Logger.getLogger(MaterialAction.class); |
||||
|
||||
private StateType state; |
||||
|
||||
private String message; |
||||
|
||||
private UserMaterial userMaterial; |
||||
|
||||
private ApplicationMaterial applicationMaterial; |
||||
|
||||
private Integer applyId; |
||||
|
||||
@Autowired |
||||
private ConstantsService constantsService; |
||||
|
||||
/** |
||||
* 申请资料定义列表 |
||||
* @return 资料 |
||||
*/ |
||||
public String materialList(){ |
||||
ActionContext actionContext=ActionContext.getContext(); |
||||
HttpServletRequest request= ServletActionContext.getRequest(); |
||||
String result; |
||||
try { |
||||
actionContext.put(Constants.LIST,materialService.materialList()); |
||||
result= Constants.SUCCESS; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
logger.error(e); |
||||
result=Constants.ERROR; |
||||
} |
||||
this.setState(request.getParameter(Constants.STATE) == null ? null : StateType.valueOf(request.getParameter(Constants.STATE))); |
||||
this.setMessage(request.getParameter(Constants.MESSAGE)); |
||||
constantsService.initMaterial(); |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 添加申请资料定义 |
||||
* @return 返回添加结果 |
||||
*/ |
||||
public String addMaterial(){ |
||||
if(applicationMaterial==null||applicationMaterial.getFormName()==null||applicationMaterial.getFormName().isEmpty() |
||||
||applicationMaterial.getFormType()==null||applicationMaterial.getFormType().isEmpty()||!materialService.addMaterial(applicationMaterial)){ |
||||
this.setState(StateType.error); |
||||
this.setMessage("添加申请资料失败"); |
||||
return Constants.ERROR; |
||||
}else{ |
||||
this.setState(StateType.success); |
||||
this.setMessage("添加申请资料成功"); |
||||
return Constants.SUCCESS; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 更新申请资料定义 |
||||
* @return 返回更新结果 |
||||
*/ |
||||
public String toUpdate(){ |
||||
ActionContext act=ActionContext.getContext(); |
||||
ApplicationMaterial material; |
||||
if(applicationMaterial==null||applicationMaterial.getId()==null||(material=materialService.find(applicationMaterial.getId()))==null){ |
||||
this.setState(StateType.error); |
||||
this.setMessage("进入编辑申请资料失败"); |
||||
return Constants.ERROR; |
||||
}else { |
||||
act.put(Constants.MODEL,material); |
||||
return Constants.SUCCESS; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 删除申请资料定义 |
||||
* @return 返回删除结果 |
||||
*/ |
||||
public String deleteMaterial(){ |
||||
if(applicationMaterial==null||applicationMaterial.getId()==null||!materialService.deleteMaterial(applicationMaterial.getId())){ |
||||
this.setState(StateType.error); |
||||
this.setMessage("删除申请资料失败"); |
||||
return Constants.ERROR; |
||||
}else{ |
||||
this.setState(StateType.success); |
||||
this.setMessage("删除申请资料成功"); |
||||
return Constants.SUCCESS; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 更新申请资料定义 |
||||
* @return 返回更新结果 |
||||
*/ |
||||
public String updateMaterial(){ |
||||
if(applicationMaterial==null||applicationMaterial.getId()==null||applicationMaterial.getFormOrder()==null |
||||
||applicationMaterial.getMaterialName()==null||!materialService.updateMaterial(applicationMaterial)){ |
||||
this.setState(StateType.error); |
||||
this.setMessage("更新申请资料失败"); |
||||
return Constants.ERROR; |
||||
}else{ |
||||
this.setState(StateType.success); |
||||
this.setMessage("更新申请资料成功"); |
||||
return Constants.SUCCESS; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 查看用户申请资料 |
||||
* @return 返回列表 |
||||
*/ |
||||
public String findMaterial(){ |
||||
ActionContext act=ActionContext.getContext(); |
||||
if(applyId==null){ |
||||
this.setState(StateType.error); |
||||
this.setMessage("查看失败"); |
||||
return Constants.ERROR; |
||||
}else{ |
||||
act.put("materialList",materialService.export(applyId)); |
||||
return Constants.SUCCESS; |
||||
} |
||||
} |
||||
|
||||
public Integer getApplyId() { |
||||
return applyId; |
||||
} |
||||
|
||||
public void setApplyId(Integer applyId) { |
||||
this.applyId = applyId; |
||||
} |
||||
|
||||
public MaterialService getMaterialService() { |
||||
return materialService; |
||||
} |
||||
|
||||
public void setMaterialService(MaterialService materialService) { |
||||
this.materialService = materialService; |
||||
} |
||||
|
||||
public StateType getState() { |
||||
return state; |
||||
} |
||||
|
||||
public void setState(StateType state) { |
||||
this.state = state; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
|
||||
public void setMessage(String message) { |
||||
this.message = message; |
||||
} |
||||
|
||||
public UserMaterial getUserMaterial() { |
||||
return userMaterial; |
||||
} |
||||
|
||||
public void setUserMaterial(UserMaterial userMaterial) { |
||||
this.userMaterial = userMaterial; |
||||
} |
||||
|
||||
public ApplicationMaterial getApplicationMaterial() { |
||||
return applicationMaterial; |
||||
} |
||||
|
||||
public void setApplicationMaterial(ApplicationMaterial applicationMaterial) { |
||||
this.applicationMaterial = applicationMaterial; |
||||
} |
||||
} |
@ -0,0 +1,65 @@ |
||||
package com.app.bean; |
||||
|
||||
import javax.persistence.*; |
||||
|
||||
@Entity |
||||
@Table(name = "application_material") |
||||
public class ApplicationMaterial { |
||||
private Integer id; |
||||
private String formName; |
||||
private String formType; |
||||
private Integer formOrder; |
||||
private String materialName; |
||||
|
||||
@Id |
||||
@Column(name = "id") |
||||
@SequenceGenerator(name="increment") |
||||
@GeneratedValue(strategy=GenerationType.IDENTITY) |
||||
public Integer getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(Integer id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
@Basic |
||||
@Column(name = "form_name") |
||||
public String getFormName() { |
||||
return formName; |
||||
} |
||||
|
||||
public void setFormName(String formName) { |
||||
this.formName = formName; |
||||
} |
||||
|
||||
@Basic |
||||
@Column(name = "form_type") |
||||
public String getFormType() { |
||||
return formType; |
||||
} |
||||
|
||||
public void setFormType(String formType) { |
||||
this.formType = formType; |
||||
} |
||||
|
||||
@Basic |
||||
@Column(name = "form_order") |
||||
public Integer getFormOrder() { |
||||
return formOrder; |
||||
} |
||||
|
||||
public void setFormOrder(Integer formOrder) { |
||||
this.formOrder = formOrder; |
||||
} |
||||
|
||||
@Basic |
||||
@Column(name = "material_name") |
||||
public String getMaterialName() { |
||||
return materialName; |
||||
} |
||||
|
||||
public void setMaterialName(String materialName) { |
||||
this.materialName = materialName; |
||||
} |
||||
} |
@ -0,0 +1,86 @@ |
||||
package com.app.bean; |
||||
|
||||
import javax.persistence.*; |
||||
|
||||
@Entity |
||||
@Table(name = "user_material") |
||||
public class UserMaterial { |
||||
private Integer id; |
||||
private Integer userId; |
||||
private Integer formId; |
||||
private String formValue; |
||||
private Integer applyId; |
||||
|
||||
private String formType; |
||||
private String materialName; |
||||
|
||||
@Id |
||||
@Column(name = "id") |
||||
@SequenceGenerator(name="increment") |
||||
@GeneratedValue(strategy=GenerationType.IDENTITY) |
||||
public Integer getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(Integer id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
@Basic |
||||
@Column(name = "user_id") |
||||
public Integer getUserId() { |
||||
return userId; |
||||
} |
||||
|
||||
public void setUserId(Integer userId) { |
||||
this.userId = userId; |
||||
} |
||||
|
||||
@Basic |
||||
@Column(name = "form_id") |
||||
public Integer getFormId() { |
||||
return formId; |
||||
} |
||||
|
||||
public void setFormId(Integer formId) { |
||||
this.formId = formId; |
||||
} |
||||
|
||||
@Basic |
||||
@Column(name = "form_value") |
||||
public String getFormValue() { |
||||
return formValue; |
||||
} |
||||
|
||||
public void setFormValue(String formValue) { |
||||
this.formValue = formValue; |
||||
} |
||||
|
||||
@Basic |
||||
@Column(name="apply_id") |
||||
public Integer getApplyId() { |
||||
return applyId; |
||||
} |
||||
|
||||
public void setApplyId(Integer applyId) { |
||||
this.applyId = applyId; |
||||
} |
||||
|
||||
@Transient |
||||
public String getFormType() { |
||||
return formType; |
||||
} |
||||
|
||||
public void setFormType(String formType) { |
||||
this.formType = formType; |
||||
} |
||||
|
||||
@Transient |
||||
public String getMaterialName() { |
||||
return materialName; |
||||
} |
||||
|
||||
public void setMaterialName(String materialName) { |
||||
this.materialName = materialName; |
||||
} |
||||
} |
@ -0,0 +1,36 @@ |
||||
package com.app.service; |
||||
|
||||
import com.app.bean.ApplicationMaterial; |
||||
import com.app.bean.UserMaterial; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface MaterialService { |
||||
|
||||
//获取申请资料定义列表
|
||||
List<ApplicationMaterial> materialList(); |
||||
|
||||
//增加申请资料定义
|
||||
boolean addMaterial(ApplicationMaterial applicationMaterial); |
||||
|
||||
//查找申请资料
|
||||
ApplicationMaterial find(Integer id); |
||||
|
||||
//更新申请资料定义顺序
|
||||
boolean updateMaterial(ApplicationMaterial applicationMaterial); |
||||
|
||||
//删除申请资料定义
|
||||
boolean deleteMaterial(Integer id); |
||||
|
||||
//用户提交申请资料
|
||||
boolean submitMaterial(UserMaterial userMaterial); |
||||
|
||||
//用户编辑申请资料
|
||||
boolean updateMaterial(UserMaterial userMaterial); |
||||
|
||||
//删除用户申请资料
|
||||
boolean deleteUserMaterial(Integer userId); |
||||
|
||||
//查找用户申请资料
|
||||
List<UserMaterial> export(Integer applyId); |
||||
} |
@ -0,0 +1,135 @@ |
||||
package com.app.service; |
||||
|
||||
import com.app.bean.ApplicationMaterial; |
||||
import com.app.bean.UserMaterial; |
||||
import org.apache.log4j.Logger; |
||||
import org.hibernate.HibernateException; |
||||
import org.hibernate.Query; |
||||
import org.hibernate.Session; |
||||
import org.hibernate.criterion.DetachedCriteria; |
||||
import org.hibernate.criterion.Order; |
||||
import org.hibernate.transform.Transformers; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.dao.DataAccessException; |
||||
import org.springframework.orm.hibernate3.HibernateCallback; |
||||
import org.springframework.orm.hibernate3.HibernateTemplate; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.sql.SQLException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@Service |
||||
@Transactional |
||||
public class MaterialServiceImpl implements MaterialService{ |
||||
|
||||
private static final Logger logger= Logger.getLogger(MaterialServiceImpl.class); |
||||
|
||||
@Autowired |
||||
private HibernateTemplate hibernateTemplate; |
||||
|
||||
@Override |
||||
public List<ApplicationMaterial> materialList() { |
||||
try { |
||||
return (List<ApplicationMaterial>) hibernateTemplate.findByCriteria(DetachedCriteria.forClass(ApplicationMaterial.class).addOrder(Order.asc("formOrder"))); |
||||
} catch (DataAccessException e) { |
||||
e.printStackTrace(); |
||||
logger.error(e); |
||||
} |
||||
return new ArrayList<>(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean addMaterial(ApplicationMaterial applicationMaterial) { |
||||
try { |
||||
ApplicationMaterial c=new ApplicationMaterial(); |
||||
c.setFormName(applicationMaterial.getFormName()); |
||||
c.setFormOrder(applicationMaterial.getFormOrder()); |
||||
c.setMaterialName(applicationMaterial.getMaterialName()); |
||||
c.setFormType(applicationMaterial.getFormType()); |
||||
return hibernateTemplate.save(c)!=null; |
||||
} catch (DataAccessException e) { |
||||
e.printStackTrace(); |
||||
logger.error(e); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public boolean deleteMaterial(final Integer id) { |
||||
return (boolean) hibernateTemplate.execute(new HibernateCallback() { |
||||
public Object doInHibernate(Session session) throws HibernateException { |
||||
Query query = session.createQuery("delete from ApplicationMaterial where id=?"); |
||||
query.setInteger(0,id); |
||||
return query.executeUpdate()>0; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public boolean updateMaterial(final ApplicationMaterial applicationMaterial) { |
||||
return (boolean) hibernateTemplate.execute(new HibernateCallback() { |
||||
public Object doInHibernate(Session session) throws HibernateException { |
||||
Query query = session.createQuery("update ApplicationMaterial set formOrder=?,materialName=? where id=?"); |
||||
query.setInteger(0,applicationMaterial.getFormOrder()); |
||||
query.setString(1,applicationMaterial.getMaterialName()); |
||||
query.setInteger(2,applicationMaterial.getId()); |
||||
return query.executeUpdate()>0; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public ApplicationMaterial find(Integer id) { |
||||
return (ApplicationMaterial) hibernateTemplate.get(ApplicationMaterial.class,id); |
||||
} |
||||
|
||||
@Override |
||||
public boolean submitMaterial(UserMaterial userMaterial) { |
||||
try { |
||||
return hibernateTemplate.save(userMaterial)!=null; |
||||
} catch (DataAccessException e) { |
||||
e.printStackTrace(); |
||||
logger.error(e); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public boolean updateMaterial(UserMaterial userMaterial) { |
||||
try { |
||||
hibernateTemplate.update(userMaterial); |
||||
return true; |
||||
} catch (DataAccessException e) { |
||||
e.printStackTrace(); |
||||
logger.error(e); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public boolean deleteUserMaterial(final Integer userId) { |
||||
return (boolean) hibernateTemplate.execute(new HibernateCallback() { |
||||
public Object doInHibernate(Session session) throws HibernateException { |
||||
Query query = session.createQuery("delete from UserMaterial where userId=?"); |
||||
query.setInteger(0,userId); |
||||
return query.executeUpdate()>0; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@SuppressWarnings("unchecked") |
||||
@Override |
||||
public List<UserMaterial> export(final Integer applyId) { |
||||
return (List<UserMaterial>) hibernateTemplate.execute(new HibernateCallback() { |
||||
@Override |
||||
public Object doInHibernate(Session session) throws HibernateException, SQLException { |
||||
Query query = session.createQuery("select u.formValue as formValue,a.materialName as materialName,a.formType as formType from UserMaterial u,ApplicationMaterial a " + |
||||
"where u.formId=a.id and u.applyId=? order by a.formOrder").setResultTransformer(Transformers.aliasToBean(UserMaterial.class)); |
||||
query.setInteger(0,applyId); |
||||
return query.list(); |
||||
} |
||||
}); |
||||
} |
||||
} |
Loading…
Reference in new issue