forked from luyan/epmet-cloud-lingshan
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.0 KiB
80 lines
2.0 KiB
/**
|
|
* Copyright (c) 2018 人人开源 All rights reserved.
|
|
*
|
|
* https://www.renren.io
|
|
*
|
|
* 版权所有,侵权必究!
|
|
*/
|
|
|
|
package com.epmet.controller;
|
|
|
|
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.AddGroup;
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup;
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup;
|
|
import com.epmet.dto.SysDeptDTO;
|
|
import com.epmet.service.SysDeptService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 部门管理
|
|
*
|
|
* @author Mark sunlightcs@gmail.com
|
|
* @since 1.0.0
|
|
*/
|
|
@RestController
|
|
@RequestMapping("dept")
|
|
public class SysDeptController {
|
|
@Autowired
|
|
private SysDeptService sysDeptService;
|
|
|
|
@GetMapping("list")
|
|
public Result<List<SysDeptDTO>> list(){
|
|
List<SysDeptDTO> list = sysDeptService.list(new HashMap<>(1));
|
|
|
|
return new Result<List<SysDeptDTO>>().ok(list);
|
|
}
|
|
|
|
@GetMapping("{id}")
|
|
public Result<SysDeptDTO> get(@PathVariable("id") Long id){
|
|
SysDeptDTO data = sysDeptService.get(id);
|
|
|
|
return new Result<SysDeptDTO>().ok(data);
|
|
}
|
|
|
|
@PostMapping
|
|
public Result save(@RequestBody SysDeptDTO dto){
|
|
//效验数据
|
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
|
|
|
sysDeptService.save(dto);
|
|
|
|
return new Result();
|
|
}
|
|
|
|
@PutMapping
|
|
public Result update(@RequestBody SysDeptDTO dto){
|
|
//效验数据
|
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
|
|
|
sysDeptService.update(dto);
|
|
|
|
return new Result();
|
|
}
|
|
|
|
@DeleteMapping("{id}")
|
|
public Result delete(@PathVariable("id") Long id){
|
|
//效验数据
|
|
AssertUtils.isNull(id, "id");
|
|
|
|
sysDeptService.delete(id);
|
|
|
|
return new Result();
|
|
}
|
|
}
|
|
|