Commit 0be32ad9 authored by liuchao's avatar liuchao

no message

parent bf9321cc
package com.qiankun.controller;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -8,13 +9,17 @@ import javax.servlet.http.HttpServletResponse;
import com.google.common.collect.Maps;
import com.qiankun.entity.ActivityReg;
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.RequestBody;
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.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.qiankun.annotation.Auth;
......@@ -32,6 +37,9 @@ public class ActivityController extends BaseController<Object>{
@Autowired
private ActivityService activityService;
private ResourceBundle rb = ResourceBundle.getBundle("system");
private String activityImagePath = File.separator + rb.getString("activityImage");
@Auth(verifyLogin = false,verifyURL = false)
@RequestMapping(value = "/wx/api/activity/list", method = RequestMethod.POST)
public @ResponseBody Map<String, Object> listformWX(@RequestBody ActivityVo activityVo, HttpServletResponse response, HttpServletRequest request) throws Exception {
......@@ -137,15 +145,8 @@ public class ActivityController extends BaseController<Object>{
}
@Auth(verifyLogin = false,verifyURL = false)
@RequestMapping(value = "/wx/api/activity/save",method = RequestMethod.POST)
public @ResponseBody Map<String,Object> saveUserFormWX(@RequestBody ActivityVo activityVo, HttpServletResponse response, HttpServletRequest request) throws Exception{
return this.save(activityVo, response, request);
}
@RequestMapping("/api/activity/save")
public Map<String, Object> save(ActivityVo activityVo, HttpServletResponse response, HttpServletRequest request) throws Exception {
@RequestMapping(value = "/api/activity/save", method = RequestMethod.POST)
public Map<String, Object> save(@RequestParam(value = "file", required = false) MultipartFile file, ActivityVo activityVo, HttpServletResponse response, HttpServletRequest request) throws Exception {
Map<String, Object> map = new HashMap<>();
Activity activity = new Activity();
......@@ -158,6 +159,25 @@ public class ActivityController extends BaseController<Object>{
map.put("status", 2);
}
if (file != null) {
String fileFullName = file.getOriginalFilename();
String[] originalFileName = fileFullName.split("\\.");
String fileName = System.currentTimeMillis() + "." + originalFileName[originalFileName.length-1];
String rootPath = rb.getString("file_path");
if (StringUtils.isNotBlank(activity.getUploadImage())) {
File oldFile = new File(rootPath + activity.getUploadImage());
if (oldFile.isFile())
FileUtils.forceDelete(oldFile);
}
File destFile = new File(rootPath + activityImagePath,fileName);
FileUtils.writeByteArrayToFile(destFile,file.getBytes());
activity.setUploadImage(activityImagePath + File.separator + fileName);
}
activity.setAddr(activityVo.getAddr());
activity.setAvailable(activityVo.getAvailable());
activity.setContacts(activityVo.getContacts());
......
......@@ -78,8 +78,8 @@ public class RainbowPlanController extends BaseController<Object> {
@Autowired
private WxMaProperties propertis;
private ResourceBundle rb = ResourceBundle.getBundle("system");
private String uploadAvatarPath = File.separator + "rainbowplan" + File.separator + "uploadAvatar";
private String uploadWishImagePath = File.separator + "rainbowplan" + File.separator + "wishUploadImage";
private String uploadAvatarPath = File.separator + "rainbowplan" + File.separator + rb.getString("uploadAvatar");
private String uploadWishImagePath = File.separator + "rainbowplan" + File.separator + rb.getString("wishUploadImage");
private String getAppid(){
return propertis.getConfigs().get(0).getAppid();
......
......@@ -57,6 +57,10 @@ public class RainbowPlanWebController extends BaseController<Object>{
@Autowired
private ActivityService activityService;
private ResourceBundle rb = ResourceBundle.getBundle("system");
private String uploadAvatarPath = File.separator + "rainbowplan" + File.separator + rb.getString("uploadAvatar");
private String uploadWishImagePath = File.separator + "rainbowplan" + File.separator + rb.getString("wishUploadImage");
@RequestMapping("/rainbow/user/view")
public ModelAndView userAdd(String id, HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
......@@ -73,9 +77,6 @@ public class RainbowPlanWebController extends BaseController<Object>{
public ModelAndView saveUser(@RequestParam(value = "file", required = false) MultipartFile file, RainbowPlanUserVo vo, HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
String uploadImagePath = File.separator + "rainbowplan" + File.separator + "uploadAvatar";
ResourceBundle rb = ResourceBundle.getBundle("system");
RainbowPlanUser user = new RainbowPlanUser();
if (StringUtils.isBlank(vo.getId())) {
if (file == null) {
......@@ -103,9 +104,9 @@ public class RainbowPlanWebController extends BaseController<Object>{
FileUtils.forceDelete(oldFile);
}
File destFile = new File(rootPath + uploadImagePath,fileName);
File destFile = new File(rootPath + uploadAvatarPath,fileName);
FileUtils.writeByteArrayToFile(destFile,file.getBytes());
user.setAvatar(uploadImagePath + File.separator + fileName);
user.setAvatar(uploadAvatarPath + File.separator + fileName);
}
user.setName(vo.getName());
user.setConnectTel(vo.getConnectTel());
......@@ -219,9 +220,6 @@ public class RainbowPlanWebController extends BaseController<Object>{
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) {
......
......@@ -55,6 +55,8 @@ public class Activity {
private String tel; //联系电话
private String uploadImage;//活动照片路径
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL}, orphanRemoval = true, mappedBy = "activity")
@JsonIgnore
private Set<ActivityReg> activityReg = new HashSet<ActivityReg>();
......@@ -165,6 +167,14 @@ public class Activity {
this.createTime = createTime;
}
public String getUploadImage() {
return uploadImage;
}
public void setUploadImage(String uploadImage) {
this.uploadImage = uploadImage;
}
......
......@@ -18,7 +18,9 @@ tjmdp.secret=69ea7217fc5cee04f274c872a86be5e7
tjmdp.token=
tjmdp.aesKey=
tjmdp.msgDataFormat=JSON
wishUploadImage=wishUploadImage
activityImage=activityImage
uploadAvatar=uploadAvatar
nation=\u6c49\u65cf,\u8499\u53e4\u65cf,\u56de\u65cf,\u85cf\u65cf,\u7ef4\u543e\u5c14\u65cf,\u82d7\u65cf,\u5f5d\u65cf,\u58ee\u65cf,\u5e03\u4f9d\u65cf,\u671d\u9c9c\u65cf,\u6ee1\u65cf,\u4f97\u65cf,\u7476\u65cf,\u767d\u65cf,\u571f\u5bb6\u65cf,\u54c8\u5c3c\u65cf,\u54c8\u8428\u514b\u65cf,\u50a3\u65cf,\u9ece\u65cf,\u5088\u50f3\u65cf,\u4f64\u65cf,\u7572\u65cf,\u9ad8\u5c71\u65cf,\u62c9\u795c\u65cf,\u6c34\u65cf,\u4e1c\u4e61\u65cf,\u7eb3\u897f\u65cf,\u666f\u9887\u65cf,\u67ef\u5c14\u514b\u5b5c\u65cf,\u571f\u65cf,\u8fbe\u65a1\u5c14\u65cf,\u4eeb\u4f6c\u65cf,\u7f8c\u65cf,\u5e03\u6717\u65cf,\u6492\u62c9\u65cf,\u6bdb\u5357\u65cf,\u4ee1\u4f6c\u65cf,\u9521\u4f2f\u65cf,\u963f\u660c\u65cf,\u666e\u7c73\u65cf,\u5854\u5409\u514b\u65cf,\u6012\u65cf,\u4e4c\u5b5c\u522b\u514b\u65cf,\u4fc4\u7f57\u65af\u65cf,\u9102\u6e29\u514b\u65cf,\u5fb7\u6602\u65cf,\u4fdd\u5b89\u65cf,\u88d5\u56fa\u65cf,\u4eac\u65cf,\u5854\u5854\u5c14\u65cf,\u72ec\u9f99\u65cf,\u9102\u4f26\u6625\u65cf,\u8d6b\u54f2\u65cf,\u95e8\u5df4\u65cf,\u73de\u5df4\u65cf,\u57fa\u8bfa\u65cf
......
......@@ -42,6 +42,9 @@
<div class="row">
<div class="col-xs-5">
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 活动类型 </label>
......@@ -157,7 +160,18 @@
</div>
<div class="col-xs-5">
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1">图片</label>
<div class="col-sm-9">
<c:if test="${activity.uploadImage!=null}">
<img src="<webpath:path/>/wx/rainbowplan/loadResource?imageName=${activity.uploadImage}" width="200"/><br></c:if>
<input type="file" id="input_file" name="file" >
</div>
</div>
</div>
</div>
......
......@@ -99,7 +99,7 @@
<th width="">所属活动</th>
<th width="">状态</th>
<th width="5%">发布时间</th>
<th width="2%">操作</th>
<th width="5%">操作</th>
</tr>
</thead>
......@@ -145,10 +145,12 @@
<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/wish/view?id=${wish.id}'">
<i class="icon-edit bigger-120"></i>
<i class="icon-edit"></i>
</button>
&nbsp;
<button class="btn btn-xs btn-info" title="修改小朋友信息" onclick="window.location.href='<webpath:path/>/rainbow/user/view?id=${wish.children.id}'">
<i class="icon-user"></i>
</button>
<%-- <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> --%>
......
......@@ -92,30 +92,42 @@ $(document).ready(function(){
var activity = {
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('name', $('#name').val());
formData.append('type', $('#type').val());
formData.append('addr', $('#addr').val());
formData.append('content', $('#content').val());
formData.append('day', $('#day').val());
formData.append('max', $('#max').val());
formData.append('crowd', $('#crowd').val());
formData.append('available', $('#available').val());
formData.append('contacts', $('#contacts').val());
formData.append('tel', $('#tel').val());
$.ajax({
url: webPath + '/api/activity/save',
type: 'POST',
url: '/api/activity/save',
dataType:'json',
data: {
id:$('#id').val(),
name:$('#name').val(),
type:$('#type').val(),
addr:$('#addr').val(),
content:$('#content').val(),
day:$('#day').val(),
max:$('#max').val(),
crowd:$('#crowd').val(),
available:$('#available').val(),
contacts:$('#contacts').val(),
tel:$('#tel').val()
cache: false,
data: formData,
processData: false,
contentType: false,
dataType:"json",
beforeSend: function(){
},
success: function(data){
var status=data.status;
if(status==1){//注册成功
if(status==1){//成功
bootbox.dialog({
message:"新增活动成功",
buttons:{
......@@ -146,6 +158,7 @@ var activity = {
"label":"确定",
"className":"btn-sm btn-primary",
"callback": function () {
window.location.reload();
}
}
......
......@@ -118,7 +118,6 @@ var user = {
formData.append('connectTel', $('#connectTel').val());
formData.append('receiveAddress', $('#receiveAddress').val());
alert(user.type)
if(user.type == 0){
formData.append('nickName', $('#nickName').val());
formData.append('gender', $('input:radio[name="gender"]:checked').val());
......@@ -128,9 +127,6 @@ var user = {
formData.append('status', $('#status').val());
}
$.ajax({
url: webPath + "/rainbow/user/save",
type: 'POST',
......
var isSubmit = true;
$(document).ready(function(){
$("#activity").select2({
placeholder : "请选择",
placeholder : "请选择所属活动",
allowClear : true
});
......
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