/**
 * 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.WorkContentPricemanage;
import com.jeeplus.modules.workcontent.dao.WorkContentPricemanageDao;

/**
 * 认价管理Service
 * @author ssrh
 * @version 2018-06-06
 */
@Service
@Transactional(readOnly = true)
public class WorkContentPricemanageService extends CrudService<WorkContentPricemanageDao, WorkContentPricemanage> implements WorkContentDetailBaseService {

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


    @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"));
        WorkContentPricemanage newRecord = jsonObject.toJavaObject(WorkContentPricemanage.class);
        newRecord.setContract(contentData);
        newRecord.setProjectId(projectId);
        newRecord.setContentId(contentId);
        this.save(newRecord);
    }

}