package com.hotent.portal.controller;


import com.hotent.base.controller.BaseController;
import com.hotent.base.enums.ResponseErrorEnums;
import com.hotent.base.model.CommonResult;
import com.hotent.portal.model.PortalUrlPermission;
import com.hotent.portal.model.dto.PortalUrlPermissionDto;
import com.hotent.portal.service.PortalUrlPermissionManager;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 *  前端控制器
 *
 * @company 广州宏天软件股份有限公司
 * @author cola
 * @since 2021-08-26
 */
@RestController
@RequestMapping("/portalUrlPermission/v1/")
public class PortalUrlPermissionController extends BaseController<PortalUrlPermissionManager, PortalUrlPermission> {

    @Autowired
    PortalUrlPermissionManager portalUrlPermissionManager;

    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public CommonResult saveData(@RequestBody PortalUrlPermissionDto dto){
        return portalUrlPermissionManager.saveData(dto);
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public CommonResult updateData(@RequestBody PortalUrlPermissionDto dto){
        PortalUrlPermission portalUrlPermission = new PortalUrlPermission();
        BeanUtils.copyProperties(dto,portalUrlPermission);
        boolean res = portalUrlPermissionManager.updateById(portalUrlPermission);
        return new CommonResult().message(res? ResponseErrorEnums.SUCCESS_OPTION.getMessage() : ResponseErrorEnums.FAIL_OPTION.getMessage());
    }
}
