package com.yx.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageInfo;
import com.yx.model.Clockin;
import com.yx.model.Clockinnew;
import com.yx.model.Owner;
import com.yx.model.Userinfo;
import com.yx.service.IClockInNewService;
import com.yx.service.IOwnerService;
import com.yx.util.JsonObject;
import com.yx.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author yx
* @since 2021-04-27
*/
@Api(tags = {""})
@RestController
@RequestMapping("/clockinnew")
public class ClockInNewController {
private Logger log = LoggerFactory.getLogger(getClass());
@Resource
private IClockInNewService clockinnewService;
@Resource
private IOwnerService ownerService;
@RequestMapping("/queryClockInAll")
public JsonObject queryClockInAll(Clockinnew clockinnew,String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "15") Integer pageSize
){
if(name!=null){
Owner owner = new Owner();
owner.setUsername(name);
clockinnew.setOwner(owner);
}
PageInfo<Clockinnew> pageInfo= clockinnewService.queryClockInAll(pageNum,pageSize,clockinnew);
return new JsonObject(0,"ok",pageInfo.getTotal(),pageInfo.getList());
}
@RequestMapping("/queryClockInAll2")
public JsonObject queryClockInAll2(Clockinnew clockinnew, HttpServletRequest request,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "15") Integer pageSize
){
//获取当前得登录用户
Userinfo userinfo= (Userinfo) request.getSession().getAttribute("user");
String username=userinfo.getUsername();
//根据username获取登录账号得业主id
Owner owner=ownerService.queryOwnerByName(username);
clockinnew.setOwnerId(owner.getId());
PageInfo<Clockinnew> pageInfo= clockinnewService.queryClockInAll(pageNum,pageSize,clockinnew);
return new JsonObject(0,"ok",pageInfo.getTotal(),pageInfo.getList());
}
@RequestMapping("/queryOwner")
public List<Owner> queryOwner(HttpServletRequest request,Clockinnew clockinnew){
//获取当前得登录用户
Userinfo userinfo= (Userinfo) request.getSession().getAttribute("user");
String username=userinfo.getUsername();
//根据username获取登录账号得业主id
Owner owner=ownerService.queryOwnerByName(username);
List<Owner> list = new ArrayList<>();
list.add(owner);
return list;
}
@ApiOperation(value = "新增")
@PostMapping("/add")
public R add(@RequestBody Clockinnew clockinnew,HttpServletRequest request){
/**
* 打卡前先判断这个用户在当天是否已经打卡,若已打卡提示您已经打卡
* 通过ownerId,查询最近一条数据日期是否是今天,判断是否已经打卡,若填的日期不是今天,那么提示日期错误
* queryCountByOwnIdAndTime(),返回查找到记录的条数,条数大于0,表示已经打卡,反之未打卡
*
* 若未打卡则,添加打卡信息
* 通过username查找对应的owner,可获取到其id
*/
//获取当前得登录用户
Userinfo userinfo= (Userinfo) request.getSession().getAttribute("user");
String username=userinfo.getUsername();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
String todayDate = df.format(new Date());//今天的日期
//System.out.println(todayDate);
Owner owner = ownerService.queryOwnerByName(username);
Integer ownerId = owner.getId();
Date timeFlag = clockinnewService.queryCountByOwnId(ownerId);//数据库查到业主的最近一次打卡日期
String timeFlag1="";
if (timeFlag!=null){
timeFlag1=df.format(timeFlag);//查到的最近打卡日期
}
if (timeFlag1.equals(todayDate)){//若今天日期等于数据库中已经查到业主的时间,则说明已经打卡
return R.fail(400,"今日已打卡,请勿重复打卡");
}
//不相等,证明数据库还没有这个业主今日的打卡记录,正常打卡
clockinnew.setOwnerId(owner.getId());
//若为疑似病例或者确诊那么提示请填写备注
if (clockinnew.getType1()==1 || clockinnew.getType2()==1){
if (clockinnew.getRemarks()==null || clockinnew.getRemarks()==""){
return R.fail(400,"请填写备注并详细说明");
}
}
int num = clockinnewService.add(clockinnew);
return R.ok();
}
@ApiOperation(value = "删除")
@RequestMapping("/deleteByIds")
public R delete(String ids){
List<String> list= Arrays.asList(ids.split(","));
for(String id:list){
Long idLong=new Long(id);
clockinnewService.delete(idLong);
}
return R.ok();
}
@ApiOperation(value = "更新")
@PutMapping()
public int update(@RequestBody Clockinnew clockinnew){
return clockinnewService.updateData(clockinnew);
}
@ApiOperation(value = "查询分页数据")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码"),
@ApiImplicitParam(name = "pageCount", value = "每页条数")
})
@GetMapping()
public IPage<Clockinnew> findListByPage(@RequestParam Integer page,
@RequestParam Integer pageCount){
return clockinnewService.findListByPage(page, pageCount);
}
@ApiOperation(value = "id查询")
@GetMapping("{id}")
public Clockinnew findById(@PathVariable Long id){
return clockinnewService.findById(id);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
java毕设, 技术栈 - 数据库:MySQL 5.7.33 - 后端技术:SpringBoot 2.3.0,MyBatisPlus - 数据连接池:Druid - 前端技术:Layui,Ajax,Json等 - Web容器:Apache Tomcat 8 - 项目管理工具:Maven 3.6.0 - 版本控制工具:Git - 开发工具:IDEA
资源推荐
资源详情
资源评论
收起资源包目录
springboot+MyBatisPlus+Layui社区物业管理系统源码+数据库 (344个子文件)
layui.css 71KB
font-awesome.css 37KB
font-awesome.min.css 30KB
layuimini.css 17KB
wangEditor.css 17KB
wangEditor.min.css 15KB
layer.css 14KB
layui.mobile.css 10KB
zyupload-1.0.0.min.css 9KB
laydate.css 7KB
default.css 4KB
step.css 1KB
code.css 1KB
public.css 942B
treetable.css 294B
fontawesome-webfont.eot 162KB
iconfont.eot 41KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
55.gif 2KB
35.gif 2KB
15.gif 2KB
loading-2.gif 2KB
37.gif 1KB
68.gif 1KB
52.gif 777B
loading-1.gif 701B
PropertyIndex.html 15KB
welcome-3.html 12KB
login.html 10KB
CarParkIndex.html 8KB
ComplaintIndex.html 8KB
RepairIndex.html 8KB
index.html 8KB
RecordIndex.html 7KB
共 344 条
- 1
- 2
- 3
- 4
资源评论
云哲-吉吉2021
- 粉丝: 3205
- 资源: 1130
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功