update 更改模块名称
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package com.jero.modules.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 领域与用户关系实体
|
||||
*@Author: wzj
|
||||
*@Date: 2022/3/2 11:41
|
||||
**/
|
||||
@Data
|
||||
@TableName("domain_user_rel")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="domain_user_rel对象", description="领域与用户关系表")
|
||||
public class DomainUserRel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty("主键")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("领域id")
|
||||
private String domainId;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private String userId;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.jero.modules.domain.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.jero.modules.domain.entity.DomainUserRel;
|
||||
/**
|
||||
* 领域与用户关系
|
||||
*@Author: wzj
|
||||
*@Date: 2022/3/2 11:41
|
||||
**/
|
||||
public interface DomainUserRelMapper extends BaseMapper<DomainUserRel> {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jero.modules.domain.mapper.DomainUserRelMapper">
|
||||
<resultMap id="OnlCgformSubscribeResultMap" type="com.jero.modules.domain.entity.DomainUserRel">
|
||||
<id column="id" property="id" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="domain_id" property="domainId" />
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.jero.modules.domain.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.domain.entity.DomainUserRel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 领域与用户关系
|
||||
*@Author: wzj
|
||||
*@Date: 2022/3/2 11:40
|
||||
**/
|
||||
public interface DomainUserRelService extends IService<DomainUserRel> {
|
||||
|
||||
Result<?> insert(JSONObject jsonObject);
|
||||
|
||||
Result<?> queryList();
|
||||
|
||||
/**
|
||||
* 查询领域、文档关联的用户
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<String> queryDomainUserRelInfo(Map<String,Object> params);
|
||||
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package com.jero.modules.domain.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.domain.entity.DomainUserRel;
|
||||
import com.jero.modules.domain.mapper.DomainUserRelMapper;
|
||||
import com.jero.modules.domain.service.DomainUserRelService;
|
||||
import com.jero.modules.system.mapper.SysUserMapper;
|
||||
import me.zhyd.oauth.utils.StringUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 领域与用户关系
|
||||
*@Author: wzj
|
||||
*@Date: 2022/3/2 11:41
|
||||
**/
|
||||
@Service
|
||||
public class DomainManageServiceImpl extends ServiceImpl<DomainUserRelMapper, DomainUserRel> implements DomainUserRelService {
|
||||
|
||||
//我的订阅
|
||||
//@Autowired
|
||||
//private OnlCgformSubscribeMapper onlCgformSubscribeMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Override
|
||||
public Result<?> insert(JSONObject jsonObject) {
|
||||
try {
|
||||
List<String> domainIdList = jsonObject.getJSONArray("domainIdList").toJavaList(String.class);
|
||||
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userName = currentUser.getUsername();
|
||||
String userId = currentUser.getId();
|
||||
QueryWrapper<DomainUserRel> deleteWrapepr = new QueryWrapper<>();
|
||||
deleteWrapepr.lambda().eq(DomainUserRel::getUserId,userId);
|
||||
super.baseMapper.delete(deleteWrapepr);
|
||||
|
||||
List<DomainUserRel> domainUserRelList = new ArrayList<>();
|
||||
domainIdList.forEach(domainId -> {
|
||||
DomainUserRel domainUserRel = new DomainUserRel();
|
||||
domainUserRel.setCreateBy(userName);
|
||||
domainUserRel.setDomainId(domainId);
|
||||
domainUserRel.setUserId(userId);
|
||||
domainUserRel.setCreateTime(new Date());
|
||||
domainUserRelList.add(domainUserRel);
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(domainIdList)) {
|
||||
super.saveBatch(domainUserRelList);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
log.error("添加领域与用户关系失败:" + ex.getMessage());
|
||||
throw new JeroBootException("添加失败!");
|
||||
}
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> queryList() {
|
||||
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = currentUser.getId();
|
||||
QueryWrapper<DomainUserRel> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(DomainUserRel::getUserId,userId);
|
||||
List<DomainUserRel> domainUserRels = super.baseMapper.selectList(queryWrapper);
|
||||
return Result.OK(domainUserRels);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询领域、文档关联的用户
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> queryDomainUserRelInfo(Map<String, Object> params) {
|
||||
String domainId = (String) params.get("domainId");
|
||||
String documentId = (String) params.get("documentId");
|
||||
List<String> result = new ArrayList<>();
|
||||
try {
|
||||
//获取订阅该领域的所有用户信息
|
||||
if(StringUtils.isNotEmpty(domainId)){
|
||||
QueryWrapper<DomainUserRel> queryDomain = new QueryWrapper<>();
|
||||
queryDomain.lambda().in(DomainUserRel::getDomainId, Arrays.asList(domainId.split(",")));
|
||||
List<DomainUserRel> domainUserRelList = super.baseMapper.selectList(queryDomain);
|
||||
if(CollectionUtils.isNotEmpty(domainUserRelList)){
|
||||
result = domainUserRelList.stream().map(DomainUserRel::getUserId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
}catch (Exception ex){
|
||||
log.error("根据领域id、文档id查询用户失败:" + ex.getMessage());
|
||||
throw new JeroBootException("根据领域id、文档id查询用户失败!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user