9 changed files with 527 additions and 2 deletions
@ -0,0 +1,105 @@ |
|||
package org.dromara.im.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import jakarta.validation.constraints.*; |
|||
import cn.dev33.satoken.annotation.SaCheckPermission; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
|||
import org.dromara.common.log.annotation.Log; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.common.log.enums.BusinessType; |
|||
import org.dromara.common.excel.utils.ExcelUtil; |
|||
import org.dromara.im.domain.vo.ImAgentVo; |
|||
import org.dromara.im.domain.bo.ImAgentBo; |
|||
import org.dromara.im.service.IImAgentService; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
|
|||
/** |
|||
* 代理关联 |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-07 |
|||
*/ |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/im/agent") |
|||
public class ImAgentController extends BaseController { |
|||
|
|||
private final IImAgentService imAgentService; |
|||
|
|||
/** |
|||
* 查询代理关联列表 |
|||
*/ |
|||
@SaCheckPermission("im:agent:list") |
|||
//@GetMapping("/list")
|
|||
public TableDataInfo<ImAgentVo> list(ImAgentBo bo, PageQuery pageQuery) { |
|||
return imAgentService.queryPageList(bo, pageQuery); |
|||
} |
|||
|
|||
/** |
|||
* 导出代理关联列表 |
|||
*/ |
|||
@SaCheckPermission("im:agent:export") |
|||
//@Log(title = "代理关联", businessType = BusinessType.EXPORT)
|
|||
//@PostMapping("/export")
|
|||
public void export(ImAgentBo bo, HttpServletResponse response) { |
|||
List<ImAgentVo> list = imAgentService.queryList(bo); |
|||
ExcelUtil.exportExcel(list, "代理关联", ImAgentVo.class, response); |
|||
} |
|||
|
|||
/** |
|||
* 获取代理关联详细信息 |
|||
* |
|||
* @param id 主键 |
|||
*/ |
|||
@SaCheckPermission("im:agent:query") |
|||
//@GetMapping("/{id}")
|
|||
public R<ImAgentVo> getInfo(@NotNull(message = "主键不能为空") |
|||
@PathVariable Long id) { |
|||
return R.ok(imAgentService.queryById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增代理关联 |
|||
*/ |
|||
@SaCheckPermission("im:agent:add") |
|||
@Log(title = "代理关联", businessType = BusinessType.INSERT) |
|||
//@RepeatSubmit()
|
|||
//@PostMapping()
|
|||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ImAgentBo bo) { |
|||
return toAjax(imAgentService.insertByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 修改代理关联 |
|||
*/ |
|||
@SaCheckPermission("im:agent:edit") |
|||
@Log(title = "代理关联", businessType = BusinessType.UPDATE) |
|||
//@RepeatSubmit()
|
|||
//@PutMapping()
|
|||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ImAgentBo bo) { |
|||
return toAjax(imAgentService.updateByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 删除代理关联 |
|||
* |
|||
* @param ids 主键串 |
|||
*/ |
|||
@SaCheckPermission("im:agent:remove") |
|||
@Log(title = "代理关联", businessType = BusinessType.DELETE) |
|||
//@DeleteMapping("/{ids}")
|
|||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|||
@PathVariable Long[] ids) { |
|||
return toAjax(imAgentService.deleteWithValidByIds(List.of(ids), true)); |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
package org.dromara.im.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 ImAgent 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,65 @@ |
|||
package org.dromara.im.domain.bo; |
|||
|
|||
import org.dromara.im.domain.ImAgent; |
|||
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 jakarta.validation.constraints.*; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 代理关联业务对象 im_agent |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-07 |
|||
*/ |
|||
@Data |
|||
@AutoMapper(target = ImAgent.class, reverseConvertGenerate = false) |
|||
public class ImAgentBo { |
|||
|
|||
/** |
|||
* 主键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,76 @@ |
|||
package org.dromara.im.domain.vo; |
|||
|
|||
import java.util.Date; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import org.dromara.im.domain.ImAgent; |
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import org.dromara.common.excel.annotation.ExcelDictFormat; |
|||
import org.dromara.common.excel.convert.ExcelDictConvert; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 代理关联视图对象 im_agent |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-07 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = ImAgent.class) |
|||
public class ImAgentVo 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.im.mapper; |
|||
|
|||
import org.dromara.im.domain.ImAgent; |
|||
import org.dromara.im.domain.vo.ImAgentVo; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
|
|||
/** |
|||
* 代理关联Mapper接口 |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-07 |
|||
*/ |
|||
public interface ImAgentMapper extends BaseMapperPlus<ImAgent, ImAgentVo> { |
|||
|
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
package org.dromara.im.service; |
|||
|
|||
import org.dromara.im.domain.vo.ImAgentVo; |
|||
import org.dromara.im.domain.bo.ImAgentBo; |
|||
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 IImAgentService { |
|||
|
|||
/** |
|||
* 查询代理关联 |
|||
* |
|||
* @param id 主键 |
|||
* @return 代理关联 |
|||
*/ |
|||
ImAgentVo queryById(Long id); |
|||
|
|||
/** |
|||
* 分页查询代理关联列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 代理关联分页列表 |
|||
*/ |
|||
TableDataInfo<ImAgentVo> queryPageList(ImAgentBo bo, PageQuery pageQuery); |
|||
|
|||
/** |
|||
* 查询符合条件的代理关联列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 代理关联列表 |
|||
*/ |
|||
List<ImAgentVo> queryList(ImAgentBo bo); |
|||
|
|||
/** |
|||
* 新增代理关联 |
|||
* |
|||
* @param bo 代理关联 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
Boolean insertByBo(ImAgentBo bo); |
|||
|
|||
/** |
|||
* 修改代理关联 |
|||
* |
|||
* @param bo 代理关联 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
Boolean updateByBo(ImAgentBo bo); |
|||
|
|||
/** |
|||
* 校验并批量删除代理关联信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
|||
} |
|||
@ -0,0 +1,136 @@ |
|||
package org.dromara.im.service.impl; |
|||
|
|||
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.im.constant.ImConstant; |
|||
import org.springframework.stereotype.Service; |
|||
import org.dromara.im.domain.bo.ImAgentBo; |
|||
import org.dromara.im.domain.vo.ImAgentVo; |
|||
import org.dromara.im.domain.ImAgent; |
|||
import org.dromara.im.mapper.ImAgentMapper; |
|||
import org.dromara.im.service.IImAgentService; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* 代理关联Service业务层处理 |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-07 |
|||
*/ |
|||
@DS(ImConstant.DS_IM_PLATFORM) |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class ImAgentServiceImpl implements IImAgentService { |
|||
|
|||
private final ImAgentMapper baseMapper; |
|||
|
|||
/** |
|||
* 查询代理关联 |
|||
* |
|||
* @param id 主键 |
|||
* @return 代理关联 |
|||
*/ |
|||
@Override |
|||
public ImAgentVo queryById(Long id){ |
|||
return baseMapper.selectVoById(id); |
|||
} |
|||
|
|||
/** |
|||
* 分页查询代理关联列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 代理关联分页列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo<ImAgentVo> queryPageList(ImAgentBo bo, PageQuery pageQuery) { |
|||
LambdaQueryWrapper<ImAgent> lqw = buildQueryWrapper(bo); |
|||
Page<ImAgentVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
/** |
|||
* 查询符合条件的代理关联列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 代理关联列表 |
|||
*/ |
|||
@Override |
|||
public List<ImAgentVo> queryList(ImAgentBo bo) { |
|||
LambdaQueryWrapper<ImAgent> lqw = buildQueryWrapper(bo); |
|||
return baseMapper.selectVoList(lqw); |
|||
} |
|||
|
|||
private LambdaQueryWrapper<ImAgent> buildQueryWrapper(ImAgentBo bo) { |
|||
//Map<String, Object> params = bo.getParams();
|
|||
LambdaQueryWrapper<ImAgent> lqw = Wrappers.lambdaQuery(); |
|||
lqw.eq(bo.getSysId() != null, ImAgent::getSysId, bo.getSysId()); |
|||
lqw.like(StringUtils.isNotBlank(bo.getAgentName()), ImAgent::getAgentName, bo.getAgentName()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getUniqueToken()), ImAgent::getUniqueToken, bo.getUniqueToken()); |
|||
lqw.eq(bo.getCreatedTime() != null, ImAgent::getCreatedTime, bo.getCreatedTime()); |
|||
lqw.eq(bo.getUpdatedTime() != null, ImAgent::getUpdatedTime, bo.getUpdatedTime()); |
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增代理关联 |
|||
* |
|||
* @param bo 代理关联 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(ImAgentBo bo) { |
|||
ImAgent add = MapstructUtils.convert(bo, ImAgent.class); |
|||
validEntityBeforeSave(add); |
|||
boolean flag = baseMapper.insert(add) > 0; |
|||
if (flag) { |
|||
bo.setId(add.getId()); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改代理关联 |
|||
* |
|||
* @param bo 代理关联 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(ImAgentBo bo) { |
|||
ImAgent update = MapstructUtils.convert(bo, ImAgent.class); |
|||
validEntityBeforeSave(update); |
|||
return baseMapper.updateById(update) > 0; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(ImAgent entity){ |
|||
//TODO 做一些数据校验,如唯一约束
|
|||
} |
|||
|
|||
/** |
|||
* 校验并批量删除代理关联信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
|||
if(isValid){ |
|||
//TODO 做一些业务上的校验,判断是否需要校验
|
|||
} |
|||
return baseMapper.deleteByIds(ids) > 0; |
|||
} |
|||
} |
|||
@ -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.im.mapper.ImAgentMapper"> |
|||
|
|||
</mapper> |
|||
Loading…
Reference in new issue