105 lines
3.8 KiB
Plaintext
105 lines
3.8 KiB
Plaintext
package com.nationalelectric.greenH5;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
|
import org.codehaus.jackson.type.TypeReference;
|
|
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.ResponseBody;
|
|
|
|
import com.nationalelectirc.Constant.Constant;
|
|
import com.nationalelectirc.utils.RestResult;
|
|
import com.nationalelectric.greenH5.po.GreenUserInfo;
|
|
import com.nationalelectric.greenH5.po.Result;
|
|
|
|
@Controller
|
|
@RequestMapping("/greenHealthMsg")
|
|
public class GreenHealthMsgController extends GreenBaseController {
|
|
|
|
/**
|
|
* 查询健康知识资讯类别
|
|
*
|
|
* @param result
|
|
* @return
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
@RequestMapping(value = "/getHealthMsgType", method = RequestMethod.POST)
|
|
public @ResponseBody RestResult getHealthMsgType(@RequestBody Map<String,Object> map) {
|
|
try {
|
|
///String data_type = map.get("data_type").toString();
|
|
String sql = "select data_value,data_code from green_dictionary_info where data_type='healthmsgcate' and is_deleted='N' order by data_sort";
|
|
List<Map<String,Object>> list = hibernateDao.queryForListWithSql(sql.toString());
|
|
return new RestResult(Constant.SUCCESS, "查询成功", list);
|
|
}catch (Exception e) {
|
|
e.printStackTrace();
|
|
return new RestResult(Constant.FAILED, "查询失败!");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 查询健康知识资讯列表
|
|
*
|
|
* @param result
|
|
* @return
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
@RequestMapping(value = "/getHealthMsgList", method = RequestMethod.POST)
|
|
public @ResponseBody RestResult getHealthMsgList(@RequestBody Map<String,Object> map) {
|
|
try {
|
|
///String data_type = map.get("data_type").toString();
|
|
Integer pageSize = (Integer) map.get("pageSize");
|
|
Integer page = (Integer) map.get("pageNum");
|
|
String infoType = (String)map.get("infoType");
|
|
page = (page-1) * pageSize;
|
|
int limit = ((page > 0 ? page : 1) -1) * pageSize;
|
|
String cate = (String)map.get("cate");
|
|
//and cate=? cate,
|
|
String sql = "SELECT * FROM(SELECT RN.*,ROWNUM rw FROM("
|
|
+ " select ID as \"id\",title as \"title\",type as \"type\",create_time as \"create_time\", "
|
|
+ " forward_url as \"forward_url\",info_type as \"info_type\" "
|
|
+ "from green_health_msg "
|
|
+ "where is_del='1' and status='1' and info_type=? order by update_time desc "
|
|
+ " )rn ) WHERE rw > ? AND rw <= ? ";
|
|
List<Map<String,Object>> list = hibernateDao.queryForListWithSql(sql.toString(),new Object[]{ infoType, limit, pageSize});
|
|
return new RestResult(Constant.SUCCESS, "查询成功", list);
|
|
}catch (Exception e) {
|
|
e.printStackTrace();
|
|
return new RestResult(Constant.FAILED, "查询失败!");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 查询健康知识资讯详情
|
|
*
|
|
* @param result
|
|
* @return
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
@RequestMapping(value = "/getHealthMsgDetail", method = RequestMethod.POST)
|
|
public @ResponseBody RestResult getHealthMsgDetail(@RequestBody Map<String,Object> map) {
|
|
try {
|
|
String id = (String) map.get("id");
|
|
|
|
String sql = "select title as \"title\" ,content as \"content\",create_time as \"create_time\",info_type as \"info_type\" from green_health_msg where id=?";
|
|
List<Map<String,Object>> list = hibernateDao.queryForListWithSql(sql.toString(),new Object[]{ id});
|
|
if(list.size()==0){
|
|
return new RestResult(Constant.FAILED, "查无该数据!");
|
|
}
|
|
return new RestResult(Constant.SUCCESS, "查询成功", list.get(0));
|
|
}catch (Exception e) {
|
|
e.printStackTrace();
|
|
return new RestResult(Constant.FAILED, "查询失败!");
|
|
}
|
|
}
|
|
|
|
|
|
}
|