|
@@ -6,8 +6,12 @@ import com.kcim.common.util.UserContext;
|
|
|
import com.kcim.dao.mapper.UserResponsibilityRightMapper;
|
|
|
import com.kcim.dao.model.UserResponsibilityRight;
|
|
|
import org.springframework.stereotype.Repository;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @program: CostAccount
|
|
@@ -22,65 +26,98 @@ public class UserResponsibilityRightRepository extends ServiceImpl<UserResponsib
|
|
|
* @return 列表
|
|
|
*/
|
|
|
public List<UserResponsibilityRight> getList() {
|
|
|
+ return getListByUserId(UserContext.getCurrentUser().getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取指定用户有权限的列表
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<UserResponsibilityRight> getListByUserId(Long userId) {
|
|
|
LambdaQueryWrapper<UserResponsibilityRight> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(UserResponsibilityRight::getHospId, UserContext.getHospId());
|
|
|
- queryWrapper.eq(UserResponsibilityRight::getUserId, UserContext.getCurrentUser().getId());
|
|
|
+ queryWrapper.eq(UserResponsibilityRight::getUserId, userId);
|
|
|
return this.list(queryWrapper);
|
|
|
}
|
|
|
|
|
|
-// public List<StandItem> getList(String name) {
|
|
|
-// LambdaQueryWrapper<StandItem> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
-// queryWrapper.eq(StandItem::getHospId, UserContext.getHospId());
|
|
|
-// if(!StringUtils.isEmpty(name)){
|
|
|
-// queryWrapper.like(StandItem::getName, name);
|
|
|
-// }
|
|
|
-// return this.list(queryWrapper);
|
|
|
-// }
|
|
|
-//
|
|
|
-// public Page<StandItem> getPage(Integer current, Integer pageSize, String name, String kcClassCode) {
|
|
|
-// Page<StandItem> page = new Page<>(current,pageSize);
|
|
|
-// LambdaQueryWrapper<StandItem> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
-// queryWrapper.eq(StandItem::getHospId, UserContext.getHospId());
|
|
|
-// if(!StringUtils.isEmpty(name)){
|
|
|
-//// queryWrapper.like(StandItem::getName,name);
|
|
|
-// queryWrapper.and(q->q.like(StandItem::getName,name).or().like(StandItem::getNationalCode,name));
|
|
|
-// }
|
|
|
-// if(!StringUtils.isEmpty(kcClassCode)){
|
|
|
-// queryWrapper.eq(StandItem::getKcClassCode,kcClassCode);
|
|
|
-// }
|
|
|
-// return this.page(page,queryWrapper);
|
|
|
-// }
|
|
|
-//
|
|
|
-// public StandItem getOneByCode(String code) {
|
|
|
-// LambdaQueryWrapper<StandItem> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
-// queryWrapper.eq(StandItem::getHospId, UserContext.getHospId());
|
|
|
-// queryWrapper.eq(StandItem::getCode,code);
|
|
|
-// return this.getOne(queryWrapper);
|
|
|
-// }
|
|
|
-//
|
|
|
-// public void deleteStandItem(Integer id) {
|
|
|
-// StandItem item = this.getById(id);
|
|
|
-// if(Objects.nonNull(item)){
|
|
|
-// item.setDeleteTime(new Date());
|
|
|
-// item.setDeleteUser(String.valueOf(UserContext.getCurrentUser().getId()));
|
|
|
-// this.updateById(item);
|
|
|
-// this.removeById(id);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// public void removeList(List<StandItem> list) {
|
|
|
-// for (StandItem item : list) {
|
|
|
-// item.setDeleteTime(new Date());
|
|
|
-// item.setDeleteUser(String.valueOf(UserContext.getCurrentUser().getId()));
|
|
|
-// }
|
|
|
-// this.updateBatchById(list,100);
|
|
|
-// List<Integer> collect = list.stream().map(StandItem::getId).collect(Collectors.toList());
|
|
|
-// this.removeBatchByIds(collect,100);
|
|
|
-// }
|
|
|
-//
|
|
|
-// public List<StandItem> getList(SessionUserVO currentUser) {
|
|
|
-// LambdaQueryWrapper<StandItem> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
-// queryWrapper.eq(StandItem::getHospId, currentUser.getHospId());
|
|
|
-// return this.list(queryWrapper);
|
|
|
-// }
|
|
|
+ /**
|
|
|
+ * 批量删除指定用户责任中心权限
|
|
|
+ * @param list
|
|
|
+ */
|
|
|
+ public void removeUserResponsibilityRightList(List<UserResponsibilityRight> list){
|
|
|
+ if(!CollectionUtils.isEmpty(list)){
|
|
|
+ list.stream().forEach(userResponsibility-> {
|
|
|
+ userResponsibility.setDeleteUser(String.valueOf(UserContext.getCurrentUser().getId()));
|
|
|
+ userResponsibility.setDeleteTime(new Date());
|
|
|
+ });
|
|
|
+ this.updateBatchById(list);
|
|
|
+ List<Integer> collect = list.stream().map(UserResponsibilityRight::getId).collect(Collectors.toList());
|
|
|
+ this.removeByIds(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加一个用户责任中心权限
|
|
|
+ * @param userResponsibilityRight
|
|
|
+ */
|
|
|
+ public void addUserResponsibilityRight(UserResponsibilityRight userResponsibilityRight) {
|
|
|
+ userResponsibilityRight.setHospId(UserContext.getHospId());
|
|
|
+ userResponsibilityRight.setCreateTime(new Date());
|
|
|
+ userResponsibilityRight.setCreateUser(String.valueOf(UserContext.getCurrentUser().getId()));
|
|
|
+ this.save(userResponsibilityRight);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加一个用户责任中心权限
|
|
|
+ * @param userId
|
|
|
+ * @param responsibilityCode
|
|
|
+ */
|
|
|
+ public void addUserResponsibilityRight(Long userId,String responsibilityCode) {
|
|
|
+ UserResponsibilityRight userResponsibilityRight = new UserResponsibilityRight();
|
|
|
+ userResponsibilityRight.setHospId(UserContext.getHospId());
|
|
|
+ userResponsibilityRight.setUserId(userId);
|
|
|
+ userResponsibilityRight.setResponsibilityCode(responsibilityCode);
|
|
|
+ userResponsibilityRight.setCreateTime(new Date());
|
|
|
+ userResponsibilityRight.setCreateUser(String.valueOf(UserContext.getCurrentUser().getId()));
|
|
|
+ this.save(userResponsibilityRight);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除一个用户责任中心权限
|
|
|
+ * @param userResponsibilityRight
|
|
|
+ */
|
|
|
+ public void deleteUserResponsibilityRight(UserResponsibilityRight userResponsibilityRight) {
|
|
|
+ LambdaQueryWrapper<UserResponsibilityRight> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(UserResponsibilityRight::getHospId, UserContext.getHospId());
|
|
|
+ queryWrapper.eq(UserResponsibilityRight::getUserId, userResponsibilityRight.getUserId());
|
|
|
+ queryWrapper.eq(UserResponsibilityRight::getResponsibilityCode, userResponsibilityRight.getResponsibilityCode());
|
|
|
+ UserResponsibilityRight item = this.getOne(queryWrapper);
|
|
|
+ if(Objects.nonNull(item)){
|
|
|
+ item.setDeleteTime(new Date());
|
|
|
+ item.setDeleteUser(String.valueOf(UserContext.getCurrentUser().getId()));
|
|
|
+ this.updateById(item);
|
|
|
+ this.removeById(item.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除指定用户的责任中心权限
|
|
|
+ * @param userId
|
|
|
+ * @param responsibilityCode
|
|
|
+ */
|
|
|
+ public void deleteUserResponsibilityRight(Long userId,String responsibilityCode) {
|
|
|
+ LambdaQueryWrapper<UserResponsibilityRight> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(UserResponsibilityRight::getHospId, UserContext.getHospId());
|
|
|
+ queryWrapper.eq(UserResponsibilityRight::getUserId, userId);
|
|
|
+ queryWrapper.eq(UserResponsibilityRight::getResponsibilityCode, responsibilityCode);
|
|
|
+ UserResponsibilityRight item = this.getOne(queryWrapper);
|
|
|
+ if(Objects.nonNull(item)){
|
|
|
+ item.setDeleteTime(new Date());
|
|
|
+ item.setDeleteUser(String.valueOf(UserContext.getCurrentUser().getId()));
|
|
|
+ this.updateById(item);
|
|
|
+ this.removeById(item.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|