1
zj
2024-07-26 ffd6930343008031dd8c663a5503d7e90c0cecf5
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
package com.nq.controller.backend;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.nq.common.ServerResponse;
import com.nq.dao.RechargeAddressMapper;
import com.nq.pojo.RechargeAddress;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.servlet.http.HttpServletRequest;
 
/**
 * @program: dabaogp
 * @description:
 * @create: 2024-07-26 11:31
 **/
@Controller
@RequestMapping({"/admin/rechargeAddress/"})
public class AdminrRechargeAddressController {
 
    @Autowired
    private RechargeAddressMapper mapper;
 
    @RequestMapping(value = {"add.do"})
    @ResponseBody
    public ServerResponse add(RechargeAddress rechargeAddress, HttpServletRequest httpServletRequest) {
        Long count = mapper.selectCount(new LambdaQueryWrapper<RechargeAddress>().eq(RechargeAddress::getAddress, rechargeAddress.getAddress()));
        if(count > 0){
            return ServerResponse.createByErrorMsg("充币地址已存在");
        }
        mapper.insert(rechargeAddress);
        return ServerResponse.createBySuccess();
    }
 
    @RequestMapping(value = {"select.do"})
    @ResponseBody
    public ServerResponse select() {
        return ServerResponse.createBySuccess(mapper.selectList(new LambdaQueryWrapper<RechargeAddress>()));
    }
 
    @RequestMapping(value = {"update.do"})
    @ResponseBody
    public ServerResponse update(RechargeAddress rechargeAddress, HttpServletRequest httpServletRequest) {
        Long count = mapper.selectCount(new LambdaQueryWrapper<RechargeAddress>().eq(RechargeAddress::getId, rechargeAddress.getId()));
        if(count == 0){
            return ServerResponse.createByErrorMsg("充币地址不存在");
        }
        Long count2 = mapper.selectCount(new LambdaQueryWrapper<RechargeAddress>().eq(RechargeAddress::getAddress, rechargeAddress.getAddress()).ne(RechargeAddress::getId,rechargeAddress.getId()));
        if(count2 > 0){
            return ServerResponse.createByErrorMsg("充币地址已存在");
        }
        mapper.updateById(rechargeAddress);
        return ServerResponse.createBySuccess();
    }
 
    @RequestMapping(value = {"delete.do"})
    @ResponseBody
    public ServerResponse delete(@RequestParam("id") Integer id, HttpServletRequest httpServletRequest) {
        Long count = mapper.selectCount(new LambdaQueryWrapper<RechargeAddress>().eq(RechargeAddress::getId, id));
        if(count == 0){
            return ServerResponse.createByErrorMsg("充币地址不存在");
        }
        mapper.deleteById(id);
        return ServerResponse.createBySuccess();
    }
 
}