|
|
|
/**
|
|
|
|
* Copyright (c) 2018 人人开源 All rights reserved.
|
|
|
|
*
|
|
|
|
* https://www.renren.io
|
|
|
|
*
|
|
|
|
* 版权所有,侵权必究!
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.epmet.controller;
|
|
|
|
|
|
|
|
import com.epmet.dto.SysDictDataDTO;
|
|
|
|
import com.epmet.service.SysDictDataService;
|
|
|
|
import com.epmet.commons.tools.constant.Constant;
|
|
|
|
import com.epmet.commons.tools.page.PageData;
|
|
|
|
import com.epmet.commons.tools.utils.Result;
|
|
|
|
import com.epmet.commons.tools.validator.AssertUtils;
|
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils;
|
|
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup;
|
|
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 字典数据
|
|
|
|
*
|
|
|
|
* @author Mark sunlightcs@gmail.com
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("dict/data")
|
|
|
|
public class SysDictDataController {
|
|
|
|
@Autowired
|
|
|
|
private SysDictDataService sysDictDataService;
|
|
|
|
|
|
|
|
@GetMapping("page")
|
|
|
|
public Result<PageData<SysDictDataDTO>> page(@RequestParam Map<String, Object> params){
|
|
|
|
//字典类型
|
|
|
|
PageData<SysDictDataDTO> page = sysDictDataService.page(params);
|
|
|
|
|
|
|
|
return new Result<PageData<SysDictDataDTO>>().ok(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("{id}")
|
|
|
|
public Result<SysDictDataDTO> get(@PathVariable("id") Long id){
|
|
|
|
SysDictDataDTO data = sysDictDataService.get(id);
|
|
|
|
|
|
|
|
return new Result<SysDictDataDTO>().ok(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
@PostMapping
|
|
|
|
public Result save(@RequestBody SysDictDataDTO dto){
|
|
|
|
//效验数据
|
|
|
|
ValidatorUtils.validateEntity(dto, DefaultGroup.class);
|
|
|
|
|
|
|
|
sysDictDataService.save(dto);
|
|
|
|
|
|
|
|
return new Result();
|
|
|
|
}
|
|
|
|
|
|
|
|
@PutMapping
|
|
|
|
public Result update(@RequestBody SysDictDataDTO dto){
|
|
|
|
//效验数据
|
|
|
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
|
|
|
|
|
|
|
sysDictDataService.update(dto);
|
|
|
|
|
|
|
|
return new Result();
|
|
|
|
}
|
|
|
|
|
|
|
|
@DeleteMapping
|
|
|
|
public Result delete(@RequestBody Long[] ids){
|
|
|
|
//效验数据
|
|
|
|
AssertUtils.isArrayEmpty(ids, "id");
|
|
|
|
|
|
|
|
sysDictDataService.delete(ids);
|
|
|
|
|
|
|
|
return new Result();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|