package com.org.hktshop.controller.system;


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.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("/sys")
public class HktSystemController extends BaseController {

    @Autowired
    private HktSystemService hktSystemService;

    @PostMapping("/updateSystem")
    @ApiOperation(value = "新增/修改 系统")
    public Object updateHktSystem(@RequestBody HktSystem hktSystem) {
        try {
            hktSystemService.updateHktSystem(hktSystem);
            return BaseResult.success();
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.info(ex.toString());
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode());
        }
    }

    @PostMapping("/delSystem")
    @ApiOperation(value = "删除系统")
    public Object delSystem(@RequestBody HktSystem hktSystem) {
        try {
            hktSystemService.delSystem(hktSystem);
            return BaseResult.success();
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.info(ex.toString());
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode());
        }
    }

    @PostMapping("/findSystem")
    @ApiOperation(value = "系统详情")
    public Object findSystem(@RequestBody HktSystem hktSystem) {
        try {
            return BaseResult.successWithData(hktSystemService.findSystem(hktSystem));
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.info(ex.toString());
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode());
        }
    }

    @PostMapping("/selectSystem")
    @ApiOperation(value = "系统列表")
    public Object selectSystem() {
        try {
            return BaseResult.successWithData(hktSystemService.selectSystem());
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.info(ex.toString());
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode());
        }
    }

}

