suerprisePlus
2024-09-23 e7c3276f2f5091fe8626af61ba5d7b41b2a1f2df
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
package com.yb.controller;
 
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
 
import com.alibaba.fastjson.JSON;
import com.yb.dao.THistoryDao;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yb.entity.THistoryEntity;
import com.yb.service.THistoryService;
import com.yb.config.PageUtils;
import com.yb.config.R;
 
 
/**
 * ${comments}
 *
 * @author yw
 * @email leutu@qq.com
 * @date 2024-09-14 16:35:15
 */
@RestController
@RequestMapping("/api/thistory")
public class THistoryController {
    @Autowired
    private THistoryService tHistoryService;
    @Autowired
    private THistoryDao tHistoryDao;
 
    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "list", notes = "参数 : page,limit")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = tHistoryService.queryPage(params);
 
        return R.ok().put("page", page);
    }
 
 
    /**
     * 列表
     */
    @GetMapping("/query")
    @ApiOperation(value = "query", notes = "")
    public R query(@RequestParam Map<String, Object> params) {
        PageUtils page = tHistoryService.query(params);
 
        return R.ok().put("page", page);
    }
 
    /**
     * 列表
     */
    @PostMapping("/listAll")
    @ApiOperation(value = "listAll", notes = "")
    public R listAll() {
        PageUtils page = tHistoryService.queryPage(new HashMap<String, Object>());
 
        return R.ok().put("page", page);
    }
 
    /**
     * 信息
     */
    @PostMapping("/info/{id}")
    @ApiOperation(value = "info", notes = "")
    public R info(@PathVariable("id") Integer id) {
        THistoryEntity tHistory = tHistoryService.getById(id);
 
        return R.ok().put("tHistory", tHistory);
    }
 
    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation(value = "save", notes = "")
    public R save(@RequestBody THistoryEntity tHistory) {
        int id =  tHistoryDao.insert(tHistory);
//        tHistory.getId().toString()
        HashMap<String,Object> hashMap= new HashMap<>();
        hashMap.put("id",tHistory.getId().toString());
        return R.ok(hashMap);
    }
 
    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation(value = "update", notes = "")
    public R update(@RequestBody THistoryEntity tHistory) {
        tHistoryService.updateById(tHistory);
        return R.ok();
    }
 
    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation(value = "delete", notes = "")
    public R delete(@RequestBody Integer[] ids) {
        tHistoryService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
 
    /**
     * 修改
     */
    @PostMapping("/getTableMeta")
    @ApiOperation(value = "getTableMeta", notes = "")
    public R getTableMeta() {
        ArrayList<Map<String, String>> list = new ArrayList<Map<String, String>>();
 
        Field[] fields = THistoryEntity.class.getDeclaredFields();
        for (Field field : fields) {
            Map<String, String> map = new HashMap<>();
            System.out.println("属性名:" + field.getName());
            System.out.println("类型:" + field.getType().getName());
            map.put("name", field.getName());
            map.put("type", field.getType().getName());
            map.put("cname", field.getName());
            list.add(map);
        }
        return R.ok(list);
    }
}