张天森
2022-09-27 9fcdea28782ac45b0d7b07396d523638d43cb7b3
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
package com.panzhihua.service_property.api;
 
 
import com.panzhihua.common.constants.Constants;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.property.ComPropertyRepairVO;
import com.panzhihua.common.utlis.RSAUtils;
import com.panzhihua.service_property.entity.ComPropertyRepair;
import com.panzhihua.service_property.service.ComPropertyRepairService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
/**
 * (ComPropertyRepair)表控制层
 *
 * @author makejava
 * @since 2021-09-02 10:12:12
 */
@RestController
@RequestMapping("comPropertyRepair")
public class ComPropertyRepairApi {
    /**
     * 服务对象
     */
    @Resource
    private ComPropertyRepairService comPropertyRepairService;
 
    /**
     * 分页查询所有数据
     * @return 所有数据
     */
    @PostMapping("queryAll")
    public R selectAll(@RequestBody CommonPage commonPage) {
        return this.comPropertyRepairService.pageList(commonPage);
    }
 
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R selectOne(@PathVariable("id") Long id) {
        return this.comPropertyRepairService.selectDetail(id);
    }
 
    /**
     * 新增数据
     *
     * @param comPropertyRepairVO 实体对象
     * @return 新增结果
     */
    @PostMapping
    public R insert(@RequestBody ComPropertyRepairVO comPropertyRepairVO) {
        ComPropertyRepair comPropertyRepair=new ComPropertyRepair();
        if(comPropertyRepairVO!=null){
            BeanUtils.copyProperties(comPropertyRepairVO,comPropertyRepair);
        }
        try {
            comPropertyRepairVO.setRepairName(RSAUtils.decrypt(comPropertyRepairVO.getRepairName(), Constants.PRIVATE_KEY));
            comPropertyRepairVO.setRepairPhone(RSAUtils.decrypt(comPropertyRepairVO.getRepairPhone(), Constants.PRIVATE_KEY));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return R.ok(this.comPropertyRepairService.save(comPropertyRepair));
    }
 
    /**
     * 修改数据
     *
     * @param comPropertyRepairVO 实体对象
     * @return 修改结果
     */
    @PostMapping("/update")
    public R update(@RequestBody ComPropertyRepairVO comPropertyRepairVO) {
        ComPropertyRepair comPropertyRepair=new ComPropertyRepair();
        if(comPropertyRepairVO!=null){
            BeanUtils.copyProperties(comPropertyRepairVO,comPropertyRepair);
        }
        return R.ok(this.comPropertyRepairService.updateById(comPropertyRepair));
    }
 
    /**
     * 删除数据
     *
     * @param id 主键结合
     * @return 删除结果
     */
    @GetMapping("del")
    public R delete(@RequestParam("id") Long id) {
        return R.ok(this.comPropertyRepairService.removeById(id));
    }
 
}