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

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.service.CrudService;
import com.jeeplus.modules.projectcontentinfo.entity.ProjectContentData;
import com.jeeplus.modules.workcontent.dao.WorkContentVisamanageDao;
import com.jeeplus.modules.workcontent.entity.WorkContentVisamanage;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

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

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


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

}