package com.gz.controller.system;

import com.github.pagehelper.PageInfo;
import com.gz.core.annotation.TraceLog;
import com.gz.dto.system.AdminDTO;
import com.gz.rvo.system.AdminRVO;
import com.gz.service.system.AdminService;
import com.gz.vo.system.AdminVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author LiuchangLan
 * @date 2020/9/4 14:41
 */
@RestController
@RequestMapping("system/admin")
public class AdminController {

    @Resource
    private AdminService adminService;

    @PostMapping("insert")
    @TraceLog(module = "管理员管理",business = "新增管理员")
    public Integer insert(@RequestBody AdminDTO adminDTO){
        return adminService.insert(adminDTO);
    }

    @DeleteMapping("delete")
    @TraceLog(module = "管理员管理",business = "删除管理员")
    public Integer delete( Integer id){
        return adminService.delete(id);
    }

    @PostMapping("update")
    @TraceLog(module = "管理员管理",business = "修改管理员")
    public Integer update(@RequestBody AdminDTO adminDTO){
        return adminService.update(adminDTO);
    }

    @GetMapping("select")
    @TraceLog(module = "管理员管理",business = "查询管理员列表")
    public PageInfo<AdminDTO> select(AdminVO adminVO){
        return adminService.select(adminVO);
    }

    @GetMapping("selectByPrimaryKey")
    @TraceLog(module = "管理员管理",business = "查询管理员详细信息")
    public AdminDTO selectByPrimaryKey(String id){
        return adminService.selectByPrimaryKey(id);
    }

    @GetMapping("updateStatus")
    @TraceLog(module = "管理员管理",business = "修改管理员状态")
    Integer updateStatus(String id){
        return adminService.updateStatus(id);
    }

    @PostMapping("resetPassword")
    @TraceLog(module = "管理员管理",business = "重置管理员密码")
    Integer resetPassword(@RequestBody String id){
        return adminService.resetPassword(id);
    }

    @GetMapping("selectAll")
    List<AdminDTO> selectAll(){
        return adminService.selectAll();
    }

    @GetMapping("selectByPrimaryKeyDept")
    AdminRVO selectByPrimaryKeyDept(String id){
        return adminService.selectByPrimaryKeyDept(id);
    }

}
