package com.huimv.admin.controller.primary;

;
import com.huimv.admin.service.primary.IAccountService;
import com.huimv.admin.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private IAccountService iAccountService;

    @RequestMapping("/new")
    public Result newAccount(@RequestParam(name = "userId") Integer userId){
       return iAccountService.newAccount(userId);
    }

    @RequestMapping("/cancel")
    public Result cancelAccount(@RequestParam(name = "id") Integer id,
                                @RequestParam(name = "accountStatus") Integer accountStatus){
       return iAccountService.cancelAccount(id,accountStatus);
    }

    @RequestMapping("/remove")
    public Result removeAccount(@RequestParam(name = "ids") List<Integer> ids){
        return  iAccountService.removeAccount(ids);
    }


    @RequestMapping("/list")
    public Result listAccount(){
        return iAccountService.findAll();
    }

    @RequestMapping("/setAccountStatus")
    public Result setAccountStatus(@RequestParam(name = "ids") List<Integer> ids, @RequestParam(name = "status") Integer status){
        /* 设置账号状态 */
        return iAccountService.setAccountStatus(ids,status);
    }

}
