service层逻辑练习

接口

public interface FGalleryFileService {
    /**
     * 展示文件添加
     * @param tempVo 待添加的实体对象 前台传递所有值. 判断内容类型与galleryTypeId的类型是否一致是否一致.
     * @throws ChecksException
     */
    void fixAdd(FGalleryFile tempVo) throws ChecksException;

    /**
     * 展示文件修改
     * @param tempVo 前台传递所有值
     * @throws ChecksException
     */
    void fixEditSave(FGalleryFile tempVo) throws ChecksException;

    /**
     * 分页数据获取
     * @param tempVo 分页实体
     * @param myPage 分页对象
     * @param orderbys 排序字段数组
     * @param orderbysDirection 排序方式数组
     */
    void fixSearch(FGalleryFile tempVo, PageInfo myPage, String[] orderbys, String[] orderbysDirection) throws ChecksException;

    /**
     * 文件移动 例如把当前文档移动到另外一个目录下.
     * @param tempVo 带移动的实体对象 调用部分修改方式,移动时 判断移动到的栏目是否允许添加内容 否则抛出ChecksException("FGalleryType.ifAdd.error"),
     *               添加的内容是否和FGalleryType.contentTypes指定的内容一致.一致才能移动否则ChecksException("FGalleryType.contentTypes.error")
     *               使用部分修改方式
     * @throws ChecksException
     */
    void fixMoveUpdate(FGalleryFile tempVo) throws ChecksException;
}



实现接口

public class FGalleryFileServiceImpl implements FGalleryFileService {

    /**
     * 展示文件添加
     * @param tempVo 待添加的实体对象 前台传递所有值. 判断内容类型与galleryTypeId的类型是否一致是否一致.
     * @throws ChecksException
     */
    @Override
    public void fixAdd(FGalleryFile tempVo) throws ChecksException {
        if (tempVo.getTypes().equals(tempVo.getGalleryTypeId())) {
            tempVo.add();
        }
    }

    /**
     * 展示文件修改
     * @param tempVo 前台传递所有值
     * @throws ChecksException
     */
    @Override
    public void fixEditSave(FGalleryFile tempVo) throws ChecksException {
        tempVo.edit();
    }

    /**
     * 分页数据获取
     * @param tempVo 分页实体
     * @param myPage 分页对象
     * @param orderbys 排序字段数组
     * @param orderbysDirection 排序方式数组
     */
    @Override
    public void fixSearch(FGalleryFile tempVo, PageInfo myPage, String[] orderbys, String[] orderbysDirection) throws ChecksException {

            tempVo.catchPage(myPage,null,tempVo.orderSQLmaker(orderbys,orderbysDirection),null);

    }
    /**
     * 文件移动 例如把当前文档移动到另外一个目录下.
     * @param tempVo 带移动的实体对象 调用部分修改方式,移动时 判断移动到的栏目是否允许添加内容 否则抛出ChecksException("FGalleryType.ifAdd.error"),
     *               添加的内容是否和FGalleryType.contentTypes指定的内容一致.一致才能移动否则ChecksException("FGalleryType.contentTypes.error")
     *               使用部分修改方式
     * @throws ChecksException
     */
    @Override
    public void fixMoveUpdate(FGalleryFile tempVo) throws ChecksException {
        FGalleryType fgt = (FGalleryType)tempVo.hqlQuery("from FGalleryType where id ='"+tempVo.getGalleryTypeId()+"'");
        if(fgt.getIfAdd() == true){
            if(tempVo.getGalleryTypeId().equals(fgt.getContentTypes())){
                tempVo.editPart();
            }else{
                throw new ChecksException("FGalleryType.contentTypes.error");
            }
        }else{
            throw new ChecksException("FGalleryType.ifAdd.error");
        }
    }
}


数据库一个表的外键也是外键对应表的主键

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值