/**
 * 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 com.jeeplus.modules.workcontent.dao.WorkContentBiddingplanDao;
import com.jeeplus.modules.workcontent.entity.WorkContentBiddingplan;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.service.CrudService;

/**
 * 招标策划Service
 * @author ssrh
 * @version 2018-06-05
 */
@Service
@Transactional(readOnly = true)
public class WorkContentBiddingplanService extends CrudService<WorkContentBiddingplanDao, WorkContentBiddingplan> implements WorkContentDetailBaseService{

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


    @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("contProgram.id"));
        WorkContentBiddingplan workContentBiddingplan =jsonObject.toJavaObject(WorkContentBiddingplan.class);
        workContentBiddingplan.setContProgram(contentData);
        workContentBiddingplan.setProjectId(projectId);
        workContentBiddingplan.setContentId(contentId);
        this.save(workContentBiddingplan);
    }

    public WorkContentBiddingplan getByContentId(String contentId) {
        return dao.findUniqueByProperty("content_id",contentId);
    }
}