|
|
@@ -13,8 +13,10 @@ import com.ydtech.modules.admin.model.po.SysSys;
|
|
|
import com.ydtech.modules.admin.model.po.SysUserLinkSys;
|
|
|
import com.ydtech.modules.admin.service.SysSysService;
|
|
|
import com.ydtech.modules.admin.service.SysUserLinkSysService;
|
|
|
+import com.ydtech.modules.admin.service.SysUserService;
|
|
|
import com.ydtech.modules.base.controller.BaseController;
|
|
|
import com.ydtech.modules.order.entity.BasePageResult;
|
|
|
+import com.ydtech.utils.StringUtils;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -38,6 +40,8 @@ public class SysUserLinkSysServiceImpl extends ServiceImpl<SysUserLinkSysMapper,
|
|
|
|
|
|
@Autowired
|
|
|
private SysSysService sysSysService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserService sysUserService;
|
|
|
|
|
|
/**
|
|
|
* @version
|
|
|
@@ -61,22 +65,27 @@ public class SysUserLinkSysServiceImpl extends ServiceImpl<SysUserLinkSysMapper,
|
|
|
*/
|
|
|
@Override
|
|
|
public void addOrUpdate(SysUserLinkSysAddDto sysUserLinkSysAddDto) {
|
|
|
- //先删除后添加
|
|
|
- this.getBaseMapper().delete(new QueryWrapper<SysUserLinkSys>()
|
|
|
- .lambda()
|
|
|
- .eq(SysUserLinkSys::getUserId, sysUserLinkSysAddDto.getUserId()));
|
|
|
- String userId = sysUserLinkSysAddDto.getUserId();
|
|
|
- List<Long> list = sysUserLinkSysAddDto.getList();
|
|
|
- List<SysUserLinkSys> addList =new ArrayList<SysUserLinkSys>();
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
- for (Long sysId : list){
|
|
|
- SysUserLinkSys sysUserLinkSys =new SysUserLinkSys(sysId, userId,new Date(), new BaseController().getUser().getId(), new Date(), new BaseController().getUser().getId());
|
|
|
- addList.add(sysUserLinkSys);
|
|
|
+ List<String> userIds ;
|
|
|
+ if("1".equals(sysUserLinkSysAddDto.getFlag())){
|
|
|
+ userIds = sysUserService.getUserIds();
|
|
|
+ }else {
|
|
|
+ userIds = sysUserLinkSysAddDto.getUserIds();
|
|
|
+ }
|
|
|
+ if (userIds.size() > 0 && sysUserLinkSysAddDto.getSysId() != null && StringUtils.isNotEmpty(sysUserLinkSysAddDto.getFlag())) {
|
|
|
+ List<String> existUserIds = baseMapper.setByUserIds(userIds, sysUserLinkSysAddDto.getSysId());
|
|
|
+ userIds.removeAll(existUserIds);
|
|
|
+ List<SysUserLinkSys> addList = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(userIds)) {
|
|
|
+ for (String userId : userIds) {
|
|
|
+ SysUserLinkSys sysUserLinkSys = new SysUserLinkSys(sysUserLinkSysAddDto.getSysId(), userId, new Date(), userId, new Date(), new BaseController().getUser().getId());
|
|
|
+ addList.add(sysUserLinkSys);
|
|
|
+ }
|
|
|
+ //添加
|
|
|
+ this.saveBatch(addList, 50);
|
|
|
}
|
|
|
- //添加
|
|
|
- this.saveBatch(addList,50);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @version
|
|
|
* @author: hxl
|
|
|
@@ -113,6 +122,11 @@ public class SysUserLinkSysServiceImpl extends ServiceImpl<SysUserLinkSysMapper,
|
|
|
return new BasePageResult<>(sysUserDto.getPageNum(), page.getSize(), result.getTotal(), page.getPages(),
|
|
|
result.getRecords());
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SysUserLinkSys checkSys(String id, String sysId) {
|
|
|
+ return baseMapper.checkSys(id,sysId);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|