package jnpf.flowable.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import jnpf.base.UserInfo; import jnpf.base.service.SuperServiceImpl; import jnpf.flowable.entity.CommonEntity; import jnpf.flowable.mapper.CommonMapper; import jnpf.flowable.service.CommonService; import jnpf.util.RandomUtil; import jnpf.util.StringUtil; import jnpf.util.UserProvider; import org.springframework.stereotype.Service; import java.util.List; /** * 类的描述 * * @author JNPF@YinMai Info. Co., Ltd * @version 5.0.x * @since 2024/5/22 20:32 */ @Service public class CommonServiceImpl extends SuperServiceImpl implements CommonService { @Override public List getCommonByUserId(String userId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(CommonEntity::getCreatorUserId, userId); return this.list(queryWrapper); } @Override public int setCommonFLow(String flowId) { UserInfo userInfo = UserProvider.getUser(); String userId = userInfo.getUserId(); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(CommonEntity::getFlowId, flowId) .eq(CommonEntity::getCreatorUserId, userId); List list = this.list(queryWrapper); if (CollectionUtil.isNotEmpty(list)) { this.removeByIds(list); return 2; } else { CommonEntity entity = new CommonEntity(); entity.setId(RandomUtil.uuId()); entity.setFlowId(flowId); entity.setCreatorUserId(userId); this.save(entity); } return 1; } @Override public void deleteFlow(String flowId) { if (StringUtil.isNotEmpty(flowId)) { QueryWrapper common = new QueryWrapper<>(); common.lambda().eq(CommonEntity::getFlowId, flowId); this.remove(common); } } }