package com.jeesite.modules.admin.apply.service;

import java.util.List;

import com.jeesite.modules.admin.apply.dao.AdminAccessApplyDao;
import com.jeesite.modules.admin.apply.entity.AdminAccessApply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.file.utils.FileUploadUtils;

/**
 * 应用接入申请表Service
 * @author yinet
 * @version 2022-06-13
 */
@Service
@Transactional(readOnly=true)
public class AdminAccessApplyService extends CrudService<AdminAccessApplyDao, AdminAccessApply> {
	@Autowired
	private AdminAccessApplyDao adminAccessApplyDao;
	/**
	 * 获取单条数据
	 * @param adminAccessApply
	 * @return
	 */
	@Override
	public AdminAccessApply get(AdminAccessApply adminAccessApply) {
		return super.get(adminAccessApply);
	}
	
	/**
	 * 查询分页数据
	 * @param adminAccessApply 查询条件
	 * @param adminAccessApply.page 分页对象
	 * @return
	 */
	@Override
	public Page<AdminAccessApply> findPage(AdminAccessApply adminAccessApply) {
		return super.findPage(adminAccessApply);
	}
	
	/**
	 * 查询列表数据
	 * @param adminAccessApply
	 * @return
	 */
	@Override
	public List<AdminAccessApply> findList(AdminAccessApply adminAccessApply) {
		return super.findList(adminAccessApply);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param adminAccessApply
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(AdminAccessApply adminAccessApply) {
		super.save(adminAccessApply);
		// 保存上传图片
		FileUploadUtils.saveFileUpload(adminAccessApply, adminAccessApply.getId(), "adminAccessApply_image");
		// 保存上传附件
		FileUploadUtils.saveFileUpload(adminAccessApply, adminAccessApply.getId(), "adminAccessApply_file");
	}
	
	/**
	 * 更新状态
	 * @param adminAccessApply
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(AdminAccessApply adminAccessApply) {
		super.updateStatus(adminAccessApply);
	}
	
	/**
	 * 删除数据
	 * @param adminAccessApply
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(AdminAccessApply adminAccessApply) {
		super.delete(adminAccessApply);
	}

	public boolean findByName(String appName) {
		AdminAccessApply adminAccessApply=adminAccessApplyDao.findByName(appName);
		if(adminAccessApply!=null){
			return false;
		}else {
			return true;
		}
	}
}