使用Jquery实现每日签到功能(2)

package com.controller; import java.util.Date; 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 org.springframework.web.servlet.ModelAndView; import com.common.framework.controller.BaseController; import com.common.util.RequestUtil; import com.model.entity.SignEntity; import com.model.service.SignService; @Controller @RequestMapping("/sign") public class SignController extends BaseController { @Autowired private SignService signService; @RequestMapping("/doSign") public ModelAndView doSign(HttpServletRequest request, HttpServletResponse response) { ModelAndView view = super.createJsonView(); try { // 先查询是否已经签到 boolean ifHasSigned = signService.ifHasSigned(); if(ifHasSigned) { view.addObject("result", "1"); } else { SignEntity signEntity = new SignEntity(); Date signDate = new Date(); signEntity.setSignTime(signDate); signEntity.setSignDay(Long.valueOf(signDate.getDate())); signEntity.setSignIp(RequestUtil.getIpAddr(request)); signEntity.setSigner("zhoukun"); signService.signTX(signEntity); view.addObject("result", "0"); } List<SignEntity> signList = signService.listSign(); view.addObject("signList", signList); } catch (Exception e) { e.printStackTrace(); } return view; } public static void main(String[] args) { System.out.println(new Date().getDate()); } }

演示图:

使用Jquery实现每日签到功能

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgjszs.html