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.service.system.AdminService;
import com.gz.vo.system.AdminVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

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

    @Resource
    private AdminService adminService;


    /**
     * @description 增
     * @author LiuChangLan
     * @since 2020/9/4 14:46
     */
    @PostMapping("insert")
    @TraceLog(module = "管理员管理",business = "新增管理员")
    public Integer insert(@RequestBody AdminDTO adminDTO){
        return adminService.insert(adminDTO);
    }

    /**
     * @description 删
     * @author LiuChangLan
     * @since 2020/9/4 14:46
     */
    @DeleteMapping("delete")
    @TraceLog(module = "管理员管理",business = "删除管理员")
    public Integer delete( Integer id){
        return adminService.delete(id);
    }

    /**
     * @description 改
     * @author LiuChangLan
     * @since 2020/9/4 14:46
     */
    @PostMapping("update")
    @TraceLog(module = "管理员管理",business = "修改管理员")
    public Integer update(@RequestBody AdminDTO adminDTO){
        return adminService.update(adminDTO);
    }

    /**
     * @description 查(分页)
     * @author LiuChangLan
     * @since 2020/9/4 14:46
     */
    @GetMapping("select")
    @TraceLog(module = "管理员管理",business = "查询管理员列表")
    public PageInfo<AdminDTO> select(AdminVO adminVO){
        return adminService.select(adminVO);
    }

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

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

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



}
