101captain
2021-08-24 04748ba0bebf4a2385e60fd1bb76678bafd812d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.panzhihua.service_community.api;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.community.CancelRecordDTO;
import com.panzhihua.common.model.dtos.community.OperationDetailDTO;
import com.panzhihua.common.model.dtos.community.PageUserReserveDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActReserveCommitVO;
import com.panzhihua.service_community.dao.ComActReserveOperationRecordMapper;
import com.panzhihua.service_community.model.dos.ComActReserveOperationRecordDO;
import com.panzhihua.service_community.model.dos.ComActReserveRecordDO;
import com.panzhihua.service_community.service.ComActReserveOperationRecordService;
import com.panzhihua.service_community.service.ComActReserveRecordService;
import com.panzhihua.service_community.service.ComActReserveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
/**
 * 预约登记
 */
@Slf4j
@RestController
@RequestMapping("/reserve")
public class ComActReserveApi {
 
    @Resource
    private ComActReserveService comActReserveService;
    @Resource
    private ComActReserveRecordService comActReserveRecordService;
    @Resource
    private ComActReserveOperationRecordService comActReserveOperationRecordService;
    /**
     * 预约登记详情
     * @param id
     * @return
     */
    @GetMapping("/detail")
    public R detail(@RequestParam("id") Long id){
        if(id!=null){
            return R.ok(comActReserveService.getById(id));
        }
        return R.fail();
    }
 
    /**
     * 小程序提交预约/登记
     * @param comActReserveCommitVO
     * @return
     */
    @PostMapping("/commit")
    public R commit(@RequestBody ComActReserveCommitVO comActReserveCommitVO){
        return comActReserveService.commit(comActReserveCommitVO);
    }
 
    /**
     * 我的预约/登记
     * @param pageUserReserveDTO
     * @return
     */
    @PostMapping("/userReserveList")
    public R userReserveList(@RequestBody PageUserReserveDTO pageUserReserveDTO){
        return comActReserveService.pageReserveList(pageUserReserveDTO);
    }
    /**
     * 取消预约/登记
     */
    @PostMapping("/cancelReserve")
    public R userCancelReserve(@RequestBody CancelRecordDTO cancelRecordDTO){
        return comActReserveRecordService.cancel(cancelRecordDTO);
    }
 
    /**
     * 预约详情操作记录
     */
    @PostMapping("/detailOperation")
    public R reserveOperation(@RequestBody OperationDetailDTO comActReserveOperationRecordDO){
            if(comActReserveOperationRecordDO!=null){
                QueryWrapper<ComActReserveOperationRecordDO> queryWrapper=new QueryWrapper<>();
                if(comActReserveOperationRecordDO.getUserId()!=null){
                    queryWrapper.eq("user_id",comActReserveOperationRecordDO.getUserId());
                }
                if(comActReserveOperationRecordDO.getReserveRecordId()!=null){
                    queryWrapper.eq("reserve_record_id",comActReserveOperationRecordDO.getReserveRecordId());
                }
                if(comActReserveOperationRecordDO.getType()!=null){
                    queryWrapper.eq("type",comActReserveOperationRecordDO.getType());
                }
                queryWrapper.orderByDesc("reserve_time");
                return R.ok(comActReserveOperationRecordService.list(queryWrapper));
            }
        return R.ok();
    }
}