添加"客户端管理"模块
This commit is contained in:
parent
6e9d42088b
commit
a2e904d1f2
@ -88,14 +88,14 @@ Ruoyi-Flex实行前后端分离仓库,本项目是java后端部分,前端项
|
||||
|
||||
## 7、Ruoyi-Flex交流群
|
||||
|
||||
本软件完全开源,作者很忙,如果您在使用过程中遇到问题,请付点小费(扫码微信支付199元)后申请加入微信群寻求帮助:
|
||||
本软件完全开源,作者很忙,如果您在使用过程中遇到问题,请付点小费(扫码微信支付99元)后申请加入微信群寻求帮助:
|
||||
<table>
|
||||
<tr>
|
||||
<td>1、免费QQ交流群:</td>
|
||||
<td>762217712[交流1群]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2、付费微信交流群:</td>
|
||||
<td>2、付费微信VIP群(微信扫码支付99元加好友入群):</td>
|
||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/dataprince.jpg"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -65,8 +65,4 @@ public class MyBatisFlexConfig implements ConfigurationCustomizer, MyBatisFlexCu
|
||||
AuditManager.setMessageCollector(new ConsoleMessageCollector());
|
||||
}
|
||||
|
||||
//TODO:动态表名
|
||||
|
||||
//TODO:多租户配置
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,20 @@
|
||||
package com.ruoyi.system.controller.system;
|
||||
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.common.core.core.domain.R;
|
||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.web.annotation.RepeatSubmit;
|
||||
import com.ruoyi.system.domain.bo.SysClientBo;
|
||||
import com.ruoyi.system.domain.vo.SysClientVo;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -10,92 +23,114 @@ import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.ruoyi.system.service.ISysClientService;
|
||||
import com.ruoyi.system.domain.SysClient;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统授权表 控制层。
|
||||
*
|
||||
* @author mybatis-flex-helper automatic generation
|
||||
* @since 1.0
|
||||
* @author 数据小王子
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/sysClient")
|
||||
@RequestMapping("/system/client")
|
||||
public class SysClientController {
|
||||
|
||||
@Resource
|
||||
private ISysClientService sysClientService;
|
||||
|
||||
/**
|
||||
* 添加 系统授权表
|
||||
*
|
||||
* @param sysClient 系统授权表
|
||||
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||
* 查询客户端管理列表
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public boolean save(@RequestBody SysClient sysClient) {
|
||||
return sysClientService.save(sysClient);
|
||||
@SaCheckPermission("system:client:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysClientVo> list(SysClientBo sysClientBo) {
|
||||
return sysClientService.selectPage(sysClientBo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出客户端管理列表
|
||||
*/
|
||||
@SaCheckPermission("system:client:export")
|
||||
@Log(title = "客户端管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(SysClientBo sysClientBo, HttpServletResponse response) {
|
||||
List<SysClientVo> list = sysClientService.selectList(sysClientBo);
|
||||
ExcelUtil.exportExcel(list, "客户端管理", SysClientVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键删除系统授权表
|
||||
* 获取客户端管理详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
||||
*/
|
||||
@DeleteMapping("/remove/{id}")
|
||||
public boolean remove(@PathVariable Serializable id) {
|
||||
return sysClientService.removeById(id);
|
||||
@SaCheckPermission("system:client:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<SysClientVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(sysClientService.selectById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据主键更新系统授权表
|
||||
*
|
||||
* @param sysClient 系统授权表
|
||||
* @return {@code true} 更新成功,{@code false} 更新失败
|
||||
* 新增客户端管理
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public boolean update(@RequestBody SysClient sysClient) {
|
||||
return sysClientService.updateById(sysClient);
|
||||
@SaCheckPermission("system:client:add")
|
||||
@Log(title = "客户端管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated @RequestBody SysClientBo sysClientBo) {
|
||||
boolean inserted = sysClientService.insert(sysClientBo);
|
||||
if (!inserted) {
|
||||
return R.fail("新增客户端管理记录失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有系统授权表
|
||||
*
|
||||
* @return 所有数据
|
||||
* 修改客户端管理
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public List<SysClient> list() {
|
||||
return sysClientService.list();
|
||||
@SaCheckPermission("system:client:edit")
|
||||
@Log(title = "客户端管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated @RequestBody SysClientBo sysClientBo) {
|
||||
Boolean updated = sysClientService.update(sysClientBo);
|
||||
if (!updated) {
|
||||
R.fail("修改客户端管理记录失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据系统授权表主键获取详细信息。
|
||||
*
|
||||
* @param id sysClient主键
|
||||
* @return 系统授权表详情
|
||||
* 状态修改
|
||||
*/
|
||||
@GetMapping("/getInfo/{id}")
|
||||
public SysClient getInfo(@PathVariable Serializable id) {
|
||||
return sysClientService.getById(id);
|
||||
@SaCheckPermission("system:client:edit")
|
||||
@Log(title = "客户端管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysClientBo sysClientBo) {
|
||||
Boolean updated = sysClientService.updateStatus(sysClientBo.getId(),sysClientBo.getStatus());
|
||||
if (!updated) {
|
||||
R.fail("修改客户端管理状态失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询系统授权表
|
||||
* 删除客户端管理
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @return 分页对象
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Page<SysClient> page(Page<SysClient> page) {
|
||||
return sysClientService.page(page);
|
||||
@SaCheckPermission("system:client:remove")
|
||||
@Log(title = "客户端管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
boolean deleted = sysClientService.deleteByIds(List.of(ids));
|
||||
if (!deleted) {
|
||||
R.fail("删除客户端管理记录失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.orm.listener.EntityInsertListener;
|
||||
import com.ruoyi.common.orm.listener.EntityUpdateListener;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ -27,7 +24,7 @@ public class SysClient extends BaseEntity {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id()
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -71,9 +68,8 @@ public class SysClient extends BaseEntity {
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 1代表删除)
|
||||
* 删除标志(0就代表存在 1就代表删除)
|
||||
*/
|
||||
@Column(isLogicDelete = true)
|
||||
private Integer delFlag;
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
@ -22,6 +23,12 @@ public class SysConfig extends BaseEntity
|
||||
@Id
|
||||
private Long configId;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
@Column(tenantId = true)
|
||||
private Long tenantId;
|
||||
|
||||
/** 参数名称 */
|
||||
private String configName;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class SysClientVo implements Serializable {
|
||||
/**
|
||||
* 授权类型
|
||||
*/
|
||||
@ExcelProperty(value = "授权类型")
|
||||
//@ExcelProperty(value = "授权类型")
|
||||
private List<String> grantTypeList;
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,15 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
|
||||
import com.ruoyi.common.orm.core.page.PageQuery;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.SysClient;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.ruoyi.system.domain.bo.SysClientBo;
|
||||
import com.ruoyi.system.domain.vo.SysClientVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统授权表 服务层。
|
||||
@ -11,5 +18,43 @@ import com.mybatisflex.core.service.IService;
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface ISysClientService extends IService<SysClient> {
|
||||
/**
|
||||
* 查询客户端管理
|
||||
*/
|
||||
SysClientVo selectById(Long id);
|
||||
|
||||
/**
|
||||
* 查询客户端信息基于客户端id
|
||||
*/
|
||||
SysClient selectByClientId(String clientId);
|
||||
|
||||
/**
|
||||
* 查询客户端管理列表
|
||||
*/
|
||||
TableDataInfo<SysClientVo> selectPage(SysClientBo sysClientBo);
|
||||
|
||||
/**
|
||||
* 查询客户端管理列表
|
||||
*/
|
||||
List<SysClientVo> selectList(SysClientBo sysClientBo);
|
||||
|
||||
/**
|
||||
* 新增客户端管理
|
||||
*/
|
||||
Boolean insert(SysClientBo sysClientBo);
|
||||
|
||||
/**
|
||||
* 修改客户端管理
|
||||
*/
|
||||
Boolean update(SysClientBo sysClientBo);
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*/
|
||||
boolean updateStatus(Long id, String status);
|
||||
|
||||
/**
|
||||
* 校验并批量删除客户端管理信息
|
||||
*/
|
||||
Boolean deleteByIds(Collection<Long> ids);
|
||||
}
|
||||
|
@ -1,12 +1,27 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.util.UpdateEntity;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
import com.ruoyi.common.orm.core.page.PageQuery;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.bo.SysClientBo;
|
||||
import com.ruoyi.system.domain.vo.SysClientVo;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.service.ISysClientService;
|
||||
import com.ruoyi.system.domain.SysClient;
|
||||
import com.ruoyi.system.mapper.SysClientMapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ruoyi.system.domain.table.SysClientTableDef.SYS_CLIENT;
|
||||
|
||||
/**
|
||||
* 系统授权表 服务层实现。
|
||||
*
|
||||
@ -15,4 +30,89 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
@Service
|
||||
public class SysClientServiceImpl extends ServiceImpl<SysClientMapper, SysClient> implements ISysClientService {
|
||||
|
||||
@Resource
|
||||
private SysClientMapper clientMapper;
|
||||
@Override
|
||||
public QueryWrapper query() {
|
||||
return super.query().from(SYS_CLIENT);
|
||||
}
|
||||
|
||||
private QueryWrapper buildQueryWrapper(SysClientBo bo) {
|
||||
return query()
|
||||
.where(SYS_CLIENT.CLIENT_ID.eq(bo.getClientId()))
|
||||
.and(SYS_CLIENT.CLIENT_KEY.eq(bo.getClientKey()))
|
||||
.and(SYS_CLIENT.CLIENT_SECRET.eq(bo.getClientSecret()))
|
||||
.and(SYS_CLIENT.STATUS.eq(bo.getStatus()))
|
||||
.orderBy(SYS_CLIENT.ID, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysClientVo selectById(Long id) {
|
||||
SysClientVo sysClientVo = this.getOneAs(query().where(SYS_CLIENT.ID.eq(id)), SysClientVo.class);
|
||||
sysClientVo.setGrantTypeList(List.of(sysClientVo.getGrantType().split(",")));
|
||||
return sysClientVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysClient selectByClientId(String clientId) {
|
||||
return this.getOne(query().where(SYS_CLIENT.CLIENT_ID.eq(clientId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysClientVo> selectPage(SysClientBo sysClientBo) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(sysClientBo);
|
||||
Page<SysClientVo> page = this.pageAs(PageQuery.build(), queryWrapper, SysClientVo.class);
|
||||
page.getRecords().forEach(r -> r.setGrantTypeList(List.of(r.getGrantType().split(","))));
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysClientVo> selectList(SysClientBo sysClientBo) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(sysClientBo);
|
||||
List<SysClientVo> list = this.listAs(queryWrapper, SysClientVo.class);
|
||||
list.forEach(r -> r.setGrantTypeList(List.of(r.getGrantType().split(","))));
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增客户端管理
|
||||
*/
|
||||
@Override
|
||||
public Boolean insert(SysClientBo sysClientBo) {
|
||||
SysClient sysClient = MapstructUtils.convert(sysClientBo, SysClient.class);
|
||||
sysClient.setGrantType(String.join(",", sysClientBo.getGrantTypeList()));
|
||||
// 生成clientId
|
||||
String clientKey = sysClientBo.getClientKey();
|
||||
String clientSecret = sysClientBo.getClientSecret();
|
||||
sysClient.setClientId(SecureUtil.md5(clientKey + clientSecret));
|
||||
return this.save(sysClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改客户端管理
|
||||
*/
|
||||
@Override
|
||||
public Boolean update(SysClientBo sysClientBo) {
|
||||
SysClient sysClient = MapstructUtils.convert(sysClientBo, SysClient.class);
|
||||
sysClient.setGrantType(String.join(",", sysClientBo.getGrantTypeList()));
|
||||
return this.updateById(sysClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*/
|
||||
@Override
|
||||
public boolean updateStatus(Long id, String status) {
|
||||
SysClient sysClient = UpdateEntity.of(SysClient.class, id);
|
||||
sysClient.setStatus(status);
|
||||
return clientMapper.update(sysClient) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除客户端管理
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteByIds(Collection<Long> ids) {
|
||||
return this.removeByIds(ids);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user