新增:批量删除菜单功能和复制菜单功能

This commit is contained in:
2024-08-31 22:18:12 +08:00
parent c08faf29fe
commit c6d9577f86
15 changed files with 750 additions and 13 deletions

View File

@@ -71,6 +71,7 @@ public class MybatisPlusConfig {
"sys_order",
"sys_domain",
"sys_white_domain",
"sys_website",
"sys_website_field",
"sys_modules",
"sys_environment",

View File

@@ -33,7 +33,6 @@ public class DictDataController extends BaseController {
@Resource
private DictService dictService;
@PreAuthorize("hasAuthority('sys:dict:list')")
@ApiOperation("分页查询字典数据")
@GetMapping("/page")
public ApiResult<PageResult<DictData>> page(DictDataParam param) {

View File

@@ -27,11 +27,9 @@ public class DictionaryDataController extends BaseController {
@Resource
private DictionaryDataService dictionaryDataService;
@PreAuthorize("hasAuthority('sys:dictionary:list')")
@ApiOperation("分页查询字典数据")
@GetMapping("/page")
public ApiResult<PageResult<DictionaryData>> page(DictionaryDataParam param) {
System.out.println("param = " + param);
return success(dictionaryDataService.pageRel(param));
}

View File

@@ -1,9 +1,13 @@
package com.gxwebsoft.common.system.controller;
import cn.hutool.core.stream.CollectorUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.core.web.*;
import com.gxwebsoft.common.system.entity.Company;
import com.gxwebsoft.common.system.entity.Dict;
import com.gxwebsoft.common.system.entity.Menu;
import com.gxwebsoft.common.system.entity.Version;
import com.gxwebsoft.common.system.param.MenuParam;
@@ -19,6 +23,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 菜单控制器
@@ -141,8 +147,39 @@ public class MenuController extends BaseController {
return fail("删除失败");
}
@PreAuthorize("hasAuthority('sys:menu:remove')")
@ApiOperation("删除父级以下菜单")
@DeleteMapping("/deleteParentMenu/{id}")
public ApiResult<?> deleteParentMenu(@PathVariable("id") Integer id) {
final List<Menu> list = menuService.list(new LambdaQueryWrapper<Menu>().eq(Menu::getParentId, id));
if (CollectionUtils.isEmpty(list)) {
menuService.removeById(id);
return success("删除成功");
}
final Set<Integer> ids = list.stream().map(Menu::getMenuId).collect(Collectors.toSet());
final List<Menu> list2 = menuService.list(new LambdaUpdateWrapper<Menu>().in(Menu::getParentId, ids));
final Set<Integer> collect = list2.stream().map(Menu::getMenuId).collect(Collectors.toSet());
if (!CollectionUtils.isEmpty(list2)) {
ids.addAll(collect);
final List<Menu> list3 = menuService.list(new LambdaUpdateWrapper<Menu>().in(Menu::getParentId, ids));
final Set<Integer> collect1 = list3.stream().map(Menu::getMenuId).collect(Collectors.toSet());
if (!CollectionUtils.isEmpty(collect1)) {
ids.addAll(collect1);
}
ids.add(id);
if (menuService.removeByIds(ids)) {
return success("删除成功");
}
}
ids.add(id);
if (menuService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('sys:menu:update')")
@OperationLog
@ApiOperation("菜单克隆")
@PostMapping("/clone")
public ApiResult<?> onClone(@RequestBody MenuParam param){
@@ -166,7 +203,6 @@ public class MenuController extends BaseController {
}
@PreAuthorize("hasAuthority('sys:menu:update')")
@OperationLog
@ApiOperation("安装插件")
@GetMapping("/install/{id}")
public ApiResult<?> install(@PathVariable("id") Integer id){

View File

@@ -0,0 +1,125 @@
package com.gxwebsoft.common.system.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.system.service.WebsiteService;
import com.gxwebsoft.common.system.entity.Website;
import com.gxwebsoft.common.system.param.WebsiteParam;
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;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 网站信息记录表控制器
*
* @author 科技小王子
* @since 2024-08-30 19:29:10
*/
@Api(tags = "网站信息记录表管理")
@RestController
@RequestMapping("/api/system/website")
public class WebsiteController extends BaseController {
@Resource
private WebsiteService websiteService;
@PreAuthorize("hasAuthority('sys:website:list')")
@ApiOperation("分页查询网站信息记录表")
@GetMapping("/page")
public ApiResult<PageResult<Website>> page(WebsiteParam param) {
// 使用关联查询
return success(websiteService.pageRel(param));
}
@PreAuthorize("hasAuthority('sys:website:list')")
@OperationLog
@ApiOperation("查询全部网站信息记录表")
@GetMapping()
public ApiResult<List<Website>> list(WebsiteParam param) {
// 使用关联查询
return success(websiteService.listRel(param));
}
@PreAuthorize("hasAuthority('sys:website:list')")
@OperationLog
@ApiOperation("根据id查询网站信息记录表")
@GetMapping("/{id}")
public ApiResult<Website> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(websiteService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('sys:website:save')")
@OperationLog
@ApiOperation("添加网站信息记录表")
@PostMapping()
public ApiResult<?> save(@RequestBody Website website) {
if (websiteService.save(website)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('sys:website:update')")
@OperationLog
@ApiOperation("修改网站信息记录表")
@PutMapping()
public ApiResult<?> update(@RequestBody Website website) {
if (websiteService.updateById(website)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:website:remove')")
@OperationLog
@ApiOperation("删除网站信息记录表")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (websiteService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('sys:website:save')")
@OperationLog
@ApiOperation("批量添加网站信息记录表")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<Website> list) {
if (websiteService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('sys:website:update')")
@OperationLog
@ApiOperation("批量修改网站信息记录表")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<Website> batchParam) {
if (batchParam.update(websiteService, "website_id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:website:remove')")
@OperationLog
@ApiOperation("批量删除网站信息记录表")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (websiteService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

View File

@@ -0,0 +1,154 @@
package com.gxwebsoft.common.system.entity;
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;
/**
* 网站信息记录表
*
* @author 科技小王子
* @since 2024-08-30 19:29:10
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "Website对象", description = "网站信息记录表")
@TableName("sys_website")
public class Website implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "站点ID")
@TableId(value = "website_id", type = IdType.AUTO)
private Integer websiteId;
@ApiModelProperty(value = "网站名称")
private String websiteName;
@ApiModelProperty(value = "网站标识")
private String websiteCode;
@ApiModelProperty(value = "网站LOGO")
private String websiteIcon;
@ApiModelProperty(value = "网站LOGO")
private String websiteLogo;
@ApiModelProperty(value = "网站LOGO(深色模式)")
private String websiteDarkLogo;
@ApiModelProperty(value = "网站类型")
private String websiteType;
@ApiModelProperty(value = "网站关键词")
private String keywords;
@ApiModelProperty(value = "域名前缀")
private String prefix;
@ApiModelProperty(value = "绑定域名")
private String domain;
@ApiModelProperty(value = "全局样式")
private String style;
@ApiModelProperty(value = "后台管理地址")
private String adminUrl;
@ApiModelProperty(value = "应用版本 10免费版 20授权版 30永久授权")
private Integer version;
@ApiModelProperty(value = "服务到期时间")
private Date expirationTime;
@ApiModelProperty(value = "模版ID")
private Integer templateId;
@ApiModelProperty(value = "行业类型(父级)")
private String industryParent;
@ApiModelProperty(value = "行业类型(子级)")
private String industryChild;
@ApiModelProperty(value = "企业ID")
private Integer companyId;
@ApiModelProperty(value = "所在国家")
private String country;
@ApiModelProperty(value = "所在省份")
private String province;
@ApiModelProperty(value = "所在城市")
private String city;
@ApiModelProperty(value = "所在辖区")
private String region;
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "街道地址")
private String address;
@ApiModelProperty(value = "联系电话")
private String phone;
@ApiModelProperty(value = "电子邮箱")
private String email;
@ApiModelProperty(value = "ICP备案号")
private String icpNo;
@ApiModelProperty(value = "公安备案")
private String policeNo;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "是否推荐")
private Integer recommend;
@ApiModelProperty(value = "状态 0未开通 1运行中 2维护中 3已关闭 4已欠费停机 5违规关停")
private Integer status;
@ApiModelProperty(value = "维护说明")
private String statusText;
@ApiModelProperty(value = "关闭说明")
private String statusClose;
@ApiModelProperty(value = "全局样式")
private String styles;
@ApiModelProperty(value = "排序号")
private Integer sortNumber;
@ApiModelProperty(value = "用户ID")
private Integer userId;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
}

View File

@@ -0,0 +1,37 @@
package com.gxwebsoft.common.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.common.system.entity.Website;
import com.gxwebsoft.common.system.param.WebsiteParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 网站信息记录表Mapper
*
* @author 科技小王子
* @since 2024-08-30 19:29:10
*/
public interface WebsiteMapper extends BaseMapper<Website> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<Website>
*/
List<Website> selectPageRel(@Param("page") IPage<Website> page,
@Param("param") WebsiteParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<Website> selectListRel(@Param("param") WebsiteParam param);
}

View File

@@ -0,0 +1,146 @@
<?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.gxwebsoft.common.system.mapper.WebsiteMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM sys_website a
<where>
<if test="param.websiteId != null">
AND a.website_id = #{param.websiteId}
</if>
<if test="param.websiteName != null">
AND a.website_name LIKE CONCAT('%', #{param.websiteName}, '%')
</if>
<if test="param.websiteCode != null">
AND a.website_code LIKE CONCAT('%', #{param.websiteCode}, '%')
</if>
<if test="param.websiteIcon != null">
AND a.website_icon LIKE CONCAT('%', #{param.websiteIcon}, '%')
</if>
<if test="param.websiteLogo != null">
AND a.website_logo LIKE CONCAT('%', #{param.websiteLogo}, '%')
</if>
<if test="param.websiteDarkLogo != null">
AND a.website_dark_logo LIKE CONCAT('%', #{param.websiteDarkLogo}, '%')
</if>
<if test="param.websiteType != null">
AND a.website_type LIKE CONCAT('%', #{param.websiteType}, '%')
</if>
<if test="param.keywords != null">
AND a.keywords LIKE CONCAT('%', #{param.keywords}, '%')
</if>
<if test="param.prefix != null">
AND a.prefix LIKE CONCAT('%', #{param.prefix}, '%')
</if>
<if test="param.domain != null">
AND a.domain LIKE CONCAT('%', #{param.domain}, '%')
</if>
<if test="param.style != null">
AND a.style LIKE CONCAT('%', #{param.style}, '%')
</if>
<if test="param.adminUrl != null">
AND a.admin_url LIKE CONCAT('%', #{param.adminUrl}, '%')
</if>
<if test="param.version != null">
AND a.version = #{param.version}
</if>
<if test="param.expirationTime != null">
AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%')
</if>
<if test="param.templateId != null">
AND a.template_id = #{param.templateId}
</if>
<if test="param.industryParent != null">
AND a.industry_parent LIKE CONCAT('%', #{param.industryParent}, '%')
</if>
<if test="param.industryChild != null">
AND a.industry_child LIKE CONCAT('%', #{param.industryChild}, '%')
</if>
<if test="param.companyId != null">
AND a.company_id = #{param.companyId}
</if>
<if test="param.country != null">
AND a.country LIKE CONCAT('%', #{param.country}, '%')
</if>
<if test="param.province != null">
AND a.province LIKE CONCAT('%', #{param.province}, '%')
</if>
<if test="param.city != null">
AND a.city LIKE CONCAT('%', #{param.city}, '%')
</if>
<if test="param.region != null">
AND a.region LIKE CONCAT('%', #{param.region}, '%')
</if>
<if test="param.longitude != null">
AND a.longitude LIKE CONCAT('%', #{param.longitude}, '%')
</if>
<if test="param.latitude != null">
AND a.latitude LIKE CONCAT('%', #{param.latitude}, '%')
</if>
<if test="param.address != null">
AND a.address LIKE CONCAT('%', #{param.address}, '%')
</if>
<if test="param.phone != null">
AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
</if>
<if test="param.email != null">
AND a.email LIKE CONCAT('%', #{param.email}, '%')
</if>
<if test="param.icpNo != null">
AND a.icp_no LIKE CONCAT('%', #{param.icpNo}, '%')
</if>
<if test="param.policeNo != null">
AND a.police_no LIKE CONCAT('%', #{param.policeNo}, '%')
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.recommend != null">
AND a.recommend = #{param.recommend}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.statusText != null">
AND a.status_text LIKE CONCAT('%', #{param.statusText}, '%')
</if>
<if test="param.statusClose != null">
AND a.status_close LIKE CONCAT('%', #{param.statusClose}, '%')
</if>
<if test="param.styles != null">
AND a.styles LIKE CONCAT('%', #{param.styles}, '%')
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</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>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.common.system.entity.Website">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.common.system.entity.Website">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -0,0 +1,148 @@
package com.gxwebsoft.common.system.param;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 网站信息记录表查询参数
*
* @author 科技小王子
* @since 2024-08-30 19:29:10
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "WebsiteParam对象", description = "网站信息记录表查询参数")
public class WebsiteParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "站点ID")
@QueryField(type = QueryType.EQ)
private Integer websiteId;
@ApiModelProperty(value = "网站名称")
private String websiteName;
@ApiModelProperty(value = "网站标识")
private String websiteCode;
@ApiModelProperty(value = "网站LOGO")
private String websiteIcon;
@ApiModelProperty(value = "网站LOGO")
private String websiteLogo;
@ApiModelProperty(value = "网站LOGO(深色模式)")
private String websiteDarkLogo;
@ApiModelProperty(value = "网站类型")
private String websiteType;
@ApiModelProperty(value = "网站关键词")
private String keywords;
@ApiModelProperty(value = "域名前缀")
private String prefix;
@ApiModelProperty(value = "绑定域名")
private String domain;
@ApiModelProperty(value = "全局样式")
private String style;
@ApiModelProperty(value = "后台管理地址")
private String adminUrl;
@ApiModelProperty(value = "应用版本 10免费版 20授权版 30永久授权")
@QueryField(type = QueryType.EQ)
private Integer version;
@ApiModelProperty(value = "服务到期时间")
private String expirationTime;
@ApiModelProperty(value = "模版ID")
@QueryField(type = QueryType.EQ)
private Integer templateId;
@ApiModelProperty(value = "行业类型(父级)")
private String industryParent;
@ApiModelProperty(value = "行业类型(子级)")
private String industryChild;
@ApiModelProperty(value = "企业ID")
@QueryField(type = QueryType.EQ)
private Integer companyId;
@ApiModelProperty(value = "所在国家")
private String country;
@ApiModelProperty(value = "所在省份")
private String province;
@ApiModelProperty(value = "所在城市")
private String city;
@ApiModelProperty(value = "所在辖区")
private String region;
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "街道地址")
private String address;
@ApiModelProperty(value = "联系电话")
private String phone;
@ApiModelProperty(value = "电子邮箱")
private String email;
@ApiModelProperty(value = "ICP备案号")
private String icpNo;
@ApiModelProperty(value = "公安备案")
private String policeNo;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "是否推荐")
@QueryField(type = QueryType.EQ)
private Integer recommend;
@ApiModelProperty(value = "状态 0未开通 1运行中 2维护中 3已关闭 4已欠费停机 5违规关停")
@QueryField(type = QueryType.EQ)
private Integer status;
@ApiModelProperty(value = "维护说明")
private String statusText;
@ApiModelProperty(value = "关闭说明")
private String statusClose;
@ApiModelProperty(value = "全局样式")
private String styles;
@ApiModelProperty(value = "排序号")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@ApiModelProperty(value = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}

View File

@@ -0,0 +1,42 @@
package com.gxwebsoft.common.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Website;
import com.gxwebsoft.common.system.param.WebsiteParam;
import java.util.List;
/**
* 网站信息记录表Service
*
* @author 科技小王子
* @since 2024-08-30 19:29:10
*/
public interface WebsiteService extends IService<Website> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<Website>
*/
PageResult<Website> pageRel(WebsiteParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<Website>
*/
List<Website> listRel(WebsiteParam param);
/**
* 根据id查询
*
* @param websiteId 站点ID
* @return Website
*/
Website getByIdRel(Integer websiteId);
}

View File

@@ -1,5 +1,6 @@
package com.gxwebsoft.common.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.utils.CommonUtil;
@@ -39,8 +40,13 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
@Transactional(rollbackFor = {Exception.class}, isolation = Isolation.SERIALIZABLE)
public Boolean cloneMenu(MenuParam param) {
System.out.println("准备待克隆的菜单数据 = " + param);
LambdaQueryWrapper<Menu> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Menu::getDeleted,0);
if(ObjectUtil.isNotEmpty(param.getMenuId())) {
wrapper.eq(Menu::getMenuId,param.getMenuId());
}
// 删除本项目菜单
baseMapper.delete(new LambdaQueryWrapper<Menu>().eq(Menu::getDeleted,0));
baseMapper.delete(wrapper);
// 顶级栏目
param.setParentId(0);
// 工单系统

View File

@@ -0,0 +1,47 @@
package com.gxwebsoft.common.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.WebsiteMapper;
import com.gxwebsoft.common.system.service.WebsiteService;
import com.gxwebsoft.common.system.entity.Website;
import com.gxwebsoft.common.system.param.WebsiteParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 网站信息记录表Service实现
*
* @author 科技小王子
* @since 2024-08-30 19:29:10
*/
@Service
public class WebsiteServiceImpl extends ServiceImpl<WebsiteMapper, Website> implements WebsiteService {
@Override
public PageResult<Website> pageRel(WebsiteParam param) {
PageParam<Website, WebsiteParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
List<Website> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<Website> listRel(WebsiteParam param) {
List<Website> list = baseMapper.selectListRel(param);
// 排序
PageParam<Website, WebsiteParam> page = new PageParam<>();
page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}
@Override
public Website getByIdRel(Integer websiteId) {
WebsiteParam param = new WebsiteParam();
param.setWebsiteId(websiteId);
return param.getOne(baseMapper.selectListRel(param));
}
}

View File

@@ -47,8 +47,9 @@ public class SysGenerator {
private static final String MODULE_NAME = "common.system";
// 需要生成的表
private static final String[] TABLE_NAMES = new String[]{
"sys_website"
// "sys_website_field"
"sys_domain"
// "sys_domain"
};
// 需要去除的表前缀
private static final String[] TABLE_PREFIX = new String[]{

View File

@@ -77,11 +77,8 @@ public class ${table.controllerName} {
<% } %>
@GetMapping("/page")
public ApiResult<PageResult<${entity}>> page(${entity}Param param) {
PageParam<${entity}, ${entity}Param> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
return success(${serviceIns}.page(page, page.getWrapper()));
// 使用关联查询
//return success(${serviceIns}.pageRel(param));
return success(${serviceIns}.pageRel(param));
}
<% if(!swagger2) { %>

View File

@@ -37,7 +37,7 @@ public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.m
@Override
public PageResult<${entity}> pageRel(${entity}Param param) {
PageParam<${entity}, ${entity}Param> page = new PageParam<>(param);
//page.setDefaultOrder("create_time desc");
page.setDefaultOrder("create_time desc");
List<${entity}> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@@ -47,7 +47,7 @@ public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.m
List<${entity}> list = baseMapper.selectListRel(param);
// 排序
PageParam<${entity}, ${entity}Param> page = new PageParam<>();
//page.setDefaultOrder("create_time desc");
page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}