package cn.ibizlab.businesscentral.core.rest;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import cn.ibizlab.businesscentral.core.dto.*;
import cn.ibizlab.businesscentral.core.mapping.*;
import cn.ibizlab.businesscentral.core.odoo_website.domain.Website_published_multi_mixin;
import cn.ibizlab.businesscentral.core.odoo_website.service.IWebsite_published_multi_mixinService;
import cn.ibizlab.businesscentral.core.odoo_website.filter.Website_published_multi_mixinSearchContext;
import cn.ibizlab.businesscentral.util.annotation.VersionCheck;

@Slf4j
@Api(tags = {"多网站发布的Mixin" })
@RestController("Core-website_published_multi_mixin")
@RequestMapping("")
public class Website_published_multi_mixinResource {

    @Autowired
    public IWebsite_published_multi_mixinService website_published_multi_mixinService;

    @Autowired
    @Lazy
    public Website_published_multi_mixinMapping website_published_multi_mixinMapping;

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Website_published_multi_mixin-Create-all')")
    @ApiOperation(value = "新建多网站发布的Mixin", tags = {"多网站发布的Mixin" },  notes = "新建多网站发布的Mixin")
	@RequestMapping(method = RequestMethod.POST, value = "/website_published_multi_mixins")
    public ResponseEntity<Website_published_multi_mixinDTO> create(@Validated @RequestBody Website_published_multi_mixinDTO website_published_multi_mixindto) {
        Website_published_multi_mixin domain = website_published_multi_mixinMapping.toDomain(website_published_multi_mixindto);
		website_published_multi_mixinService.create(domain);
        Website_published_multi_mixinDTO dto = website_published_multi_mixinMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Website_published_multi_mixin-Create-all')")
    @ApiOperation(value = "批量新建多网站发布的Mixin", tags = {"多网站发布的Mixin" },  notes = "批量新建多网站发布的Mixin")
	@RequestMapping(method = RequestMethod.POST, value = "/website_published_multi_mixins/batch")
    public ResponseEntity<Boolean> createBatch(@RequestBody List<Website_published_multi_mixinDTO> website_published_multi_mixindtos) {
        website_published_multi_mixinService.createBatch(website_published_multi_mixinMapping.toDomain(website_published_multi_mixindtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Website_published_multi_mixin-Update-all')")
    @ApiOperation(value = "更新多网站发布的Mixin", tags = {"多网站发布的Mixin" },  notes = "更新多网站发布的Mixin")
	@RequestMapping(method = RequestMethod.PUT, value = "/website_published_multi_mixins/{website_published_multi_mixin_id}")
    public ResponseEntity<Website_published_multi_mixinDTO> update(@PathVariable("website_published_multi_mixin_id") Long website_published_multi_mixin_id, @RequestBody Website_published_multi_mixinDTO website_published_multi_mixindto) {
		Website_published_multi_mixin domain  = website_published_multi_mixinMapping.toDomain(website_published_multi_mixindto);
        domain .setId(website_published_multi_mixin_id);
		website_published_multi_mixinService.update(domain );
		Website_published_multi_mixinDTO dto = website_published_multi_mixinMapping.toDto(domain );
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Website_published_multi_mixin-Update-all')")
    @ApiOperation(value = "批量更新多网站发布的Mixin", tags = {"多网站发布的Mixin" },  notes = "批量更新多网站发布的Mixin")
	@RequestMapping(method = RequestMethod.PUT, value = "/website_published_multi_mixins/batch")
    public ResponseEntity<Boolean> updateBatch(@RequestBody List<Website_published_multi_mixinDTO> website_published_multi_mixindtos) {
        website_published_multi_mixinService.updateBatch(website_published_multi_mixinMapping.toDomain(website_published_multi_mixindtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Website_published_multi_mixin-Remove-all')")
    @ApiOperation(value = "删除多网站发布的Mixin", tags = {"多网站发布的Mixin" },  notes = "删除多网站发布的Mixin")
	@RequestMapping(method = RequestMethod.DELETE, value = "/website_published_multi_mixins/{website_published_multi_mixin_id}")
    public ResponseEntity<Boolean> remove(@PathVariable("website_published_multi_mixin_id") Long website_published_multi_mixin_id) {
         return ResponseEntity.status(HttpStatus.OK).body(website_published_multi_mixinService.remove(website_published_multi_mixin_id));
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Website_published_multi_mixin-Remove-all')")
    @ApiOperation(value = "批量删除多网站发布的Mixin", tags = {"多网站发布的Mixin" },  notes = "批量删除多网站发布的Mixin")
	@RequestMapping(method = RequestMethod.DELETE, value = "/website_published_multi_mixins/batch")
    public ResponseEntity<Boolean> removeBatch(@RequestBody List<Long> ids) {
        website_published_multi_mixinService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Website_published_multi_mixin-Get-all')")
    @ApiOperation(value = "获取多网站发布的Mixin", tags = {"多网站发布的Mixin" },  notes = "获取多网站发布的Mixin")
	@RequestMapping(method = RequestMethod.GET, value = "/website_published_multi_mixins/{website_published_multi_mixin_id}")
    public ResponseEntity<Website_published_multi_mixinDTO> get(@PathVariable("website_published_multi_mixin_id") Long website_published_multi_mixin_id) {
        Website_published_multi_mixin domain = website_published_multi_mixinService.get(website_published_multi_mixin_id);
        Website_published_multi_mixinDTO dto = website_published_multi_mixinMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }


}

