package com.org.hktshop.controller.system;


import com.org.hktshop.Interface.system.HktSystemRoleService;
import com.org.hktshop.Interface.system.HktSystemService;
import com.org.hktshop.base.BaseResult;
import com.org.hktshop.controller.BaseController;
import com.org.hktshop.entity.system.HktSystem;
import com.org.hktshop.entity.system.HktSystemRole;
import com.org.hktshop.utils.HttpCode;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统
 * @author hotking03
 */
@RestController
@RequestMapping("/sysRole")
public class HktSystemRoleController extends BaseController {

    @Autowired
    private HktSystemRoleService hktSystemRoleService;

    @PostMapping("/updateSystemRole")
    @ApiOperation(value = "新增/修改 系统角色权限")
    public Object updateSystemRole(@RequestBody HktSystemRole hktSystemRole) {
        try {
            hktSystemRoleService.updateSystemRole(hktSystemRole);
            return BaseResult.success();
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.info(ex.toString());
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode());
        }
    }

    @PostMapping("/delSystemRole")
    @ApiOperation(value = "删除系统角色权限")
    public Object delSystemRole(@RequestBody HktSystemRole hktSystemRole) {
        try {
            hktSystemRoleService.delSystemRole(hktSystemRole);
            return BaseResult.success();
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.info(ex.toString());
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode());
        }
    }

    @PostMapping("/findSystemRole")
    @ApiOperation(value = "系统角色权限详情")
    public Object findSystemRole(@RequestBody HktSystemRole hktSystemRole) {
        try {
            return BaseResult.successWithData(hktSystemRoleService.findSystemRole(hktSystemRole));
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.info(ex.toString());
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode());
        }
    }

    @PostMapping("/selectSystemRole")
    @ApiOperation(value = "系统角色权限列表")
    public Object selectSystemRole(@RequestBody HktSystemRole hktSystemRole) {
        try {
            return BaseResult.successWithData(hktSystemRoleService.selectSystemRole(hktSystemRole));
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.info(ex.toString());
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode());
        }
    }

}

