package com.fjhx.acc.controller;

import com.fjhx.acc.service.AccAccountService;
import com.fjhx.params.acc.AccountExcel;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 全局账号 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-08-15
 */
@RestController
@RequestMapping("/accAccount")
public class AccAccountController {

    @Autowired
    private AccAccountService accAccountService;

    @GetMapping("/refreshPassword")
    public void refreshPassword(HttpServletResponse response) {
        List<AccountExcel> list = accAccountService.refreshPassword();
        ExcelUtil.export(response, "员工密码", "员工密码", list, AccountExcel.class);
    }

    @GetMapping("/test")
    public R refreshPasswordTest(@RequestParam String key) {
        Object aa = accAccountService.test(key);
        return R.data(aa);
    }

    @PostMapping("/updatePassword")
    public R updatePassword(@RequestBody Map<String, String> condition) {
        String password = accAccountService.updatePassword(condition.get("id"));
        return R.data(password);
    }

}

