package cn.ibizlab.assetmanagement.assetapi.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.transaction.annotation.Transactional;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import cn.ibizlab.assetmanagement.assetapi.dto.*;
import cn.ibizlab.assetmanagement.assetapi.mapping.*;
import cn.ibizlab.assetmanagement.core.asset.domain.EAMAssetPartsGroup;
import cn.ibizlab.assetmanagement.core.asset.service.IEAMAssetPartsGroupService;
import cn.ibizlab.assetmanagement.core.asset.filter.EAMAssetPartsGroupSearchContext;
import cn.ibizlab.assetmanagement.util.annotation.VersionCheck;

@Slf4j
@Api(tags = {"资产备件包" })
@RestController("AssetApi-eamassetpartsgroup")
@RequestMapping("")
public class EAMAssetPartsGroupResource {

    @Autowired
    public IEAMAssetPartsGroupService eamassetpartsgroupService;

    @Autowired
    @Lazy
    public EAMAssetPartsGroupMapping eamassetpartsgroupMapping;

    @PreAuthorize("hasPermission(this.eamassetpartsgroupMapping.toDomain(#eamassetpartsgroupdto),'iBizAssetManagement-EAMAssetPartsGroup-Create')")
    @ApiOperation(value = "新建资产备件包", tags = {"资产备件包" },  notes = "新建资产备件包")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassetpartsgroups")
    @Transactional
    public ResponseEntity<EAMAssetPartsGroupDTO> create(@RequestBody EAMAssetPartsGroupDTO eamassetpartsgroupdto) {
        EAMAssetPartsGroup domain = eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdto);
		eamassetpartsgroupService.create(domain);
        EAMAssetPartsGroupDTO dto = eamassetpartsgroupMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupMapping.toDomain(#eamassetpartsgroupdtos),'iBizAssetManagement-EAMAssetPartsGroup-Create')")
    @ApiOperation(value = "批量新建资产备件包", tags = {"资产备件包" },  notes = "批量新建资产备件包")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassetpartsgroups/batch")
    public ResponseEntity<Boolean> createBatch(@RequestBody List<EAMAssetPartsGroupDTO> eamassetpartsgroupdtos) {
        eamassetpartsgroupService.createBatch(eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamassetpartsgroup" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamassetpartsgroupService.get(#eamassetpartsgroup_id),'iBizAssetManagement-EAMAssetPartsGroup-Update')")
    @ApiOperation(value = "更新资产备件包", tags = {"资产备件包" },  notes = "更新资产备件包")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamassetpartsgroups/{eamassetpartsgroup_id}")
    @Transactional
    public ResponseEntity<EAMAssetPartsGroupDTO> update(@PathVariable("eamassetpartsgroup_id") String eamassetpartsgroup_id, @RequestBody EAMAssetPartsGroupDTO eamassetpartsgroupdto) {
		EAMAssetPartsGroup domain  = eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdto);
        domain .setEamassetpartsgroupid(eamassetpartsgroup_id);
		eamassetpartsgroupService.update(domain );
		EAMAssetPartsGroupDTO dto = eamassetpartsgroupMapping.toDto(domain );
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupService.getEamassetpartsgroupByEntities(this.eamassetpartsgroupMapping.toDomain(#eamassetpartsgroupdtos)),'iBizAssetManagement-EAMAssetPartsGroup-Update')")
    @ApiOperation(value = "批量更新资产备件包", tags = {"资产备件包" },  notes = "批量更新资产备件包")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamassetpartsgroups/batch")
    public ResponseEntity<Boolean> updateBatch(@RequestBody List<EAMAssetPartsGroupDTO> eamassetpartsgroupdtos) {
        eamassetpartsgroupService.updateBatch(eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupService.get(#eamassetpartsgroup_id),'iBizAssetManagement-EAMAssetPartsGroup-Remove')")
    @ApiOperation(value = "删除资产备件包", tags = {"资产备件包" },  notes = "删除资产备件包")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamassetpartsgroups/{eamassetpartsgroup_id}")
    @Transactional
    public ResponseEntity<Boolean> remove(@PathVariable("eamassetpartsgroup_id") String eamassetpartsgroup_id) {
         return ResponseEntity.status(HttpStatus.OK).body(eamassetpartsgroupService.remove(eamassetpartsgroup_id));
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupService.getEamassetpartsgroupByIds(#ids),'iBizAssetManagement-EAMAssetPartsGroup-Remove')")
    @ApiOperation(value = "批量删除资产备件包", tags = {"资产备件包" },  notes = "批量删除资产备件包")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamassetpartsgroups/batch")
    public ResponseEntity<Boolean> removeBatch(@RequestBody List<String> ids) {
        eamassetpartsgroupService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamassetpartsgroupMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMAssetPartsGroup-Get')")
    @ApiOperation(value = "获取资产备件包", tags = {"资产备件包" },  notes = "获取资产备件包")
	@RequestMapping(method = RequestMethod.GET, value = "/eamassetpartsgroups/{eamassetpartsgroup_id}")
    public ResponseEntity<EAMAssetPartsGroupDTO> get(@PathVariable("eamassetpartsgroup_id") String eamassetpartsgroup_id) {
        EAMAssetPartsGroup domain = eamassetpartsgroupService.get(eamassetpartsgroup_id);
        EAMAssetPartsGroupDTO dto = eamassetpartsgroupMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "获取资产备件包草稿", tags = {"资产备件包" },  notes = "获取资产备件包草稿")
	@RequestMapping(method = RequestMethod.GET, value = "/eamassetpartsgroups/getdraft")
    public ResponseEntity<EAMAssetPartsGroupDTO> getDraft() {
        return ResponseEntity.status(HttpStatus.OK).body(eamassetpartsgroupMapping.toDto(eamassetpartsgroupService.getDraft(new EAMAssetPartsGroup())));
    }

    @ApiOperation(value = "检查资产备件包", tags = {"资产备件包" },  notes = "检查资产备件包")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassetpartsgroups/checkkey")
    public ResponseEntity<Boolean> checkKey(@RequestBody EAMAssetPartsGroupDTO eamassetpartsgroupdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamassetpartsgroupService.checkKey(eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdto)));
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupMapping.toDomain(#eamassetpartsgroupdto),'iBizAssetManagement-EAMAssetPartsGroup-Save')")
    @ApiOperation(value = "保存资产备件包", tags = {"资产备件包" },  notes = "保存资产备件包")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassetpartsgroups/save")
    public ResponseEntity<Boolean> save(@RequestBody EAMAssetPartsGroupDTO eamassetpartsgroupdto) {
        return ResponseEntity.status(HttpStatus.OK).body(eamassetpartsgroupService.save(eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdto)));
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupMapping.toDomain(#eamassetpartsgroupdtos),'iBizAssetManagement-EAMAssetPartsGroup-Save')")
    @ApiOperation(value = "批量保存资产备件包", tags = {"资产备件包" },  notes = "批量保存资产备件包")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassetpartsgroups/savebatch")
    public ResponseEntity<Boolean> saveBatch(@RequestBody List<EAMAssetPartsGroupDTO> eamassetpartsgroupdtos) {
        eamassetpartsgroupService.saveBatch(eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMAssetPartsGroup-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMAssetPartsGroup-Get')")
	@ApiOperation(value = "获取DEFAULT", tags = {"资产备件包" } ,notes = "获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamassetpartsgroups/fetchdefault")
	public ResponseEntity<List<EAMAssetPartsGroupDTO>> fetchDefault(EAMAssetPartsGroupSearchContext context) {
        Page<EAMAssetPartsGroup> domains = eamassetpartsgroupService.searchDefault(context) ;
        List<EAMAssetPartsGroupDTO> list = eamassetpartsgroupMapping.toDto(domains.getContent());
        return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMAssetPartsGroup-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMAssetPartsGroup-Get')")
	@ApiOperation(value = "查询DEFAULT", tags = {"资产备件包" } ,notes = "查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamassetpartsgroups/searchdefault")
	public ResponseEntity<Page<EAMAssetPartsGroupDTO>> searchDefault(@RequestBody EAMAssetPartsGroupSearchContext context) {
        Page<EAMAssetPartsGroup> domains = eamassetpartsgroupService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamassetpartsgroupMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasPermission(this.eamassetpartsgroupMapping.toDomain(#eamassetpartsgroupdto),'iBizAssetManagement-EAMAssetPartsGroup-Create')")
    @ApiOperation(value = "根据备件包建立资产备件包", tags = {"资产备件包" },  notes = "根据备件包建立资产备件包")
	@RequestMapping(method = RequestMethod.POST, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups")
    @Transactional
    public ResponseEntity<EAMAssetPartsGroupDTO> createByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id, @RequestBody EAMAssetPartsGroupDTO eamassetpartsgroupdto) {
        EAMAssetPartsGroup domain = eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdto);
        domain.setEamsparepartsgroupid(eamsparepartsgroup_id);
		eamassetpartsgroupService.create(domain);
        EAMAssetPartsGroupDTO dto = eamassetpartsgroupMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupMapping.toDomain(#eamassetpartsgroupdtos),'iBizAssetManagement-EAMAssetPartsGroup-Create')")
    @ApiOperation(value = "根据备件包批量建立资产备件包", tags = {"资产备件包" },  notes = "根据备件包批量建立资产备件包")
	@RequestMapping(method = RequestMethod.POST, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/batch")
    public ResponseEntity<Boolean> createBatchByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id, @RequestBody List<EAMAssetPartsGroupDTO> eamassetpartsgroupdtos) {
        List<EAMAssetPartsGroup> domainlist=eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdtos);
        for(EAMAssetPartsGroup domain:domainlist){
            domain.setEamsparepartsgroupid(eamsparepartsgroup_id);
        }
        eamassetpartsgroupService.createBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamassetpartsgroup" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamassetpartsgroupService.get(#eamassetpartsgroup_id),'iBizAssetManagement-EAMAssetPartsGroup-Update')")
    @ApiOperation(value = "根据备件包更新资产备件包", tags = {"资产备件包" },  notes = "根据备件包更新资产备件包")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/{eamassetpartsgroup_id}")
    @Transactional
    public ResponseEntity<EAMAssetPartsGroupDTO> updateByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id, @PathVariable("eamassetpartsgroup_id") String eamassetpartsgroup_id, @RequestBody EAMAssetPartsGroupDTO eamassetpartsgroupdto) {
        EAMAssetPartsGroup domain = eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdto);
        domain.setEamsparepartsgroupid(eamsparepartsgroup_id);
        domain.setEamassetpartsgroupid(eamassetpartsgroup_id);
		eamassetpartsgroupService.update(domain);
        EAMAssetPartsGroupDTO dto = eamassetpartsgroupMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupService.getEamassetpartsgroupByEntities(this.eamassetpartsgroupMapping.toDomain(#eamassetpartsgroupdtos)),'iBizAssetManagement-EAMAssetPartsGroup-Update')")
    @ApiOperation(value = "根据备件包批量更新资产备件包", tags = {"资产备件包" },  notes = "根据备件包批量更新资产备件包")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/batch")
    public ResponseEntity<Boolean> updateBatchByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id, @RequestBody List<EAMAssetPartsGroupDTO> eamassetpartsgroupdtos) {
        List<EAMAssetPartsGroup> domainlist=eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdtos);
        for(EAMAssetPartsGroup domain:domainlist){
            domain.setEamsparepartsgroupid(eamsparepartsgroup_id);
        }
        eamassetpartsgroupService.updateBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupService.get(#eamassetpartsgroup_id),'iBizAssetManagement-EAMAssetPartsGroup-Remove')")
    @ApiOperation(value = "根据备件包删除资产备件包", tags = {"资产备件包" },  notes = "根据备件包删除资产备件包")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/{eamassetpartsgroup_id}")
    @Transactional
    public ResponseEntity<Boolean> removeByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id, @PathVariable("eamassetpartsgroup_id") String eamassetpartsgroup_id) {
		return ResponseEntity.status(HttpStatus.OK).body(eamassetpartsgroupService.remove(eamassetpartsgroup_id));
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupService.getEamassetpartsgroupByIds(#ids),'iBizAssetManagement-EAMAssetPartsGroup-Remove')")
    @ApiOperation(value = "根据备件包批量删除资产备件包", tags = {"资产备件包" },  notes = "根据备件包批量删除资产备件包")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/batch")
    public ResponseEntity<Boolean> removeBatchByEAMSparePartsGroup(@RequestBody List<String> ids) {
        eamassetpartsgroupService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamassetpartsgroupMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMAssetPartsGroup-Get')")
    @ApiOperation(value = "根据备件包获取资产备件包", tags = {"资产备件包" },  notes = "根据备件包获取资产备件包")
	@RequestMapping(method = RequestMethod.GET, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/{eamassetpartsgroup_id}")
    public ResponseEntity<EAMAssetPartsGroupDTO> getByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id, @PathVariable("eamassetpartsgroup_id") String eamassetpartsgroup_id) {
        EAMAssetPartsGroup domain = eamassetpartsgroupService.get(eamassetpartsgroup_id);
        EAMAssetPartsGroupDTO dto = eamassetpartsgroupMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "根据备件包获取资产备件包草稿", tags = {"资产备件包" },  notes = "根据备件包获取资产备件包草稿")
    @RequestMapping(method = RequestMethod.GET, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/getdraft")
    public ResponseEntity<EAMAssetPartsGroupDTO> getDraftByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id) {
        EAMAssetPartsGroup domain = new EAMAssetPartsGroup();
        domain.setEamsparepartsgroupid(eamsparepartsgroup_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamassetpartsgroupMapping.toDto(eamassetpartsgroupService.getDraft(domain)));
    }

    @ApiOperation(value = "根据备件包检查资产备件包", tags = {"资产备件包" },  notes = "根据备件包检查资产备件包")
	@RequestMapping(method = RequestMethod.POST, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/checkkey")
    public ResponseEntity<Boolean> checkKeyByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id, @RequestBody EAMAssetPartsGroupDTO eamassetpartsgroupdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamassetpartsgroupService.checkKey(eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdto)));
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupMapping.toDomain(#eamassetpartsgroupdto),'iBizAssetManagement-EAMAssetPartsGroup-Save')")
    @ApiOperation(value = "根据备件包保存资产备件包", tags = {"资产备件包" },  notes = "根据备件包保存资产备件包")
	@RequestMapping(method = RequestMethod.POST, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/save")
    public ResponseEntity<Boolean> saveByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id, @RequestBody EAMAssetPartsGroupDTO eamassetpartsgroupdto) {
        EAMAssetPartsGroup domain = eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdto);
        domain.setEamsparepartsgroupid(eamsparepartsgroup_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamassetpartsgroupService.save(domain));
    }

    @PreAuthorize("hasPermission(this.eamassetpartsgroupMapping.toDomain(#eamassetpartsgroupdtos),'iBizAssetManagement-EAMAssetPartsGroup-Save')")
    @ApiOperation(value = "根据备件包批量保存资产备件包", tags = {"资产备件包" },  notes = "根据备件包批量保存资产备件包")
	@RequestMapping(method = RequestMethod.POST, value = "/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/savebatch")
    public ResponseEntity<Boolean> saveBatchByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id, @RequestBody List<EAMAssetPartsGroupDTO> eamassetpartsgroupdtos) {
        List<EAMAssetPartsGroup> domainlist=eamassetpartsgroupMapping.toDomain(eamassetpartsgroupdtos);
        for(EAMAssetPartsGroup domain:domainlist){
             domain.setEamsparepartsgroupid(eamsparepartsgroup_id);
        }
        eamassetpartsgroupService.saveBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMAssetPartsGroup-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMAssetPartsGroup-Get')")
	@ApiOperation(value = "根据备件包获取DEFAULT", tags = {"资产备件包" } ,notes = "根据备件包获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/fetchdefault")
	public ResponseEntity<List<EAMAssetPartsGroupDTO>> fetchEAMAssetPartsGroupDefaultByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id,EAMAssetPartsGroupSearchContext context) {
        context.setN_eamsparepartsgroupid_eq(eamsparepartsgroup_id);
        Page<EAMAssetPartsGroup> domains = eamassetpartsgroupService.searchDefault(context) ;
        List<EAMAssetPartsGroupDTO> list = eamassetpartsgroupMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMAssetPartsGroup-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMAssetPartsGroup-Get')")
	@ApiOperation(value = "根据备件包查询DEFAULT", tags = {"资产备件包" } ,notes = "根据备件包查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamsparepartsgroups/{eamsparepartsgroup_id}/eamassetpartsgroups/searchdefault")
	public ResponseEntity<Page<EAMAssetPartsGroupDTO>> searchEAMAssetPartsGroupDefaultByEAMSparePartsGroup(@PathVariable("eamsparepartsgroup_id") String eamsparepartsgroup_id, @RequestBody EAMAssetPartsGroupSearchContext context) {
        context.setN_eamsparepartsgroupid_eq(eamsparepartsgroup_id);
        Page<EAMAssetPartsGroup> domains = eamassetpartsgroupService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamassetpartsgroupMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
}

