提交
This commit is contained in:
57
ruoyi-base-support/ruoyi-biz/pom.xml
Normal file
57
ruoyi-base-support/ruoyi-biz/pom.xml
Normal file
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-base-support</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.7.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-biz</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>13</maven.compiler.source>
|
||||
<maven.compiler.target>13</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- spring-boot-devtools -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||
</dependency>
|
||||
|
||||
<!-- swagger3-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql驱动包 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
</dependency>
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.ruoyi.web.demo.expandtable.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.web.demo.expandtable.entity.ExpandTable;
|
||||
import com.ruoyi.web.demo.expandtable.service.IExpandTableService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数配置 信息操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/demo/expandTable")
|
||||
public class ExpandTableController extends BaseController {
|
||||
@Autowired
|
||||
private IExpandTableService expandTableService;
|
||||
|
||||
/**
|
||||
* 获取参数配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:expandTable:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(HttpServletRequest request) {
|
||||
//加入条件
|
||||
QueryWrapper<ExpandTable> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
|
||||
String title = request.getParameter("name");
|
||||
if (!StringUtils.isEmpty(title)) {
|
||||
queryWrapper.like("title", title);
|
||||
}
|
||||
|
||||
Page<ExpandTable> page = expandTableService.page(getPage(), queryWrapper);
|
||||
return getDataTable(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出展开表格列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:expandTable:export')")
|
||||
@Log(title = "展开表格", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(HttpServletRequest request) {
|
||||
//加入条件
|
||||
QueryWrapper<ExpandTable> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
|
||||
String title = request.getParameter("title");
|
||||
if (!StringUtils.isEmpty(title)) {
|
||||
queryWrapper.eq("title", title);
|
||||
}
|
||||
String level = request.getParameter("level");
|
||||
if (!StringUtils.isEmpty(title)) {
|
||||
queryWrapper.eq("level", level);
|
||||
}
|
||||
String type = request.getParameter("type");
|
||||
if (!StringUtils.isEmpty(type)) {
|
||||
queryWrapper.eq("type", type);
|
||||
}
|
||||
|
||||
List<ExpandTable> list = expandTableService.list(queryWrapper);
|
||||
ExcelUtil<ExpandTable> util = new ExcelUtil<>(ExpandTable.class);
|
||||
return util.exportExcel(list, "展开表格数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取展开表格详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:expandTable:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(expandTableService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增展开表格
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:expandTable:add')")
|
||||
@Log(title = "展开表格", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ExpandTable expandTable) {
|
||||
return toAjax(expandTableService.save(expandTable));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改展开表格
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:expandTable:edit')")
|
||||
@Log(title = "展开表格", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ExpandTable expandTable) {
|
||||
return toAjax(expandTableService.updateById(expandTable));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除展开表格
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:expandTable:remove')")
|
||||
@Log(title = "展开表格", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] infoIds) {
|
||||
return toAjax(expandTableService.removeByIds(Arrays.asList(infoIds)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.ruoyi.web.demo.expandtable.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.expandtable
|
||||
* @title: 商品信息控制器
|
||||
* @description: 商品信息控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 15:02:00
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("demo_expand_table")
|
||||
@SuppressWarnings("serial")
|
||||
public class ExpandTable extends BaseEntity {
|
||||
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private String id; //id
|
||||
@TableField(value = "name")
|
||||
private String name; //商品名称
|
||||
@TableField(value = "shop")
|
||||
private String shop; //所属店铺
|
||||
@TableField(value = "category")
|
||||
private String category; //商品分类
|
||||
@TableField(value = "address")
|
||||
private String address; //店铺地址
|
||||
@TableField(value = "description")
|
||||
private String description; //商品描述
|
||||
@TableField(value = "tag")
|
||||
private String tag; //标签
|
||||
@TableField(value = "image")
|
||||
private String image; //图片
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.web.demo.expandtable.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.web.demo.expandtable.entity.ExpandTable;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.expandtable
|
||||
* @title: 商品信息控制器
|
||||
* @description: 商品信息控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 15:02:01
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExpandTableMapper extends BaseMapper<ExpandTable> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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.ruoyi.web.demo.expandtable.mapper.ExpandTableMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
a.id,
|
||||
a.name,
|
||||
a.shop,
|
||||
a.category,
|
||||
a.address,
|
||||
a.description,
|
||||
a.tag,
|
||||
a.create_time,
|
||||
a.update_by,
|
||||
a.update_date,
|
||||
a.remarks,
|
||||
a.del_flag,
|
||||
a.create_by
|
||||
</sql>
|
||||
<sql id="tableJoins">
|
||||
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ruoyi.web.demo.expandtable.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.web.demo.expandtable.entity.ExpandTable;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.expandtable
|
||||
* @title: 商品信息控制器
|
||||
* @description: 商品信息控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 15:02:02
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
public interface IExpandTableService extends IService<ExpandTable> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.web.demo.expandtable.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.web.demo.expandtable.entity.ExpandTable;
|
||||
import com.ruoyi.web.demo.expandtable.mapper.ExpandTableMapper;
|
||||
import com.ruoyi.web.demo.expandtable.service.IExpandTableService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.expandtable
|
||||
* @title: 商品信息控制器
|
||||
* @description: 商品信息控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 15:02:03
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
@Transactional
|
||||
@Service("expandTableService")
|
||||
public class ExpandTableServiceImpl extends ServiceImpl<ExpandTableMapper, ExpandTable> implements IExpandTableService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.ruoyi.web.demo.table.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.web.demo.table.entity.Table;
|
||||
import com.ruoyi.web.demo.table.service.ITableService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数配置 信息操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/demo/table")
|
||||
public class TableController extends BaseController {
|
||||
@Autowired
|
||||
private ITableService tableService;
|
||||
|
||||
/**
|
||||
* 获取参数配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:table:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(HttpServletRequest request) {
|
||||
//加入条件
|
||||
QueryWrapper<Table> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
|
||||
String title = request.getParameter("title");
|
||||
if (!StringUtils.isEmpty(title)) {
|
||||
queryWrapper.eq("title", title);
|
||||
}
|
||||
String level = request.getParameter("level");
|
||||
if (!StringUtils.isEmpty(title)) {
|
||||
queryWrapper.eq("level", level);
|
||||
}
|
||||
String type = request.getParameter("type");
|
||||
if (!StringUtils.isEmpty(type)) {
|
||||
queryWrapper.eq("type", type);
|
||||
}
|
||||
|
||||
Page<Table> page = tableService.page(getPage(), queryWrapper);
|
||||
return getDataTable(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出综合表格列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:table:export')")
|
||||
@Log(title = "综合表格", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(HttpServletRequest request) {
|
||||
//加入条件
|
||||
QueryWrapper<Table> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
|
||||
String title = request.getParameter("title");
|
||||
if (!StringUtils.isEmpty(title)) {
|
||||
queryWrapper.eq("title", title);
|
||||
}
|
||||
String level = request.getParameter("level");
|
||||
if (!StringUtils.isEmpty(title)) {
|
||||
queryWrapper.eq("level", level);
|
||||
}
|
||||
String type = request.getParameter("type");
|
||||
if (!StringUtils.isEmpty(type)) {
|
||||
queryWrapper.eq("type", type);
|
||||
}
|
||||
|
||||
List<Table> list = tableService.list(queryWrapper);
|
||||
ExcelUtil<Table> util = new ExcelUtil<>(Table.class);
|
||||
return util.exportExcel(list, "综合表格数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取综合表格详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:table:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(tableService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增综合表格
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:table:add')")
|
||||
@Log(title = "综合表格", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Table table) {
|
||||
return toAjax(tableService.save(table));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改综合表格
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:table:edit')")
|
||||
@Log(title = "综合表格", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Table table) {
|
||||
return toAjax(tableService.updateById(table));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除综合表格
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:table:remove')")
|
||||
@Log(title = "综合表格", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] infoIds) {
|
||||
return toAjax(tableService.removeByIds(Arrays.asList(infoIds)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.ruoyi.web.demo.table.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package com.sunseagear.bbs.modules.sys.entity
|
||||
* @title: 操作日志实体
|
||||
* @description: 操作日志实体 * @date: 2018-09-30 15:53:25
|
||||
* @copyright: 2018 www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("demo_table")
|
||||
@SuppressWarnings("serial")
|
||||
public class Table extends BaseEntity {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id; //id
|
||||
|
||||
@TableField(value = "title")
|
||||
private String title; //标题
|
||||
|
||||
@TableField(value = "content")
|
||||
private String content; //内容
|
||||
|
||||
@TableField(value = "author")
|
||||
private String author; //作者
|
||||
|
||||
@TableField(value = "type")
|
||||
private String type; //类型
|
||||
|
||||
@TableField(value = "status")
|
||||
private String status; //状态
|
||||
|
||||
@TableField(value = "level")
|
||||
private Integer level; //重要程度
|
||||
|
||||
@TableField(value = "tag")
|
||||
private String tag; //标签
|
||||
|
||||
@TableField(value = "readings")
|
||||
private Integer readings; //阅读数
|
||||
|
||||
@TableField(value = "publish_date")
|
||||
private Date publishDate; //发布时间
|
||||
|
||||
@TableField(exist = false)
|
||||
private SysUser user; //发布时间
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ruoyi.web.demo.table.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.web.demo.table.entity.Table;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package com.sunseagear.wind.modules.sys.mapper
|
||||
* @title: 操作日志数据库控制层接口
|
||||
* @description: 操作日志数据库控制层接口 * @date: 2018-09-30 15:53:25
|
||||
* @copyright: 2018 www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
@Mapper
|
||||
public interface TableMapper extends BaseMapper<Table> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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.ruoyi.web.demo.table.mapper.TableMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
a.*,
|
||||
b.realname as "user.realname",
|
||||
b.username as "user.username"
|
||||
</sql>
|
||||
<sql id="tableJoins">
|
||||
left join sys_user b on b.id = a.author
|
||||
</sql>
|
||||
<!--
|
||||
<select
|
||||
id="selectPage"
|
||||
resultType="com.ruoyi.web.demo.table.entity.Table">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from demo_table a
|
||||
<include refid="tableJoins"/>
|
||||
<if test="ew.sqlSegment != '' and ew.sqlSegment != null">
|
||||
${ew.sqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
-->
|
||||
</mapper>
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ruoyi.web.demo.table.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.web.demo.table.entity.Table;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package com.sunseagear.wind.modules.sys.service
|
||||
* @title: 操作日志服务接口
|
||||
* @description: 操作日志服务接口 * @date: 2018-09-30 15:53:25
|
||||
* @copyright: 2018 www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
public interface ITableService extends IService<Table> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ruoyi.web.demo.table.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.web.demo.table.entity.Table;
|
||||
import com.ruoyi.web.demo.table.mapper.TableMapper;
|
||||
import com.ruoyi.web.demo.table.service.ITableService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package com.sunseagear.wind.modules.sys.service.impl
|
||||
* @title: 操作日志服务实现
|
||||
* @description: 操作日志服务实现 * @date: 2018-09-30 15:53:25
|
||||
* @copyright: 2018 www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
@Transactional
|
||||
@Service("tableService")
|
||||
public class TableServiceImpl extends ServiceImpl<TableMapper, Table> implements ITableService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.ruoyi.web.demo.treeandtable.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.web.demo.treeandtable.entity.TreeAndTable;
|
||||
import com.ruoyi.web.demo.treeandtable.service.ITreeAndTableService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.treeandtable
|
||||
* @title: 左树右表控制器
|
||||
* @description: 左树右表控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 21:24:49
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/demo/treeandtable")
|
||||
public class TreeAndTableController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ITreeAndTableService treeAndTableService;
|
||||
|
||||
/**
|
||||
* 根据页码和每页记录数,以及查询条件动态加载数据
|
||||
*
|
||||
* @param request
|
||||
* @throws IOException
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:treeandtable:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(HttpServletRequest request) throws IOException {
|
||||
//加入条件
|
||||
QueryWrapper<TreeAndTable> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
String name = request.getParameter("name");
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
queryWrapper.eq("name", name);
|
||||
}
|
||||
String type = request.getParameter("type");
|
||||
if (!StringUtils.isEmpty(type)) {
|
||||
queryWrapper.eq("type", type);
|
||||
}
|
||||
String areaId = request.getParameter("areaId");
|
||||
if (!StringUtils.isEmpty(areaId)) {
|
||||
queryWrapper.eq("area_id", areaId);
|
||||
}
|
||||
// 预处理
|
||||
Page pageBean = treeAndTableService.page(getPage(), queryWrapper);
|
||||
return getDataTable(pageBean);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('demo:treeandtable:export')")
|
||||
@Log(title = "左树右表", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(HttpServletRequest request) throws IOException {
|
||||
//加入条件
|
||||
QueryWrapper<TreeAndTable> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
String name = request.getParameter("name");
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
queryWrapper.eq("name", name);
|
||||
}
|
||||
String type = request.getParameter("type");
|
||||
if (!StringUtils.isEmpty(type)) {
|
||||
queryWrapper.eq("type", type);
|
||||
}
|
||||
String areaId = request.getParameter("areaId");
|
||||
if (!StringUtils.isEmpty(areaId)) {
|
||||
queryWrapper.apply("area_id", areaId);
|
||||
}
|
||||
List<TreeAndTable> list = treeAndTableService.list(queryWrapper);
|
||||
ExcelUtil<TreeAndTable> util = new ExcelUtil<>(TreeAndTable.class);
|
||||
return util.exportExcel(list, "左树右表数据");
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('demo:treeandtable:add')")
|
||||
@Log(title = "左树右表", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody TreeAndTable entity) {
|
||||
return toAjax(treeAndTableService.save(entity));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('demo:treeandtable:edit')")
|
||||
@Log(title = "左树右表", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult update(@RequestBody TreeAndTable entity) {
|
||||
return toAjax(treeAndTableService.updateById(entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取左树右表详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:treeandtable:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(treeAndTableService.getById(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('demo:treeandtable:remove')")
|
||||
@Log(title = "左树右表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public AjaxResult batchDelete(@PathVariable String[] infoIds) {
|
||||
return toAjax(treeAndTableService.removeByIds(Arrays.asList(infoIds)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.web.demo.treeandtable.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.treeandtable
|
||||
* @title: 左树右表控制器
|
||||
* @description: 左树右表控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 21:24:49
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("demo_tree_and_table")
|
||||
@SuppressWarnings("serial")
|
||||
public class TreeAndTable extends BaseEntity {
|
||||
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private String id; //id
|
||||
@TableField(value = "name")
|
||||
private String name; //部门名称
|
||||
@TableField(value = "type")
|
||||
private String type; //类型
|
||||
@TableField(value = "tag")
|
||||
private String tag; //标签
|
||||
@TableField(value = "area_id")
|
||||
private String areaId; //区域
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.web.demo.treeandtable.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.web.demo.treeandtable.entity.TreeAndTable;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.treeandtable
|
||||
* @title: 左树右表控制器
|
||||
* @description: 左树右表控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 21:24:50
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
@Mapper
|
||||
public interface TreeAndTableMapper extends BaseMapper<TreeAndTable> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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.ruoyi.web.demo.treeandtable.mapper.TreeAndTableMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
a.id,
|
||||
a.name,
|
||||
a.type,
|
||||
a.tag,
|
||||
a.area_id,
|
||||
a.create_time,
|
||||
a.update_by,
|
||||
a.update_date,
|
||||
a.remarks,
|
||||
a.del_flag,
|
||||
a.create_by
|
||||
</sql>
|
||||
<sql id="tableJoins">
|
||||
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ruoyi.web.demo.treeandtable.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.web.demo.treeandtable.entity.TreeAndTable;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.treeandtable
|
||||
* @title: 左树右表控制器
|
||||
* @description: 左树右表控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 21:24:52
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
public interface ITreeAndTableService extends IService<TreeAndTable> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.web.demo.treeandtable.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.web.demo.treeandtable.entity.TreeAndTable;
|
||||
import com.ruoyi.web.demo.treeandtable.mapper.TreeAndTableMapper;
|
||||
import com.ruoyi.web.demo.treeandtable.service.ITreeAndTableService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.treeandtable
|
||||
* @title: 左树右表控制器
|
||||
* @description: 左树右表控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 21:24:52
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
@Transactional
|
||||
@Service("treeAndTableService")
|
||||
public class TreeAndTableServiceImpl extends ServiceImpl<TreeAndTableMapper, TreeAndTable> implements ITreeAndTableService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.ruoyi.web.demo.treetable.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.web.demo.treetable.entity.TreeTable;
|
||||
import com.ruoyi.web.demo.treetable.service.ITreeTableService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.treetable
|
||||
* @title: 树形结构表控制器
|
||||
* @description: 树形结构表控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 21:38:32
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("demo/treeTable")
|
||||
public class TreeTableController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ITreeTableService treeTableService;
|
||||
|
||||
/**
|
||||
* 根据页码和每页记录数,以及查询条件动态加载数据
|
||||
*
|
||||
* @param request
|
||||
* @throws IOException
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:treetable:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(HttpServletRequest request) throws IOException {
|
||||
//加入条件
|
||||
QueryWrapper<TreeTable> entityWrapper = new QueryWrapper<>();
|
||||
entityWrapper.orderByDesc( "create_time");
|
||||
String name = request.getParameter("name");
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
entityWrapper.like("name", name);
|
||||
}
|
||||
|
||||
// 预处理
|
||||
List<TreeTable> treeNodeList = treeTableService.list(entityWrapper);
|
||||
return AjaxResult.success(treeNodeList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取树形表格详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:treeTable:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||
{
|
||||
return AjaxResult.success(treeTableService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增树形表格
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:treeTable:add')")
|
||||
@Log(title = "树形表格", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody TreeTable treeTable)
|
||||
{
|
||||
return toAjax(treeTableService.save(treeTable));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改树形表格
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:treeTable:edit')")
|
||||
@Log(title = "树形表格", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody TreeTable treeTable)
|
||||
{
|
||||
return toAjax(treeTableService.updateById(treeTable));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除树形表格
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:treeTable:remove')")
|
||||
@Log(title = "树形表格", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids)
|
||||
{
|
||||
return toAjax(treeTableService.removeByIds(Arrays.asList(ids)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.web.demo.treetable.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.TreeEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.treetable
|
||||
* @title: 树形结构表控制器
|
||||
* @description: 树形结构表控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 21:38:33
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("demo_tree_table")
|
||||
@SuppressWarnings("serial")
|
||||
public class TreeTable extends TreeEntity {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private String id; //id
|
||||
|
||||
@TableField(value = "name")
|
||||
private String name; //地理编码
|
||||
@TableField(value = "geocoding")
|
||||
private String geocoding; //地理编码
|
||||
@TableField(value = "postal_code")
|
||||
private String postalCode; //邮政编码
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.web.demo.treetable.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mapper.BaseTreeMapper;
|
||||
import com.ruoyi.web.demo.treetable.entity.TreeTable;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.treetable
|
||||
* @title: 树形结构表控制器
|
||||
* @description: 树形结构表控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 21:38:33
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
@Mapper
|
||||
public interface TreeTableMapper extends BaseTreeMapper<TreeTable> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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.ruoyi.web.demo.treetable.mapper.TreeTableMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
a.*,
|
||||
(select count(*) from demo_tree_table s
|
||||
WHERE s.parent_id=a.id) as
|
||||
hasChildren
|
||||
</sql>
|
||||
<sql id="tableJoins">
|
||||
|
||||
</sql>
|
||||
<select
|
||||
id="selectByTreeId"
|
||||
resultType="com.ruoyi.web.demo.treetable.entity.TreeTable">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from demo_tree_table a
|
||||
<include refid="tableJoins"/>
|
||||
where a.id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select
|
||||
id="selectTreeList"
|
||||
resultType="com.ruoyi.web.demo.treetable.entity.TreeTable">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from demo_tree_table a
|
||||
<include refid="tableJoins"/>
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 更新子树 -->
|
||||
<update id="updateSunTreeParentIds">
|
||||
update demo_tree_table set ancestors= CONCAT(#{newParentIds},substring(ancestors, length(#{oldParentIds})+1,length(ancestors)+1))
|
||||
where ancestors like concat(#{oldParentIds}, '%')
|
||||
</update>
|
||||
|
||||
<!-- 删除子树 -->
|
||||
<delete
|
||||
id="deleteSunTree"
|
||||
parameterType="java.lang.String">
|
||||
delete from demo_tree_table
|
||||
where ancestors like concat(#{parentIds}, '%')
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ruoyi.web.demo.treetable.service;
|
||||
|
||||
import com.ruoyi.common.core.service.ITreeCommonService;
|
||||
import com.ruoyi.web.demo.treetable.entity.TreeTable;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.treetable
|
||||
* @title: 树形结构表控制器
|
||||
* @description: 树形结构表控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 21:38:34
|
||||
* @copyright: www.sunseagear.com Inc. All rightss reserved.
|
||||
*/
|
||||
public interface ITreeTableService extends ITreeCommonService<TreeTable> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.web.demo.treetable.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.impl.TreeCommonServiceImpl;
|
||||
import com.ruoyi.web.demo.treetable.entity.TreeTable;
|
||||
import com.ruoyi.web.demo.treetable.mapper.TreeTableMapper;
|
||||
import com.ruoyi.web.demo.treetable.service.ITreeTableService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package test.treetable
|
||||
* @title: 树形结构表控制器
|
||||
* @description: 树形结构表控制器
|
||||
* @author: admin
|
||||
* @date: 2019-11-13 21:38:34
|
||||
* @copyright: www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
@Transactional
|
||||
@Service("treeTableService")
|
||||
public class TreeTableServiceImpl extends TreeCommonServiceImpl<TreeTableMapper, TreeTable> implements ITreeTableService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.ruoyi.web.demo.twotable.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.web.demo.twotable.entity.Car;
|
||||
import com.ruoyi.web.demo.twotable.service.ICarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/demo/twotable/car")
|
||||
public class CarController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ICarService carService;
|
||||
|
||||
|
||||
/**
|
||||
* 根据页码和每页记录数,以及查询条件动态加载数据
|
||||
*
|
||||
* @param request
|
||||
* @throws IOException
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:twotable:car:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(HttpServletRequest request) throws IOException {
|
||||
//加入条件
|
||||
QueryWrapper<Car> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc( "create_time");
|
||||
String keyword = request.getParameter("keyword");
|
||||
if (!StringUtils.isEmpty(keyword)) {
|
||||
queryWrapper.like("name", keyword).or().like("code", keyword);
|
||||
}
|
||||
// 预处理
|
||||
Page<Car> page = carService.page(getPage(), queryWrapper);
|
||||
return getDataTable(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车辆品牌详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:twotable:car:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(carService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增车辆品牌
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:twotable:car:add')")
|
||||
@Log(title = "车辆品牌", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Car car) {
|
||||
return toAjax(carService.save(car));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改车辆品牌
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:twotable:car:edit')")
|
||||
@Log(title = "车辆品牌", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Car car) {
|
||||
return toAjax(carService.updateById(car));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除车辆品牌
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:twotable:car:remove')")
|
||||
@Log(title = "车辆品牌", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] infoIds) {
|
||||
return toAjax(carService.removeByIds(Arrays.asList(infoIds)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.ruoyi.web.demo.twotable.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.web.demo.twotable.entity.CarModel;
|
||||
import com.ruoyi.web.demo.twotable.service.ICarModelService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* All rights Reserved, Designed By www.sunseagear.com
|
||||
*
|
||||
* @version V1.0
|
||||
* @package com.sunseagear.wind.modules.sys.controller
|
||||
* @title: 消息模版控制器
|
||||
* @description: 消息模版控制器 * @date: 2018-09-03 15:10:10
|
||||
* @copyright: 2018 www.sunseagear.com Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/demo/twotable/carmodel")
|
||||
public class CarModelController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ICarModelService carModelService;
|
||||
|
||||
|
||||
/**
|
||||
* 根据页码和每页记录数,以及查询条件动态加载数据
|
||||
*
|
||||
* @param request
|
||||
* @throws IOException
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:twotable:car:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(HttpServletRequest request) throws IOException {
|
||||
//加入条件
|
||||
QueryWrapper<CarModel> entityWrapper = new QueryWrapper<>();
|
||||
entityWrapper.orderByAsc( "sort");
|
||||
String keyword = request.getParameter("keyword");
|
||||
String carId = request.getParameter("carId");
|
||||
if (!StringUtils.isEmpty(carId) && !StringUtils.isEmpty(keyword)) {
|
||||
entityWrapper.eq("car_id", carId).and(i -> i.like("label", keyword).or().like("value", keyword));
|
||||
} else if (!StringUtils.isEmpty(carId)) {
|
||||
entityWrapper.eq("car_id", carId);
|
||||
}
|
||||
|
||||
// 预处理
|
||||
Page<CarModel> page = carModelService.page(getPage(), entityWrapper);
|
||||
return getDataTable(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车辆型号详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:twotable:car:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(carModelService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增车辆型号
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:twotable:car:add')")
|
||||
@Log(title = "车辆型号", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CarModel carModel) {
|
||||
return toAjax(carModelService.save(carModel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改车辆型号
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:twotable:car:edit')")
|
||||
@Log(title = "车辆型号", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CarModel carModel) {
|
||||
return toAjax(carModelService.updateById(carModel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除车辆型号
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('demo:twotable:car:remove')")
|
||||
@Log(title = "车辆型号", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] infoIds) {
|
||||
return toAjax(carModelService.removeByIds(Arrays.asList(infoIds)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.ruoyi.web.demo.twotable.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
@TableName("demo_car")
|
||||
@SuppressWarnings("serial")
|
||||
public class Car extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private String id;
|
||||
/**
|
||||
* 汽车品牌
|
||||
*/
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 品牌编码
|
||||
*/
|
||||
@TableField(value = "code")
|
||||
private String code;
|
||||
|
||||
|
||||
/**
|
||||
* 获取 code
|
||||
*
|
||||
* @return: String 分组编码
|
||||
*/
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 code
|
||||
*
|
||||
* @param: code
|
||||
* 分组编码
|
||||
*/
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 id
|
||||
*
|
||||
* @return: String 主键
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 id
|
||||
*
|
||||
* @param: id
|
||||
* 主键
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 name
|
||||
*
|
||||
* @return: String 分组名称
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 name
|
||||
*
|
||||
* @param: name
|
||||
* 分组名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.ruoyi.web.demo.twotable.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
@TableName("demo_car_model")
|
||||
@SuppressWarnings("serial")
|
||||
public class CarModel extends BaseEntity {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private String id;
|
||||
@TableField(value = "car_id")
|
||||
private String carId;
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
@TableField(value = "value")
|
||||
private String value;
|
||||
|
||||
@TableField(value = "sort")
|
||||
private Integer sort;
|
||||
@TableField(exist = false)
|
||||
private String code;
|
||||
|
||||
public String getCarId() {
|
||||
return this.carId;
|
||||
}
|
||||
|
||||
public void setCarId(String carId) {
|
||||
this.carId = carId;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return this.sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ruoyi.web.demo.twotable.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.web.demo.twotable.entity.Car;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CarMapper extends BaseMapper<Car> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.ruoyi.web.demo.twotable.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.web.demo.twotable.entity.CarModel;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CarModelMapper extends BaseMapper<CarModel> {
|
||||
List<CarModel> selectDictList();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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.ruoyi.web.demo.twotable.mapper.CarModelMapper">
|
||||
<sql id="Base_Column_List">
|
||||
d.id,
|
||||
d.car_id,
|
||||
d.name,
|
||||
d.value,
|
||||
d.sort,
|
||||
d.remarks,
|
||||
g.code
|
||||
</sql>
|
||||
<select id="selectDictList" resultType="com.ruoyi.web.demo.twotable.entity.CarModel">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from demo_car_model d
|
||||
LEFT JOIN demo_car g on d.car_id=g.id ORDER BY sort ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ruoyi.web.demo.twotable.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.web.demo.twotable.entity.CarModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jwcg
|
||||
* @version V1.0
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2017-02-09 09:05:29
|
||||
*/
|
||||
public interface ICarModelService extends IService<CarModel> {
|
||||
List<CarModel> selectDictList();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.web.demo.twotable.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.web.demo.twotable.entity.Car;
|
||||
|
||||
/**
|
||||
* @author jwcg
|
||||
* @version V1.0
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2017-02-09 09:05:51
|
||||
*/
|
||||
public interface ICarService extends IService<Car> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.web.demo.twotable.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.web.demo.twotable.entity.CarModel;
|
||||
import com.ruoyi.web.demo.twotable.mapper.CarModelMapper;
|
||||
import com.ruoyi.web.demo.twotable.service.ICarModelService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Transactional
|
||||
@Service("carModelService")
|
||||
public class CarModelServiceImpl extends ServiceImpl<CarModelMapper, CarModel> implements ICarModelService {
|
||||
|
||||
@Override
|
||||
public List<CarModel> selectDictList() {
|
||||
return baseMapper.selectDictList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.web.demo.twotable.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.web.demo.twotable.entity.Car;
|
||||
import com.ruoyi.web.demo.twotable.entity.CarModel;
|
||||
import com.ruoyi.web.demo.twotable.mapper.CarMapper;
|
||||
import com.ruoyi.web.demo.twotable.service.ICarModelService;
|
||||
import com.ruoyi.web.demo.twotable.service.ICarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
|
||||
@Transactional
|
||||
@Service("carService")
|
||||
public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarService {
|
||||
@Autowired
|
||||
private ICarModelService carModelService;
|
||||
|
||||
@Override
|
||||
public boolean removeById(Serializable id) {
|
||||
carModelService.remove(new QueryWrapper<CarModel>().eq("car_id",id));
|
||||
return super.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeByIds(Collection<? extends Serializable> idList) {
|
||||
idList.forEach(id ->{
|
||||
removeById(id);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user