Commit edf2b27d authored by liuchao's avatar liuchao

no message

parent 8b7f5357
......@@ -238,10 +238,26 @@ public class RainbowPlanController extends BaseController<Object> {
RainbowPlanUser user = userDao.findByOpenid(openid);
if (user != null){
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");
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());
user.setAvatar(uploadAvatarPath + File.separator + fileName);
user.setPhone(info.getPhone());
user.setName(info.getName());
user.setNickName(info.getNickName());
......@@ -251,7 +267,6 @@ public class RainbowPlanController extends BaseController<Object> {
user.setReceiveName(info.getReceiveName());
user.setConnectTel(info.getConnectTel());
user.setReceiveAddress(info.getReceiveAddress());
user.setAvatar(uploadAvatarPath + File.separator + originalFileName);
user.setDisease(info.getDisease());
userDao.update(user);
}else {
......
package com.qiankun.controller.rainbowplan;
import java.io.File;
import java.util.List;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.qiankun.controller.base.BaseController;
......@@ -109,4 +114,73 @@ public class RainbowPlanWebController extends BaseController<Object>{
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;
}
}
......@@ -38,7 +38,12 @@ public class WishDaoImpl extends AbsDao<Wish,String> implements WishDao {
@Override
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 = "";
if (StringUtils.isNotBlank(searchStr)) {
if (StringUtils.isBlank(hql)) {
......
......@@ -2,11 +2,14 @@ package com.qiankun.vo;
import java.util.Date;
import org.springframework.web.multipart.MultipartFile;
import com.qiankun.entity.RainbowPlanUser;
public class WishVo {
private String id; //愿望ID
private String code; //愿望编号
private String title;//愿望标题
private String content;//愿望内容
private String uploadImage; //上传的图片
......@@ -26,6 +29,8 @@ public class WishVo {
private String order;
private String sort;
private Boolean reset = false;
public Date getCreateTime() {
return createTime;
}
......@@ -161,6 +166,22 @@ public class WishVo {
public void setSort(String 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=/var/tjmdp/udata
#file_path=/var/tjmdp/udata
account=admin
......
......@@ -181,4 +181,4 @@
activityHTML += '</select><button class="btn-xs" onclick="user.validateWish()">确定</button></div>';
</script>
<script src="<webpath:path/>/resources/js/rainbow/rainbowuser.js" type="text/javascript"></script>
\ No newline at end of file
<script src="<webpath:path/>/resources/js/rainbow/rainbowuser.js?v=window.number" type="text/javascript"></script>
\ No newline at end of file
......@@ -47,7 +47,7 @@
</div>
<div class="pull-right">
<select class="" id="activityId" name="activityId">
<select class="" id="activity" name="activity">
<option value="">请选择活动</option>
<c:forEach var="list" items="${activitylist}">
<option value="${list.id}" <c:if test="${wishVo.activityId==list.id}">selected</c:if>>${list.name}</option>
......@@ -76,7 +76,7 @@
<span class="lbl"></span>
</label>
</th>
<th width="">图片</th>
<th width="70">图片</th>
<th width="">小朋友</th>
<th width="10%">愿望</th>
<th width="20%">内容</th>
......@@ -86,7 +86,7 @@
<th width="">所属活动</th>
<th width="">状态</th>
<th width="5%">发布时间</th>
<!-- <th width="5%">操作</th> -->
<th width="2%">操作</th>
</tr>
</thead>
......@@ -101,11 +101,13 @@
</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/>
联系方式:${wish.children.phone}<br/>
收件人:${wish.children.receiveName} &nbsp;联系方式:${wish.children.connectTel}<br/>
收件地址:${wish.children.receiveAddress};
</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">
<c:if test="${wish.volunteer != null}">姓名:${wish.volunteer.name}<br/>
......@@ -127,23 +129,23 @@
<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">
<button class="btn btn-xs btn-info" onclick="window.location.href='<webpath:path/>/rainbow/user/add?id=${user.id}'">
<i class="icon-credit-card bigger-120"></i>
<button class="btn btn-xs btn-info" onclick="window.location.href='<webpath:path/>/rainbow/wish/view?id=${wish.id}'">
<i class="icon-edit bigger-120"></i>
</button>
&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>
</a>
</a> --%>
</div>
</td> --%>
</td>
</tr>
</c:forEach>
</tbody>
......
......@@ -41,6 +41,10 @@ var user = {
userId:"",
validateWish:function(){
var activityId = $("#activityId").val()
if (activityId == ""){
$("#message").html("请选择活动!");
return;
}
$.ajax({
type: 'POST',
url: '/rainbow/wish/validate',
......
var isSubmit = true;
$(document).ready(function(){
$("#activityId").select2({
$("#activity").select2({
placeholder : "请选择",
allowClear : true
});
......@@ -11,13 +12,48 @@ $(document).ready(function(){
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 = {
search : function(){
var activityId = $("#activityId").val();
var activityId = $("#activity").val();
var searchStr = $("#searchStr").val();
var status = $("#status").val();
var url = webPath + "/rainbow/wish/list";
......@@ -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