package com.fdream.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.fdream.entity.Sms;
import com.fdream.entity.User;
import com.fdream.service.ISmsService;
import com.fdream.util.DateFomat;
import com.fdream.util.RandomStringUtil;

import net.sf.json.JSONArray;
@Controller
@RequestMapping("/sms")
public class SmsController {
	@Autowired
	private ISmsService smsService;
	
	@RequestMapping("/save")
	public String save(HttpServletRequest request,HttpServletResponse response) throws Exception{
		String sconte =request.getParameter("sconte");
		String uid_a =request.getParameter("uid_a");
		String uid_b =request.getParameter("uid_b");
		String msg ="";
		String sid = RandomStringUtil.getRandomCode(10, 3);
		Sms sms =new Sms();
		sms.setSid(sid);
		sms.setSconte(sconte);
		sms.setUid_a(uid_a);
		sms.setUid_b(uid_b);
		sms.setScreatedate(DateFomat.getNowDate());
		
		if(smsService.save(sms)==true){
			msg = "{\"result\":\"评论成功!\"}";
		}else{
			msg = "{\"result\":\"评论失败!\"}";
		}
		response.setContentType("application/json");
		PrintWriter out;
		out = response.getWriter();
		out.write(msg);
		return null;
	}
	
	/**
	 * 查找所有
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/findList")
	public String findList(HttpServletRequest request,HttpServletResponse response) throws Exception{
		String id=request.getParameter("id");
		List<Sms> smsList=smsService.findList(id);
		
		JSONArray jsonArray = JSONArray.fromObject(smsList);
		response.setContentType("application/json");
		try {
			PrintWriter out = response.getWriter();
			String json = jsonArray.toString();
			out.write(json);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}
最近下载更多
ruiqiweb  LV10 2023年3月23日
lilong007  LV23 2022年10月21日
xiaoqiaothq  LV2 2022年10月16日
qwer123546  LV13 2022年9月20日
2716804680  LV9 2022年6月21日
香魔芋的头  LV2 2022年5月12日
一杯美式  LV1 2022年4月21日
171337601  LV9 2022年4月18日
qlpqlp  LV7 2022年3月13日
夜猫子111  LV2 2022年3月11日
最近浏览更多
taoshen95  LV16 2024年12月21日
ma406805131  LV19 2024年12月18日
TY0165  LV20 2024年6月25日
lxzlxzl  LV1 2024年6月21日
kevinkg  LV12 2024年5月14日
yangyuer  LV1 2024年4月26日
草原雄鹰  LV3 2024年4月6日
CCCCWWWW  LV4 2024年3月27日
admin_z  LV22 2024年1月28日
lixinsi 2024年1月15日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友