Administrator
2024-01-26 eef1bac64a0080f8f609312e31f63280b85e62d6
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.dy.pipIrrSell.clientCard;
 
import com.dy.common.aop.SsoAop;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoBa.BaClient;
import com.dy.pipIrrGlobal.voSe.VoCardInfo;
import com.dy.pipIrrGlobal.voSe.VoCards;
import com.dy.pipIrrSell.clientCard.qo.QoCards;
import com.dy.pipIrrSell.result.SellResultCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.Map;
 
/**
 * @author ZhuBaoMin
 * @date 2023-12-27 19:36
 * @LastEditTime 2023-12-27 19:36
 * @Description
 */
 
@Slf4j
@Tag(name = "农户水卡", description = "农户水卡")
@RestController
@RequestMapping(path="clientcard")
@RequiredArgsConstructor
public class ClientCardCtrl {
    private final ClientCardSv clientCardSv;
 
    /**
     * 获取指定用户名下全部水卡
     * @param clientId
     * @return
     */
    @Operation(summary = "获得全部水卡", description = "返回全部水卡数据")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回一页农户数据(BaseResponse.content:QueryResultVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = BaClient.class))}
            )
    })
    @GetMapping(path = "clientcard/{clientId}")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoCardInfo>>> get(@PathVariable("clientId") Long clientId){
        try {
            List<VoCardInfo> list = clientCardSv.getCardInfoByClientId(clientId);
            return BaseResponseUtils.buildSuccess(list);
        } catch (Exception e) {
            log.error("查询农户异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
 
    /**
     * 根据水卡编号获取操作记录及余额
     * @param cardNum 水卡编号
     * @return 水卡操作记录及余额
     */
    @Operation(summary = "获得水卡操作记录及余额", description = "返回水卡操作记录及余额")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回一页农户数据(BaseResponse.content:QueryResultVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = BaClient.class))}
            )
    })
    @GetMapping(path = "/getoperaterecords")
    @SsoAop()
    public BaseResponse<List<Map<String, Object>>> getOperateRecordsAndMoney(@RequestParam("cardNum") Long cardNum){
        try {
            Map map = clientCardSv.getOperateRecordsAndMoney(cardNum);
            return BaseResponseUtils.buildSuccess(map);
        } catch (Exception e) {
            log.error("查询操作记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
 
    /**
     * 根据水卡编号获取卡片状态
     * @param cardNum
     * @return
     */
    @Operation(summary = "根据水卡编号获取卡片状态", description = "根据水卡编号获取卡片状态")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回一页农户数据(BaseResponse.content:QueryResultVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = BaClient.class))}
            )
    })
    @GetMapping(path = "/cardstate")
    @SsoAop()
    public BaseResponse<String> getCardStateByCardNum(@RequestParam("cardNum") Long cardNum){
        try {
            String stateName = clientCardSv.getCardStateByCardNum(cardNum);
            return BaseResponseUtils.buildSuccess(stateName);
        } catch (Exception e) {
            log.error("查询操作记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
 
    /**
     * 根据指定条件获取水卡列表,应用程序使用
     * @param vo
     * @return
     */
    @Operation(summary = "获得一页水卡记录", description = "返回一页水卡数据")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回一页农户数据(BaseResponse.content:QueryResultVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = BaClient.class))}
            )
    })
    @GetMapping(path = "getcards")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoCards>>> getcards(QoCards vo){
        try {
            QueryResultVo<List<VoCards>> res = clientCardSv.getCards(vo);
            if(res.itemTotal != null && res.itemTotal > 0) {
                return BaseResponseUtils.buildSuccess(res);
            }else {
                return BaseResponseUtils.buildFail(SellResultCode.THE_CARD_NOT_EXIST.getMessage());
            }
        } catch (Exception e) {
            log.error("查询农户异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
}