package com.iailab.module.data.indexdata.controller.admin;
|
|
import com.iailab.module.data.common.utils.PageUtils;
|
import com.iailab.module.data.common.utils.R;
|
import com.iailab.framework.security.core.util.SecurityFrameworkUtils;
|
import com.iailab.module.data.indexdata.service.IndexDataItemService;
|
import com.iailab.module.data.indexdata.entity.IndexDataItemEntity;
|
import javax.annotation.Resource;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Date;
|
import java.util.Map;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2022年09月08日 21:53:00
|
*/
|
@RestController
|
@RequestMapping("/data/index-data/item")
|
public class IndexDataItemController {
|
@Resource
|
private IndexDataItemService indexDataItemService;
|
|
/**
|
* 所有数据项目列表
|
*/
|
@GetMapping("/list")
|
public R list(@RequestParam Map<String, Object> params){
|
PageUtils page = indexDataItemService.queryPage(params);
|
return R.ok().put("page", page);
|
}
|
|
/**
|
* 新增数据项目
|
*
|
* @param enity
|
* @return
|
*/
|
@PostMapping("/add")
|
public R add(@RequestBody IndexDataItemEntity enity) {
|
enity.setId(null);
|
int count = indexDataItemService.cheack(enity);
|
if (count > 0) {
|
return R.error("名称或编号重复");
|
}
|
enity.setCreateBy(SecurityFrameworkUtils.getLoginUserId().toString());
|
enity.setCreateTime(new Date());
|
indexDataItemService.add(enity);
|
return R.ok();
|
}
|
|
/**
|
* 更新数据项目
|
*
|
* @param enity
|
* @return
|
*/
|
@PostMapping("/update")
|
public R update(@RequestBody IndexDataItemEntity enity) {
|
int count = indexDataItemService.cheack(enity);
|
if (count > 0) {
|
return R.error("名称或编号重复");
|
}
|
enity.setUpdateBy(SecurityFrameworkUtils.getLoginUserId().toString());
|
indexDataItemService.update(enity);
|
return R.ok();
|
}
|
|
/**
|
* 删除数据项目
|
*
|
* @param ids
|
* @return
|
*/
|
@PostMapping("/delete")
|
public R delete(@RequestBody String[] ids) {
|
indexDataItemService.deleteBatch(ids);
|
return R.ok();
|
}
|
|
/**
|
* 数据项目详情
|
*
|
* @param id
|
* @return
|
*/
|
@RequestMapping("/info/{id}")
|
public R info(@PathVariable("id") String id){
|
IndexDataItemEntity enity = indexDataItemService.getInfoById(id);
|
return R.ok().put("data", enity);
|
}
|
}
|