/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.workcontent.service;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeeplus.modules.projectcontentinfo.entity.ProjectContentData;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.service.CrudService;
import com.jeeplus.modules.workcontent.entity.WorkContentClaim;
import com.jeeplus.modules.workcontent.dao.WorkContentClaimDao;

/**
 * 索赔管理Service
 * @author ssrh
 * @version 2018-06-12
 */
@Service
@Transactional(readOnly = true)
public class WorkContentClaimService extends CrudService<WorkContentClaimDao, WorkContentClaim> implements WorkContentDetailBaseService{

	public WorkContentClaim get(String id) {
		return super.get(id);
	}
	
	public List<WorkContentClaim> findList(WorkContentClaim workContentClaim) {
		return super.findList(workContentClaim);
	}
	
	public Page<WorkContentClaim> findPage(Page<WorkContentClaim> page, WorkContentClaim workContentClaim) {
		return super.findPage(page, workContentClaim);
	}
	
	@Transactional(readOnly = false)
	public void save(WorkContentClaim workContentClaim) {
		super.save(workContentClaim);
	}
	
	@Transactional(readOnly = false)
	public void delete(WorkContentClaim workContentClaim) {
		super.delete(workContentClaim);
	}

    @Override
    @Transactional(readOnly = false)
    public void saveDetails(String detailStr, String projectId, String contentId) {
        JSONObject jsonObject = JSON.parseObject(detailStr);
        ProjectContentData contentData = new ProjectContentData();
        contentData.setId(jsonObject.getString("contract.id"));
        WorkContentClaim workContentClaim =jsonObject.toJavaObject(WorkContentClaim.class);
        workContentClaim.setContract(contentData);
        workContentClaim.setProjectId(projectId);
        workContentClaim.setContentId(contentId);
        this.save(workContentClaim);
    }

}