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  LV20 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日
最近浏览更多
草原雄鹰  LV3 4月6日
CCCCWWWW  LV4 3月27日
admin_z  LV22 1月28日
lixinsi 1月15日
暂无贡献等级
李林112233  LV2 1月12日
gnnhka  LV10 2023年12月26日
limenghaoqwer  LV2 2023年11月27日
skook7  LV2 2023年11月21日
白菜白菜菜 2023年11月19日
暂无贡献等级
钝感力  LV1 2023年10月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友