package com.movie.api.controller;

import com.movie.api.model.dto.LoginDto;
import com.movie.api.model.entity.Admin;
import com.movie.api.service.AdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@Api(tags = "管理员接口")
@RequestMapping("/api/admin")
public class AdminController {

    @Resource
    private AdminService adminService;

    @PostMapping("/login")

     //该注解是用来对某个方法/接口进行描述 @ApiOperation(value = “接口说明”,httpMethod = “接口请求方式”, response =“接口返回参数类型”, notes = “接口发布说明”
    @ApiOperation("管理员登陆")
    public Map<String, String> login(@RequestBody LoginDto loginDto) throws Exception {
        HashMap<String, String> map = new HashMap<>();
        map.put("token", adminService.login(loginDto));
        return map;
    }

    @GetMapping("/queerybyID")
    public Admin  query(){
        Admin result = adminService.querybyId();
        return result;
    }

    @PutMapping("/updateadmin")
    @ApiOperation("修改管理员")
    //更新管理员信息
    public void updateAdmin(@RequestBody Admin admin){
         adminService.updateAdmin( admin);
    }

}
