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

/**
 * 变更管理Service
 * @author ssrh
 * @version 2018-06-06
 */
@Service
@Transactional(readOnly = true)
public class WorkContentAltermanageService extends CrudService<WorkContentAltermanageDao, WorkContentAltermanage> implements WorkContentDetailBaseService{

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


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

}