|
|
|
@ -1,8 +1,16 @@
|
|
|
|
|
package com.backoffice.m.bf_daily_nutrition;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
@ -18,6 +26,8 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
|
|
|
|
import com.backoffice.admin.code_group.code_item.A_Code_itemBO;
|
|
|
|
@ -30,6 +40,9 @@ import com.backoffice.m.bf_food.M_Bf_foodBO;
|
|
|
|
|
import com.backoffice.m.bf_growth.M_Bf_growthBO;
|
|
|
|
|
import com.backoffice.m.member_env.M_Member_envBO;
|
|
|
|
|
import com.backoffice.m.util.M_Util;
|
|
|
|
|
import com.fasterxml.jackson.core.JsonParseException;
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.renastudio.creative.web.util.AbstractControllerManager;
|
|
|
|
|
import com.renastudio.creative.web.util.DataMap;
|
|
|
|
|
import com.renastudio.creative.web.util.RenaStringUtil;
|
|
|
|
@ -37,6 +50,7 @@ import com.renastudio.creative.web.util.date.DateUtil;
|
|
|
|
|
import com.renastudio.creative.web.util.file.FileAgent;
|
|
|
|
|
import com.renastudio.creative.web.util.file.FileMeta;
|
|
|
|
|
import com.renastudio.creative.web.util.model.PageItem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author renamaestro
|
|
|
|
@ -613,14 +627,34 @@ public class M_Bf_daily_nutritionController extends AbstractControllerManager{
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="ajax_insert_self", method=RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public HashMap<String, Object> ajax_insert_self(@ModelAttribute("model") ModelMap model, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
|
|
|
|
public HashMap<String, Object> ajax_insert_self(@ModelAttribute("model") ModelMap model, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes, MultipartHttpServletRequest mRequest ) throws JsonParseException, JsonMappingException, IOException {
|
|
|
|
|
HttpSession session = request.getSession(false);
|
|
|
|
|
DataMap rm_mem = (DataMap) session.getAttribute(ConstantSystem.SESSION_RM_MEMBER);
|
|
|
|
|
|
|
|
|
|
DataMap paramMap = gmUtil.getDataMapFromRequest(request);
|
|
|
|
|
|
|
|
|
|
MultipartFile file = mRequest.getFile("attachedImage");
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
Map<String, String> map = mapper.readValue(mRequest.getParameter("fileData"), Map.class);
|
|
|
|
|
paramMap.putAll(map);
|
|
|
|
|
|
|
|
|
|
int[] arr_thumbnail_size = new int[]{300};
|
|
|
|
|
boolean[] arr_thumbnail_watermark = new boolean[]{false};
|
|
|
|
|
|
|
|
|
|
HashMap<String, FileMeta> mapFileMeta = fileAgent.uploadImage(paramMap,arr_thumbnail_size, arr_thumbnail_watermark, request, response, ConstantCode.DIR_WATERMARK_IMG, ConstantCode.DIR_WATERMARK_TXT);
|
|
|
|
|
if(mapFileMeta != null){
|
|
|
|
|
for(Entry<String, FileMeta> entry : mapFileMeta.entrySet()){
|
|
|
|
|
String key = entry.getKey();
|
|
|
|
|
FileMeta fileMeta = entry.getValue();
|
|
|
|
|
if(fileMeta != null){
|
|
|
|
|
paramMap.put("imgurl1", fileMeta.getMt_file_seq());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> result = new HashMap<String, Object>();
|
|
|
|
|
result.put("RESULT", ConstantResultCode.RESULT_INIT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
int dbc_no = (int)bf_daily_nutritionBO.insert_bf_self(paramMap);
|
|
|
|
|
result.put("dbc_no", dbc_no);
|
|
|
|
|