package com.uas.platform.b2b.erp.controller;

import com.uas.platform.b2b.service.UserService;
import com.uas.platform.b2b.support.UsageBufferedLogger;
import com.uas.platform.core.logging.BufferedLoggerManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

/**
 * Created by wangmh on 2017/8/9.
 */
@Controller("erp.UserController")
@RequestMapping("erp/account/user")
public class UserController {

    @Autowired
    private UserService userService;

    private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);

    @RequestMapping(value = "/{uus}", method = RequestMethod.DELETE)
    public ResponseEntity<String> removeUser(@PathVariable("uus") Long... uus)throws UnsupportedEncodingException {
        if (uus == null) {
            return new ResponseEntity<String>(HttpStatus.NOT_MODIFIED);
        }
        for (Long uu : uus) {
            try {
                userService.removeUser(uu);
                logger.log("用户信息", "删除用户，UU：" + uu);
            } catch (RuntimeException e){

            }
        }
        return new ResponseEntity<String>(HttpStatus.OK);
    }
}
