package com.fjhx.service.flow;

import com.fjhx.params.JumpVo;
import com.fjhx.service.water.WaterTagService;
import com.fjhx.utils.Assert;
import com.fjhx.utils.ExampleAbstract;
import com.fjhx.utils.FlowConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 删除标签
 */
@Service
public class DeleteTagService {

    @Autowired
    private WaterTagService waterTagService;

    private final FlowConstructor flowConstructor = FlowConstructor.init(new ExampleAbstract() {

        @Override
        public String getCode() {
            return "js_deleteTag";
        }

        @Override
        public void end() {
            Long tagId = getCacheData(Long.class);
            waterTagService.removeById(tagId);
        }

    });

    @Transactional(rollbackFor = Exception.class)
    public void create(Long tagId) {
        Assert.notEmpty(tagId, "标签id不能为空");
        flowConstructor.create(tagId, "删除标签", "", tagId);
    }

    @Transactional(rollbackFor = Exception.class)
    public void jump(JumpVo jumpVo) {
        flowConstructor.jump(jumpVo);
    }


}
