Commit edf2b27d authored by liuchao's avatar liuchao

no message

parent 8b7f5357
...@@ -238,10 +238,26 @@ public class RainbowPlanController extends BaseController<Object> { ...@@ -238,10 +238,26 @@ public class RainbowPlanController extends BaseController<Object> {
RainbowPlanUser user = userDao.findByOpenid(openid); RainbowPlanUser user = userDao.findByOpenid(openid);
if (user != null){ if (user != null){
if (!info.getFile().isEmpty()){ if (!info.getFile().isEmpty()){
String originalFileName = info.getFile().getOriginalFilename(); //String originalFileName = info.getFile().getOriginalFilename();
//String rootPath = rb.getString("file_path");
//File destFile = new File(rootPath + uploadAvatarPath,originalFileName);
//FileUtils.writeByteArrayToFile(destFile,info.getFile().getBytes());
String[] originalFileName = info.getFile().getOriginalFilename().split("\\.");
String fileName = info.getUid() + "." + originalFileName[originalFileName.length-1];
String rootPath = rb.getString("file_path"); String rootPath = rb.getString("file_path");
File destFile = new File(rootPath + uploadAvatarPath,originalFileName); if (StringUtils.isNotBlank(user.getAvatar())) {
File oldFile = new File(rootPath + user.getAvatar());
FileUtils.forceDelete(oldFile);
}
File destFile = new File(rootPath + uploadWishImagePath,fileName);
FileUtils.writeByteArrayToFile(destFile,info.getFile().getBytes()); FileUtils.writeByteArrayToFile(destFile,info.getFile().getBytes());
user.setAvatar(uploadAvatarPath + File.separator + fileName);
user.setPhone(info.getPhone()); user.setPhone(info.getPhone());
user.setName(info.getName()); user.setName(info.getName());
user.setNickName(info.getNickName()); user.setNickName(info.getNickName());
...@@ -251,7 +267,6 @@ public class RainbowPlanController extends BaseController<Object> { ...@@ -251,7 +267,6 @@ public class RainbowPlanController extends BaseController<Object> {
user.setReceiveName(info.getReceiveName()); user.setReceiveName(info.getReceiveName());
user.setConnectTel(info.getConnectTel()); user.setConnectTel(info.getConnectTel());
user.setReceiveAddress(info.getReceiveAddress()); user.setReceiveAddress(info.getReceiveAddress());
user.setAvatar(uploadAvatarPath + File.separator + originalFileName);
user.setDisease(info.getDisease()); user.setDisease(info.getDisease());
userDao.update(user); userDao.update(user);
}else { }else {
......
package com.qiankun.controller.rainbowplan; package com.qiankun.controller.rainbowplan;
import java.io.File;
import java.util.List; import java.util.List;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.qiankun.controller.base.BaseController; import com.qiankun.controller.base.BaseController;
...@@ -107,6 +112,75 @@ public class RainbowPlanWebController extends BaseController<Object>{ ...@@ -107,6 +112,75 @@ public class RainbowPlanWebController extends BaseController<Object>{
view.getModelMap().addAttribute("message", "no"); view.getModelMap().addAttribute("message", "no");
} }
return view;
}
@RequestMapping(value = "/rainbow/wish/save",method = RequestMethod.POST)
public ModelAndView saveWish(@RequestParam(value = "file", required = false) MultipartFile file, WishVo vo, HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
String uploadWishImagePath = File.separator + "rainbowplan" + File.separator + "wishUploadImage";
ResourceBundle rb = ResourceBundle.getBundle("system");
Wish wish = new Wish();
if (StringUtils.isBlank(vo.getId())) {
if (file == null) {
view.getModelMap().addAttribute("message", "nopic");
return view;
}
wish.setRainbowPlanUserId(vo.getRainbowPlanUserId());
wish.setActivityId(vo.getActivityId());
wish.setChildren(userDao.find(vo.getRainbowPlanUserId()));
wish.setActivity(activityService.findById(vo.getActivityId()));
wish.setVolunteer(null);
view.getModelMap().addAttribute("status", 1);
} else {
wish = wishDao.find(vo.getId());
view.getModelMap().addAttribute("status", 2);
}
if (file != null) {
String fileFullName = file.getOriginalFilename();
String[] originalFileName = fileFullName.split("\\.");
String fileName = vo.getCode() + "." + originalFileName[originalFileName.length-1];
String rootPath = rb.getString("file_path");
if (StringUtils.isNotBlank(wish.getUploadImage())) {
File oldFile = new File(rootPath + wish.getUploadImage());
if (oldFile.isFile())
FileUtils.forceDelete(oldFile);
}
File destFile = new File(rootPath + uploadWishImagePath,fileName);
FileUtils.writeByteArrayToFile(destFile,file.getBytes());
wish.setUploadImage(uploadWishImagePath + File.separator + fileName);
}
wish.setStatus(vo.getStatus());
wish.setCode(vo.getCode());
wish.setTitle(vo.getTitle());
wish.setContent(vo.getContent());
if (vo.getReset() != null && vo.getReset()) {
wish.setVolunteer(null);
wish.setExpressCode(null);
wish.setExpressCompany(null);
wish.setHelpType(0);
}
wishDao.save(wish);
return view; return view;
} }
} }
...@@ -38,7 +38,12 @@ public class WishDaoImpl extends AbsDao<Wish,String> implements WishDao { ...@@ -38,7 +38,12 @@ public class WishDaoImpl extends AbsDao<Wish,String> implements WishDao {
@Override @Override
public IPageList<Wish> findPages(String searchStr, String activityId, Integer status, String order, String sort, Hints hints) { public IPageList<Wish> findPages(String searchStr, String activityId, Integer status, String order, String sort, Hints hints) {
if (order == null){
order = " createTime ";
}
if (sort == null){
sort=" desc ";
}
String hql = ""; String hql = "";
if (StringUtils.isNotBlank(searchStr)) { if (StringUtils.isNotBlank(searchStr)) {
if (StringUtils.isBlank(hql)) { if (StringUtils.isBlank(hql)) {
......
...@@ -2,11 +2,14 @@ package com.qiankun.vo; ...@@ -2,11 +2,14 @@ package com.qiankun.vo;
import java.util.Date; import java.util.Date;
import org.springframework.web.multipart.MultipartFile;
import com.qiankun.entity.RainbowPlanUser; import com.qiankun.entity.RainbowPlanUser;
public class WishVo { public class WishVo {
private String id; //愿望ID private String id; //愿望ID
private String code; //愿望编号
private String title;//愿望标题 private String title;//愿望标题
private String content;//愿望内容 private String content;//愿望内容
private String uploadImage; //上传的图片 private String uploadImage; //上传的图片
...@@ -26,6 +29,8 @@ public class WishVo { ...@@ -26,6 +29,8 @@ public class WishVo {
private String order; private String order;
private String sort; private String sort;
private Boolean reset = false;
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
...@@ -162,6 +167,22 @@ public class WishVo { ...@@ -162,6 +167,22 @@ public class WishVo {
this.sort = sort; this.sort = sort;
} }
public Boolean getReset() {
return reset;
}
public void setReset(Boolean reset) {
this.reset = reset;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
......
#file_path=D:/file/ file_path=D:/file/
#file_path=/Users/liuyang/work/argus_work/tjmdp/udata #file_path=/Users/liuyang/work/argus_work/tjmdp/udata
file_path=/var/tjmdp/udata #file_path=/var/tjmdp/udata
account=admin account=admin
......
...@@ -181,4 +181,4 @@ ...@@ -181,4 +181,4 @@
activityHTML += '</select><button class="btn-xs" onclick="user.validateWish()">确定</button></div>'; activityHTML += '</select><button class="btn-xs" onclick="user.validateWish()">确定</button></div>';
</script> </script>
<script src="<webpath:path/>/resources/js/rainbow/rainbowuser.js" type="text/javascript"></script> <script src="<webpath:path/>/resources/js/rainbow/rainbowuser.js?v=window.number" type="text/javascript"></script>
\ No newline at end of file \ No newline at end of file
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</div> </div>
<div class="pull-right"> <div class="pull-right">
<select class="" id="activityId" name="activityId"> <select class="" id="activity" name="activity">
<option value="">请选择活动</option> <option value="">请选择活动</option>
<c:forEach var="list" items="${activitylist}"> <c:forEach var="list" items="${activitylist}">
<option value="${list.id}" <c:if test="${wishVo.activityId==list.id}">selected</c:if>>${list.name}</option> <option value="${list.id}" <c:if test="${wishVo.activityId==list.id}">selected</c:if>>${list.name}</option>
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<span class="lbl"></span> <span class="lbl"></span>
</label> </label>
</th> </th>
<th width="">图片</th> <th width="70">图片</th>
<th width="">小朋友</th> <th width="">小朋友</th>
<th width="10%">愿望</th> <th width="10%">愿望</th>
<th width="20%">内容</th> <th width="20%">内容</th>
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
<th width="">所属活动</th> <th width="">所属活动</th>
<th width="">状态</th> <th width="">状态</th>
<th width="5%">发布时间</th> <th width="5%">发布时间</th>
<!-- <th width="5%">操作</th> --> <th width="2%">操作</th>
</tr> </tr>
</thead> </thead>
...@@ -101,11 +101,13 @@ ...@@ -101,11 +101,13 @@
</td> </td>
<td title="" valign="middle"><a href="#"><img alt="" src="<webpath:path/>/wx/rainbowplan/loadResource?imageName=${wish.uploadImage}" width="60" height="60"/></a></td> <td title="" valign="middle"><a href="#"><img alt="" src="<webpath:path/>/wx/rainbowplan/loadResource?imageName=${wish.uploadImage}" width="60" height="60"/></a></td>
<td title="">姓名:${wish.children.name}&nbsp; 楼层床号:${wish.children.bedNum}<br/> <td title="">姓名:${wish.children.name}&nbsp; 楼层床号:${wish.children.bedNum}<br/>
联系方式:${wish.children.phone}<br/> 收件人:${wish.children.receiveName} &nbsp;联系方式:${wish.children.connectTel}<br/>
收件地址:${wish.children.receiveAddress}; 收件地址:${wish.children.receiveAddress};
</td> </td>
<td title="" valign="middle">${wish.title}</td> <td title="" valign="middle">
编号:${wish.code}<br>
愿望:${wish.title}</td>
<td title="" valign="middle"><div class="slim-scroll" style="overflow: hidden; width: auto; height: 65px;">${wish.content}</div></td> <td title="" valign="middle"><div class="slim-scroll" style="overflow: hidden; width: auto; height: 65px;">${wish.content}</div></td>
<td title="" valign="middle"> <td title="" valign="middle">
<c:if test="${wish.volunteer != null}">姓名:${wish.volunteer.name}<br/> <c:if test="${wish.volunteer != null}">姓名:${wish.volunteer.name}<br/>
...@@ -127,23 +129,23 @@ ...@@ -127,23 +129,23 @@
<td title="" valign="middle"><fmt:formatDate value='${wish.createTime}' pattern='yyyy-MM-dd HH:mm' /></td> <td title="" valign="middle"><fmt:formatDate value='${wish.createTime}' pattern='yyyy-MM-dd HH:mm' /></td>
<%-- <td> <td>
<div class="visible-md visible-lg hidden-sm hidden-xs btn-group"> <div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
<button class="btn btn-xs btn-info" onclick="window.location.href='<webpath:path/>/rainbow/user/add?id=${user.id}'"> <button class="btn btn-xs btn-info" onclick="window.location.href='<webpath:path/>/rainbow/wish/view?id=${wish.id}'">
<i class="icon-credit-card bigger-120"></i> <i class="icon-edit bigger-120"></i>
</button> </button>
&nbsp; &nbsp;
<a class="btn btn-xs btn-link" title="详细信息" href="<webpath:path/>/rainbow/wish/view?id=${wish.id}"> <%-- <a class="btn btn-xs btn-link" title="详细信息" href="<webpath:path/>/rainbow/wish/view?id=${wish.id}">
<i class="icon-list-alt bigger-120"></i> <i class="icon-list-alt bigger-120"></i>
</a> </a> --%>
</div> </div>
</td> --%> </td>
</tr> </tr>
</c:forEach> </c:forEach>
</tbody> </tbody>
......
...@@ -41,6 +41,10 @@ var user = { ...@@ -41,6 +41,10 @@ var user = {
userId:"", userId:"",
validateWish:function(){ validateWish:function(){
var activityId = $("#activityId").val() var activityId = $("#activityId").val()
if (activityId == ""){
$("#message").html("请选择活动!");
return;
}
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '/rainbow/wish/validate', url: '/rainbow/wish/validate',
......
var isSubmit = true;
$(document).ready(function(){ $(document).ready(function(){
$("#activityId").select2({ $("#activity").select2({
placeholder : "请选择", placeholder : "请选择",
allowClear : true allowClear : true
}); });
...@@ -11,13 +12,48 @@ $(document).ready(function(){ ...@@ -11,13 +12,48 @@ $(document).ready(function(){
railVisible:true railVisible:true
}); });
}); });
/*if ($('#wish_form').length>0){
$('#wish_form').validate({
rules : {
"title" : {
required : true
},
"content" : {
required : true
}
},
messages:{
"title" : {
required : "不能为空"
},
"content" : {
required : "不能为空"
}
},
submitHandler: function(form){
wish.save();
}
});
}*/
}) })
var wish = { var wish = {
search : function(){ search : function(){
var activityId = $("#activityId").val(); var activityId = $("#activity").val();
var searchStr = $("#searchStr").val(); var searchStr = $("#searchStr").val();
var status = $("#status").val(); var status = $("#status").val();
var url = webPath + "/rainbow/wish/list"; var url = webPath + "/rainbow/wish/list";
...@@ -137,6 +173,94 @@ var wish = { ...@@ -137,6 +173,94 @@ var wish = {
}); });
} }
}) })
},
save : function(form){
if (isSubmit){
isSubmit = false;
var formData = new FormData();
formData.append('file', $('#input_file')[0].files[0]);
formData.append('id', $('#id').val());
formData.append('code', $('#code').val());
formData.append('activityId', $('#activityId').val());
formData.append('rainbowPlanUserId', $('#rainbowPlanUserId').val());
formData.append('title', $('#title').val());
formData.append('content', $('#content').val());
formData.append('status', $('#status').val());
//console.info($('#reset'));
//alert(typeof($('#reset').val()) != "undefined");
if (typeof($('#reset').val()) != "undefined" ){
formData.append('reset', $('#reset').val());
}
$.ajax({
url: webPath + "/rainbow/wish/save",
type: 'POST',
cache: false,
data: formData,
processData: false,
contentType: false,
dataType:"json",
beforeSend: function(){
},
success : function(data) {
isSubmit = true;
var status = data.status;
var message = data.message;
if (message == "nopic"){
bootbox.dialog({
message:"请上传图片",
buttons:{
"success":{
"label":"确定",
"className":"btn-sm btn-primary",
"callback": function () {
}
}
}
});
}
if (status == 1){
bootbox.dialog({
message:"保存成功",
buttons:{
"success":{
"label":"确定",
"className":"btn-sm btn-primary",
"callback": function () {
history.go(-1);
}
}
}
});
}
if (status == 2){
bootbox.dialog({
message:"修改成功",
buttons:{
"success":{
"label":"确定",
"className":"btn-sm btn-primary",
"callback": function () {
window.location.reload();
}
}
}
});
}
}
})
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment