12 changed files with 501 additions and 7 deletions
@ -0,0 +1,14 @@ |
|||||
|
package org.dromara.system.controller.constant; |
||||
|
|
||||
|
/** |
||||
|
* @author: Blue |
||||
|
* @date: 2024-07-20 |
||||
|
* @version: 1.0 |
||||
|
*/ |
||||
|
public class ImConstant { |
||||
|
|
||||
|
/** |
||||
|
* IM数据源 |
||||
|
*/ |
||||
|
public final static String DS_IM_PLATFORM = "platform"; |
||||
|
} |
||||
@ -0,0 +1,55 @@ |
|||||
|
package org.dromara.system.domain; |
||||
|
|
||||
|
import com.fhs.core.trans.vo.TransPojo; |
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 代理关联对象 im_agent |
||||
|
* |
||||
|
* @author Blue |
||||
|
* @date 2026-04-07 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("im_agent") |
||||
|
public class ImAgentAdmin implements TransPojo { |
||||
|
/** |
||||
|
* 主键ID |
||||
|
*/ |
||||
|
@TableId(value = "id") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 管理端ID |
||||
|
*/ |
||||
|
private Long sysId; |
||||
|
|
||||
|
/** |
||||
|
* 代理用户名 |
||||
|
*/ |
||||
|
private String agentName; |
||||
|
|
||||
|
/** |
||||
|
* 唯一token |
||||
|
*/ |
||||
|
private String uniqueToken; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,66 @@ |
|||||
|
package org.dromara.system.domain.bo; |
||||
|
|
||||
|
import org.dromara.system.domain.ImAgentAdmin; |
||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.common.core.validate.EditGroup; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import jakarta.validation.constraints.*; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 代理关联业务对象 im_agent |
||||
|
* |
||||
|
* @author Blue |
||||
|
* @date 2026-04-07 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
public class ImAgentAdminBo extends BaseEntity { |
||||
|
|
||||
|
/** |
||||
|
* 主键ID |
||||
|
*/ |
||||
|
@NotNull(message = "主键ID不能为空", groups = { EditGroup.class }) |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 管理端ID |
||||
|
*/ |
||||
|
@NotNull(message = "管理端ID不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private Long sysId; |
||||
|
|
||||
|
/** |
||||
|
* 代理用户名 |
||||
|
*/ |
||||
|
@NotBlank(message = "代理用户名不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String agentName; |
||||
|
|
||||
|
/** |
||||
|
* 唯一token |
||||
|
*/ |
||||
|
@NotBlank(message = "唯一token不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String uniqueToken; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String remark; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
@NotNull(message = "创建时间不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
@NotNull(message = "更新时间不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,72 @@ |
|||||
|
package org.dromara.system.domain.vo; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
import org.dromara.system.domain.ImAgentAdmin; |
||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 代理关联视图对象 im_agent |
||||
|
* |
||||
|
* @author Blue |
||||
|
* @date 2026-04-07 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
@AutoMapper(target = ImAgentAdmin.class) |
||||
|
public class ImAgentAdminVo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键ID |
||||
|
*/ |
||||
|
@ExcelProperty(value = "主键ID") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 管理端ID |
||||
|
*/ |
||||
|
@ExcelProperty(value = "管理端ID") |
||||
|
private Long sysId; |
||||
|
|
||||
|
/** |
||||
|
* 代理用户名 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "代理用户名") |
||||
|
private String agentName; |
||||
|
|
||||
|
/** |
||||
|
* 唯一token |
||||
|
*/ |
||||
|
@ExcelProperty(value = "唯一token") |
||||
|
private String uniqueToken; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "备注") |
||||
|
private String remark; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "创建时间") |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "更新时间") |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
package org.dromara.system.mapper; |
||||
|
|
||||
|
import org.dromara.system.domain.ImAgentAdmin; |
||||
|
import org.dromara.system.domain.vo.ImAgentAdminVo; |
||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
||||
|
|
||||
|
/** |
||||
|
* 代理关联Mapper接口 |
||||
|
* |
||||
|
* @author Blue |
||||
|
* @date 2026-04-07 |
||||
|
*/ |
||||
|
public interface ImAgentAdminMapper extends BaseMapperPlus<ImAgentAdmin, ImAgentAdminVo> { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,76 @@ |
|||||
|
package org.dromara.system.service; |
||||
|
|
||||
|
import org.dromara.system.domain.vo.ImAgentAdminVo; |
||||
|
import org.dromara.system.domain.bo.ImAgentAdminBo; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 代理关联Service接口 |
||||
|
* |
||||
|
* @author Blue |
||||
|
* @date 2026-04-07 |
||||
|
*/ |
||||
|
public interface IImAgentAdminService { |
||||
|
|
||||
|
/** |
||||
|
* 查询代理关联 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 代理关联 |
||||
|
*/ |
||||
|
ImAgentAdminVo queryById(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 分页查询代理关联列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 代理关联分页列表 |
||||
|
*/ |
||||
|
TableDataInfo<ImAgentAdminVo> queryPageList(ImAgentAdminBo bo, PageQuery pageQuery); |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的代理关联列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 代理关联列表 |
||||
|
*/ |
||||
|
List<ImAgentAdminVo> queryList(ImAgentAdminBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 新增代理关联 |
||||
|
* |
||||
|
* @param bo 代理关联 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
Boolean insertByBo(ImAgentAdminBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 修改代理关联 |
||||
|
* |
||||
|
* @param bo 代理关联 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
Boolean updateByBo(ImAgentAdminBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除代理关联信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
||||
|
|
||||
|
/** |
||||
|
* 插入代理数据 |
||||
|
* |
||||
|
* @param userId 用户id |
||||
|
* @return 插入数量 |
||||
|
*/ |
||||
|
int insertAgentData(Long userId,String agentName); |
||||
|
} |
||||
@ -0,0 +1,149 @@ |
|||||
|
package org.dromara.system.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.util.RandomUtil; |
||||
|
import com.baomidou.dynamic.datasource.annotation.DS; |
||||
|
import org.dromara.common.core.utils.MapstructUtils; |
||||
|
import org.dromara.common.core.utils.StringUtils; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.dromara.system.controller.constant.ImConstant; |
||||
|
import org.dromara.system.domain.ImAgentAdmin; |
||||
|
import org.dromara.system.domain.bo.ImAgentAdminBo; |
||||
|
import org.dromara.system.domain.vo.ImAgentAdminVo; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.dromara.system.mapper.ImAgentAdminMapper; |
||||
|
import org.dromara.system.service.IImAgentAdminService; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Collection; |
||||
|
|
||||
|
/** |
||||
|
* 代理关联Service业务层处理 |
||||
|
* |
||||
|
* @author Blue |
||||
|
* @date 2026-04-07 |
||||
|
*/ |
||||
|
@RequiredArgsConstructor |
||||
|
@Service |
||||
|
@DS(ImConstant.DS_IM_PLATFORM) |
||||
|
public class ImAgentAdminServiceImpl implements IImAgentAdminService { |
||||
|
|
||||
|
private final ImAgentAdminMapper baseMapper; |
||||
|
|
||||
|
/** |
||||
|
* 查询代理关联 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 代理关联 |
||||
|
*/ |
||||
|
@Override |
||||
|
public ImAgentAdminVo queryById(Long id){ |
||||
|
return baseMapper.selectVoById(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 分页查询代理关联列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 代理关联分页列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public TableDataInfo<ImAgentAdminVo> queryPageList(ImAgentAdminBo bo, PageQuery pageQuery) { |
||||
|
LambdaQueryWrapper<ImAgentAdmin> lqw = buildQueryWrapper(bo); |
||||
|
Page<ImAgentAdminVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
||||
|
return TableDataInfo.build(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的代理关联列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 代理关联列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<ImAgentAdminVo> queryList(ImAgentAdminBo bo) { |
||||
|
LambdaQueryWrapper<ImAgentAdmin> lqw = buildQueryWrapper(bo); |
||||
|
return baseMapper.selectVoList(lqw); |
||||
|
} |
||||
|
|
||||
|
private LambdaQueryWrapper<ImAgentAdmin> buildQueryWrapper(ImAgentAdminBo bo) { |
||||
|
Map<String, Object> params = bo.getParams(); |
||||
|
LambdaQueryWrapper<ImAgentAdmin> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.eq(bo.getSysId() != null, ImAgentAdmin::getSysId, bo.getSysId()); |
||||
|
lqw.like(StringUtils.isNotBlank(bo.getAgentName()), ImAgentAdmin::getAgentName, bo.getAgentName()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getUniqueToken()), ImAgentAdmin::getUniqueToken, bo.getUniqueToken()); |
||||
|
lqw.eq(bo.getCreatedTime() != null, ImAgentAdmin::getCreatedTime, bo.getCreatedTime()); |
||||
|
lqw.eq(bo.getUpdatedTime() != null, ImAgentAdmin::getUpdatedTime, bo.getUpdatedTime()); |
||||
|
return lqw; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增代理关联 |
||||
|
* |
||||
|
* @param bo 代理关联 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean insertByBo(ImAgentAdminBo bo) { |
||||
|
ImAgentAdmin add = MapstructUtils.convert(bo, ImAgentAdmin.class); |
||||
|
validEntityBeforeSave(add); |
||||
|
boolean flag = baseMapper.insert(add) > 0; |
||||
|
if (flag) { |
||||
|
bo.setId(add.getId()); |
||||
|
} |
||||
|
return flag; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改代理关联 |
||||
|
* |
||||
|
* @param bo 代理关联 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean updateByBo(ImAgentAdminBo bo) { |
||||
|
ImAgentAdmin update = MapstructUtils.convert(bo, ImAgentAdmin.class); |
||||
|
validEntityBeforeSave(update); |
||||
|
return baseMapper.updateById(update) > 0; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 保存前的数据校验 |
||||
|
*/ |
||||
|
private void validEntityBeforeSave(ImAgentAdmin entity){ |
||||
|
//TODO 做一些数据校验,如唯一约束
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除代理关联信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
||||
|
if(isValid){ |
||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
|
} |
||||
|
return baseMapper.deleteByIds(ids) > 0; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int insertAgentData(Long userId,String agentName) { |
||||
|
ImAgentAdmin agent = new ImAgentAdmin(); |
||||
|
agent.setSysId(userId); |
||||
|
agent.setAgentName(agentName); |
||||
|
|
||||
|
//随机在1-9与26个字母中生成18位的随机数设置为token
|
||||
|
agent.setUniqueToken(RandomUtil.randomString(18)); |
||||
|
|
||||
|
return baseMapper.insert(agent); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
<?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="org.dromara.system.mapper.ImAgentAdminMapper"> |
||||
|
|
||||
|
</mapper> |
||||
Loading…
Reference in new issue