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);
|
}
|
}
|