优化核心框架

This commit is contained in:
gxwebsoft
2023-10-12 15:32:24 +08:00
parent a5f930dc33
commit 2280c4211d
23 changed files with 121 additions and 368 deletions

View File

@@ -56,7 +56,8 @@ public class MybatisPlusConfig {
"sys_tenant",
"sys_dictionary",
"sys_dictionary_data",
"sys_email_record"
"sys_email_record",
"sys_plug"
).contains(tableName);
}
};

View File

@@ -33,7 +33,6 @@ public class CacheClient {
* 写入redis缓存
* @param key [表名]:id
* @param entity 实体类对象
* 示例 cacheClient.set("merchant:"+id,merchant)
*/
public <T> void set(String key, T entity){
stringRedisTemplate.opsForValue().set(prefix(key), JSONUtil.toJSONString(entity));

View File

@@ -20,7 +20,6 @@ import com.gxwebsoft.common.core.security.JwtSubject;
import com.gxwebsoft.common.core.security.JwtUtil;
import com.gxwebsoft.common.core.utils.CacheClient;
import com.gxwebsoft.common.core.utils.CommonUtil;
import com.gxwebsoft.common.core.utils.JSONUtil;
import com.gxwebsoft.common.core.utils.RedisUtil;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
@@ -33,7 +32,6 @@ import com.gxwebsoft.common.system.result.CaptchaResult;
import com.gxwebsoft.common.system.result.LoginResult;
import com.gxwebsoft.common.system.service.*;
import com.wf.captcha.SpecCaptcha;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;

View File

@@ -146,9 +146,9 @@ public class MenuController extends BaseController {
public ApiResult<?> install(@PathVariable("id") Integer id){
if(menuService.install(id)){
// 更新安装次数
final Plug plug = plugService.getOne(new LambdaQueryWrapper<Plug>().eq(Plug::getMenuId, id));
plug.setInstalls(plug.getInstalls() + 1);
plugService.updateById(plug);
// final Plug plug = plugService.getOne(new LambdaQueryWrapper<Plug>().eq(Plug::getMenuId, id));
// plug.setInstalls(plug.getInstalls() + 1);
// plugService.updateById(plug);
return success("安装成功");
}
return fail("安装失败",id);

View File

@@ -1,17 +1,15 @@
package com.gxwebsoft.common.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Menu;
import com.gxwebsoft.common.system.entity.Plug;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.param.PlugParam;
import com.gxwebsoft.common.system.service.MenuService;
import com.gxwebsoft.common.system.service.PlugService;
import com.gxwebsoft.common.system.entity.Plug;
import com.gxwebsoft.common.system.param.PlugParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -24,7 +22,7 @@ import java.util.List;
* 插件扩展控制器
*
* @author 科技小王子
* @since 2023-05-18 11:57:37
* @since 2023-10-12 09:53:07
*/
@Api(tags = "插件扩展管理")
@RestController
@@ -32,20 +30,17 @@ import java.util.List;
public class PlugController extends BaseController {
@Resource
private PlugService plugService;
@Resource
private MenuService menuService;
@PreAuthorize("hasAuthority('sys:plug:list')")
@OperationLog
@ApiOperation("分页查询插件扩展")
@GetMapping("/page")
public ApiResult<PageResult<Plug>> page(PlugParam param) {
// 如果不传userId只显示审核通过的插件
if (param.getUserId() == null) {
param.setStatus(20);
}
PageParam<Plug, PlugParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
return success(plugService.page(page, page.getWrapper()));
// 使用关联查询
return success(plugService.pageRel(param));
//return success(plugService.pageRel(param));
}
@PreAuthorize("hasAuthority('sys:plug:list')")
@@ -53,8 +48,11 @@ public class PlugController extends BaseController {
@ApiOperation("查询全部插件扩展")
@GetMapping()
public ApiResult<List<Plug>> list(PlugParam param) {
PageParam<Plug, PlugParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
return success(plugService.list(page.getOrderWrapper()));
// 使用关联查询
return success(plugService.listRel(param));
//return success(plugService.listRel(param));
}
@PreAuthorize("hasAuthority('sys:plug:list')")
@@ -62,8 +60,9 @@ public class PlugController extends BaseController {
@ApiOperation("根据id查询插件扩展")
@GetMapping("/{id}")
public ApiResult<Plug> get(@PathVariable("id") Integer id) {
return success(plugService.getById(id));
// 使用关联查询
return success(plugService.getByIdRel(id));
//return success(plugService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('sys:plug:save')")
@@ -120,7 +119,7 @@ public class PlugController extends BaseController {
@ApiOperation("批量修改插件扩展")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<Plug> batchParam) {
if (batchParam.update(plugService, "menu_id")) {
if (batchParam.update(plugService, "plug_id")) {
return success("修改成功");
}
return fail("修改失败");
@@ -137,35 +136,4 @@ public class PlugController extends BaseController {
return fail("删除失败");
}
@PreAuthorize("hasAuthority('sys:plug:save')")
@OperationLog
@ApiOperation("发布插件")
@PostMapping("/plug")
public ApiResult<?> plug(@RequestBody Plug plug){
final Integer menuId = plug.getParentId();
// 查重
final int count = plugService.count(new LambdaQueryWrapper<Plug>().eq(Plug::getMenuId, menuId));
if(count > 0){
return fail("请勿重复发布");
}
// 准备数据
final Menu menu = menuService.getById(menuId);
plug.setUserId(getLoginUserId());
plug.setMenuId(menuId);
plug.setTenantId(getTenantId());
plug.setIcon(menu.getIcon());
plug.setPath(menu.getPath());
plug.setComponent(menu.getComponent());
plug.setAuthority(menu.getAuthority());
plug.setTitle(menu.getTitle());
plug.setMenuType(menu.getMenuType());
plug.setMeta(menu.getMeta());
plug.setParentId(menu.getParentId());
plug.setHide(menu.getHide());
plug.setSortNumber(menu.getSortNumber());
if(plugService.save(plug)){
return success("发布成功");
}
return fail("发布失败");
}
}

View File

@@ -49,9 +49,6 @@ public class FileRecord implements Serializable {
@TableLogic
private Integer deleted;
@ApiModelProperty("商户编号")
private String merchantCode;
@ApiModelProperty(value = "租户id")
private Integer tenantId;

View File

@@ -1,21 +1,24 @@
package com.gxwebsoft.common.system.entity;
import com.baomidou.mybatisplus.annotation.*;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 插件扩展
*
* @author 科技小王子
* @since 2023-05-18 11:57:37
* @since 2023-10-12 09:53:07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@@ -23,89 +26,51 @@ import java.util.List;
@TableName("sys_plug")
public class Plug implements Serializable {
private static final long serialVersionUID = 1L;
public static final int TYPE_MENU = 0; // 菜单类型
public static final int TYPE_BTN = 1; // 按钮类型
@ApiModelProperty(value = "插件id")
@TableId(value = "plug_id", type = IdType.AUTO)
private Integer plugId;
@ApiModelProperty(value = "菜单ID")
private Integer menuId;
@ApiModelProperty(value = "上级id, 0是顶级")
private Integer parentId;
@ApiModelProperty(value = "菜单名称")
private String title;
private String plugName;
@ApiModelProperty(value = "菜单路由地址")
private String path;
@ApiModelProperty(value = "插件ID")
private String plugCode;
@ApiModelProperty(value = "菜单组件地址, 目录可为空")
private String component;
@ApiModelProperty(value = "类型, 0菜单, 1按钮")
private Integer menuType;
@ApiModelProperty(value = "插件类型 10后台模块")
private Integer plugType;
@ApiModelProperty(value = "排序号")
private Integer sortNumber;
@ApiModelProperty(value = "权限标识")
private String authority;
@ApiModelProperty(value = "插件价格")
private BigDecimal price;
@ApiModelProperty(value = "打开位置")
private String target;
@ApiModelProperty(value = "评分")
private BigDecimal score;
@ApiModelProperty(value = "菜单图标")
private String icon;
@ApiModelProperty(value = "下载次数")
private Integer clicks;
@ApiModelProperty(value = "图标颜色")
private String color;
@ApiModelProperty(value = "安装次数")
private Integer installs;
@ApiModelProperty(value = "是否隐藏, 0否, 1是(仅注册路由不显示在左侧菜单)")
private Integer hide;
@ApiModelProperty(value = "菜单侧栏选中的path")
private String active;
@ApiModelProperty(value = "其它路由元信息")
private String meta;
@ApiModelProperty(value = "插件描述")
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "插件详情")
private String content;
@ApiModelProperty("评分")
private BigDecimal score;
@ApiModelProperty("插件价格")
private BigDecimal price;
@ApiModelProperty("浏览次数")
private Integer clicks;
@ApiModelProperty("安装次数")
private Integer installs;
@ApiModelProperty(value = "关联应用ID")
private Integer appId;
@ApiModelProperty(value = "状态, 10待审核 20已通过 30已驳回")
private Integer status;
@ApiModelProperty(value = "用户ID")
private Integer userId;
@ApiModelProperty(value = "状态")
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "商户编码")
private String merchantCode;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@@ -115,27 +80,4 @@ public class Plug implements Serializable {
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty("子菜单")
@TableField(exist = false)
private List<Menu> children;
@ApiModelProperty("角色权限树选中状态")
@TableField(exist = false)
private Boolean checked;
@ApiModelProperty("租户名称")
@TableField(exist = false)
private String tenantName;
@ApiModelProperty("企业名称")
@TableField(exist = false)
private String companyName;
@ApiModelProperty("企业简称")
@TableField(exist = false)
private String shortName;
@ApiModelProperty("企业域名")
@TableField(exist = false)
private String domain;
}

View File

@@ -236,14 +236,6 @@ public class User implements UserDetails {
@TableField(exist = false)
private String unionid;
@ApiModelProperty("所属商户的编号")
@TableField(exist = false)
private String merchantCode;
@ApiModelProperty("所属商户名称")
@TableField(exist = false)
private String merchantName;
@ApiModelProperty("ico文件")
@TableField(exist = false)
private String logo;

View File

@@ -58,9 +58,6 @@ public class UserGrade implements Serializable {
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "商户编码")
private String merchantCode;
@ApiModelProperty(value = "租户id")
private Integer tenantId;

View File

@@ -55,9 +55,6 @@ public class UserOauth implements Serializable {
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "商户编码")
private String merchantCode;
@ApiModelProperty(value = "租户id")
private Integer tenantId;

View File

@@ -1,6 +1,5 @@
package com.gxwebsoft.common.system.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.common.system.entity.Plug;
@@ -13,7 +12,7 @@ import java.util.List;
* 插件扩展Mapper
*
* @author 科技小王子
* @since 2023-05-18 11:57:37
* @since 2023-10-12 09:53:07
*/
public interface PlugMapper extends BaseMapper<Plug> {
@@ -24,7 +23,6 @@ public interface PlugMapper extends BaseMapper<Plug> {
* @param param 查询参数
* @return List<Plug>
*/
@InterceptorIgnore(tenantLine = "true")
List<Plug> selectPageRel(@Param("page") IPage<Plug> page,
@Param("param") PlugParam param);
@@ -36,7 +34,4 @@ public interface PlugMapper extends BaseMapper<Plug> {
*/
List<Plug> selectListRel(@Param("param") PlugParam param);
@InterceptorIgnore(tenantLine = "true")
List<Plug> getMenuByClone(@Param("param") PlugParam param);
}

View File

@@ -7,11 +7,9 @@
SELECT a.*,
b.username create_username,
b.nickname create_nickname,
b.avatar,
c.merchant_code
b.avatar
FROM sys_file_record a
LEFT JOIN sys_user b ON a.create_user_id = b.user_id
LEFT JOIN shop_merchant c ON a.merchant_code = c.merchant_code
<where>
<if test="param.id != null">
AND a.id = #{param.id}
@@ -52,9 +50,6 @@
<if test="param.contentType != null">
AND a.content_type LIKE CONCAT('%', #{param.contentType}, '%')
</if>
<if test="param.merchantCode != null">
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
</if>
</where>
</sql>

View File

@@ -4,64 +4,47 @@
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*,b.tenant_name,c.company_name,c.short_name,c.domain
SELECT a.*
FROM sys_plug a
LEFT JOIN sys_tenant b ON a.tenant_id = b.tenant_id
LEFT JOIN sys_company c ON a.tenant_id = c.tenant_id
<where>
<if test="param.plugId != null">
AND a.plug_id = #{param.plugId}
AND a.plug_id = #{param.plugId}
</if>
<if test="param.menuId != null">
AND a.menu_id = #{param.menuId}
<if test="param.plugName != null">
AND a.plug_name LIKE CONCAT('%', #{param.plugName}, '%')
</if>
<if test="param.parentId != null">
AND a.parent_id = #{param.parentId}
<if test="param.plugCode != null">
AND a.plug_code LIKE CONCAT('%', #{param.plugCode}, '%')
</if>
<if test="param.title != null">
AND a.title LIKE CONCAT('%', #{param.title}, '%')
</if>
<if test="param.path != null">
AND a.path LIKE CONCAT('%', #{param.path}, '%')
</if>
<if test="param.component != null">
AND a.component LIKE CONCAT('%', #{param.component}, '%')
</if>
<if test="param.menuType != null">
AND a.menu_type = #{param.menuType}
<if test="param.plugType != null">
AND a.plug_type = #{param.plugType}
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.authority != null">
AND a.authority LIKE CONCAT('%', #{param.authority}, '%')
<if test="param.price != null">
AND a.price = #{param.price}
</if>
<if test="param.target != null">
AND a.target LIKE CONCAT('%', #{param.target}, '%')
<if test="param.score != null">
AND a.score = #{param.score}
</if>
<if test="param.icon != null">
AND a.icon LIKE CONCAT('%', #{param.icon}, '%')
<if test="param.clicks != null">
AND a.clicks = #{param.clicks}
</if>
<if test="param.color != null">
AND a.color LIKE CONCAT('%', #{param.color}, '%')
<if test="param.installs != null">
AND a.installs = #{param.installs}
</if>
<if test="param.hide != null">
AND a.hide = #{param.hide}
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.active != null">
AND a.active LIKE CONCAT('%', #{param.active}, '%')
</if>
<if test="param.meta != null">
AND a.meta LIKE CONCAT('%', #{param.meta}, '%')
</if>
<if test="param.appId != null">
AND a.app_id = #{param.appId}
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if>
<if test="param.status != null">
AND a.status = #{param.status}
AND a.status = #{param.status}
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
@@ -69,22 +52,12 @@
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.merchantCode != null">
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.title LIKE CONCAT('%', #{param.keywords}, '%')
OR a.menu_id = #{param.keywords}
OR c.company_name LIKE CONCAT('%', #{param.keywords}, '%')
OR c.short_name LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
@@ -98,8 +71,4 @@
<include refid="selectSql"></include>
</select>
<select id="getMenuByClone" resultType="com.gxwebsoft.common.system.entity.Plug">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -40,9 +40,6 @@
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.merchantCode != null">
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>

View File

@@ -37,9 +37,6 @@
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.merchantCode != null">
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>

View File

@@ -64,7 +64,4 @@ public class FileRecordParam extends BaseParam {
@TableField(exist = false)
private String avatar;
@ApiModelProperty("商户编号")
private String merchantCode;
}

View File

@@ -9,11 +9,13 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 插件扩展查询参数
*
* @author 科技小王子
* @since 2023-05-18 11:57:37
* @since 2023-10-12 09:53:07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@@ -26,58 +28,43 @@ public class PlugParam extends BaseParam {
@QueryField(type = QueryType.EQ)
private Integer plugId;
@ApiModelProperty(value = "菜单id")
@QueryField(type = QueryType.EQ)
private Integer menuId;
@ApiModelProperty(value = "上级id, 0是顶级")
@QueryField(type = QueryType.EQ)
private Integer parentId;
@ApiModelProperty(value = "菜单名称")
private String title;
private String plugName;
@ApiModelProperty(value = "菜单路由地址")
private String path;
@ApiModelProperty(value = "插件ID")
private String plugCode;
@ApiModelProperty(value = "菜单组件地址, 目录可为空")
private String component;
@ApiModelProperty(value = "类型, 0菜单, 1按钮")
@ApiModelProperty(value = "插件类型 10后台模块")
@QueryField(type = QueryType.EQ)
private Integer menuType;
private Integer plugType;
@ApiModelProperty(value = "排序号")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@ApiModelProperty(value = "权限标识")
private String authority;
@ApiModelProperty(value = "打开位置")
private String target;
@ApiModelProperty(value = "菜单图标")
private String icon;
@ApiModelProperty(value = "图标颜色")
private String color;
@ApiModelProperty(value = "是否隐藏, 0否, 1是(仅注册路由不显示在左侧菜单)")
@ApiModelProperty(value = "插件价格")
@QueryField(type = QueryType.EQ)
private Integer hide;
private BigDecimal price;
@ApiModelProperty(value = "菜单侧栏选中的path")
private String active;
@ApiModelProperty(value = "其它路由元信息")
private String meta;
@ApiModelProperty(value = "关联应用ID")
@ApiModelProperty(value = "评分")
@QueryField(type = QueryType.EQ)
private Integer appId;
private BigDecimal score;
@ApiModelProperty(value = "状态")
@ApiModelProperty(value = "下载次数")
@QueryField(type = QueryType.EQ)
private Integer clicks;
@ApiModelProperty(value = "安装次数")
@QueryField(type = QueryType.EQ)
private Integer installs;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "插件详情")
private String content;
@ApiModelProperty(value = "状态, 10待审核 20已通过 30已驳回")
@QueryField(type = QueryType.EQ)
private Integer status;
@@ -89,7 +76,4 @@ public class PlugParam extends BaseParam {
@QueryField(type = QueryType.EQ)
private Integer deleted;
@ApiModelProperty(value = "商户编码")
private String merchantCode;
}

View File

@@ -57,7 +57,4 @@ public class UserGradeParam extends BaseParam {
@QueryField(type = QueryType.EQ)
private Integer deleted;
@ApiModelProperty(value = "商户编码")
private String merchantCode;
}

View File

@@ -54,7 +54,4 @@ public class UserOauthParam extends BaseParam {
@QueryField(type = QueryType.EQ)
private Integer deleted;
@ApiModelProperty(value = "商户编码")
private String merchantCode;
}

View File

@@ -11,7 +11,7 @@ import java.util.List;
* 插件扩展Service
*
* @author 科技小王子
* @since 2023-05-18 11:57:37
* @since 2023-10-12 09:53:07
*/
public interface PlugService extends IService<Plug> {
@@ -34,11 +34,9 @@ public interface PlugService extends IService<Plug> {
/**
* 根据id查询
*
* @param menuId 菜单id
* @param plugId 插件id
* @return Plug
*/
Plug getByIdRel(Integer menuId);
Boolean cloneMenu(PlugParam param);
Plug getByIdRel(Integer plugId);
}

View File

@@ -1,16 +1,13 @@
package com.gxwebsoft.common.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.PlugMapper;
import com.gxwebsoft.common.system.service.PlugService;
import com.gxwebsoft.common.system.entity.Plug;
import com.gxwebsoft.common.system.param.PlugParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Plug;
import com.gxwebsoft.common.system.mapper.PlugMapper;
import com.gxwebsoft.common.system.param.PlugParam;
import com.gxwebsoft.common.system.service.PlugService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -18,7 +15,7 @@ import java.util.List;
* 插件扩展Service实现
*
* @author 科技小王子
* @since 2023-05-18 11:57:37
* @since 2023-10-12 09:53:07
*/
@Service
public class PlugServiceImpl extends ServiceImpl<PlugMapper, Plug> implements PlugService {
@@ -26,7 +23,7 @@ public class PlugServiceImpl extends ServiceImpl<PlugMapper, Plug> implements Pl
@Override
public PageResult<Plug> pageRel(PlugParam param) {
PageParam<Plug, PlugParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
//page.setDefaultOrder("create_time desc");
List<Plug> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@@ -36,77 +33,15 @@ public class PlugServiceImpl extends ServiceImpl<PlugMapper, Plug> implements Pl
List<Plug> list = baseMapper.selectListRel(param);
// 排序
PageParam<Plug, PlugParam> page = new PageParam<>();
page.setDefaultOrder("create_time desc");
//page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}
@Override
public Plug getByIdRel(Integer menuId) {
public Plug getByIdRel(Integer plugId) {
PlugParam param = new PlugParam();
param.setMenuId(menuId);
param.setPlugId(plugId);
return param.getOne(baseMapper.selectListRel(param));
}
@Override
@Transactional(rollbackFor = {Exception.class}, isolation = Isolation.SERIALIZABLE)
public Boolean cloneMenu(PlugParam param) {
System.out.println("准备待克隆的菜单数据 = " + param);
// 删除本项目菜单
baseMapper.delete(new LambdaQueryWrapper<Plug>().eq(Plug::getDeleted,0));
// 顶级栏目
param.setParentId(0);
final List<Plug> list = baseMapper.getMenuByClone(param);
// final List<Integer> menuIds = list.stream().map(Menu::getMenuId).collect(Collectors.toList());
list.forEach(d -> {
Plug plug = new Plug();
plug.setParentId(0);
plug.setTitle(d.getTitle());
plug.setPath(d.getPath());
plug.setComponent(d.getComponent());
plug.setMenuType(d.getMenuType());
plug.setSortNumber(d.getSortNumber());
plug.setAuthority(d.getAuthority());
plug.setIcon(d.getIcon());
plug.setHide(d.getHide());
plug.setMeta(d.getMeta());
save(plug);
// 二级菜单
param.setParentId(d.getMenuId());
final List<Plug> list1 = baseMapper.getMenuByClone(param);
list1.forEach(d1 -> {
final Plug menu1 = new Plug();
menu1.setParentId(plug.getMenuId());
menu1.setTitle(d1.getTitle());
menu1.setPath(d1.getPath());
menu1.setComponent(d1.getComponent());
menu1.setMenuType(d1.getMenuType());
menu1.setSortNumber(d1.getSortNumber());
menu1.setAuthority(d1.getAuthority());
menu1.setIcon(d1.getIcon());
menu1.setHide(d1.getHide());
menu1.setMeta(d1.getMeta());
save(menu1);
// 三级菜单
param.setParentId(d1.getMenuId());
final List<Plug> list2 = baseMapper.getMenuByClone(param);
list2.forEach(d2 -> {
final Plug menu2 = new Plug();
menu2.setParentId(menu1.getMenuId());
menu2.setTitle(d2.getTitle());
menu2.setPath(d2.getPath());
menu2.setComponent(d2.getComponent());
menu2.setMenuType(d2.getMenuType());
menu2.setSortNumber(d2.getSortNumber());
menu2.setAuthority(d2.getAuthority());
menu2.setIcon(d2.getIcon());
menu2.setHide(d2.getHide());
menu2.setMeta(d2.getMeta());
save(menu2);
});
});
});
return true;
}
}

View File

@@ -3,16 +3,16 @@
# 数据源配置
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3308/com_gxwebsoft_oa?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: com_gxwebsoft_oa
password: EZfW2R4YiWfbLHLw
url: jdbc:mysql://127.0.0.1:3308/gxwebsoft_core?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: gxwebsoft_core
password: jdj7HYEdYHnYEFBy
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
# 日志配置
logging:
file:
name: websoft-api.log
name: websoft-core.log
level:
root: WARN
com.gxwebsoft: ERROR

View File

@@ -53,7 +53,8 @@ public class SysGenerator {
// "sys_user_oauth"
// "sys_user_grade"
// "sys_user_referee"
"sys_notice"
// "sys_notice"
"sys_plug"
};
// 需要去除的表前缀