Compare commits
4 Commits
master
...
server_202
Author | SHA1 | Date |
---|---|---|
|
fcec1f7e93 | |
|
866981adea | |
|
094c62be8d | |
|
a3290a8b5b |
7
pom.xml
7
pom.xml
|
@ -207,6 +207,13 @@
|
||||||
<version>${zhilian.version}</version>
|
<version>${zhilian.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 一组3.23-3.24测试mybatis-plus模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-mybatis-plus</artifactId>
|
||||||
|
<version>${zhilian.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<module>zhilian-gen</module>
|
<module>zhilian-gen</module>
|
||||||
<module>zhilian-job</module>
|
<module>zhilian-job</module>
|
||||||
<module>zhilian-file</module>
|
<module>zhilian-file</module>
|
||||||
|
<module>zhilian-mybatis-plus</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>zhilian-modules</artifactId>
|
<artifactId>zhilian-modules</artifactId>
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>zhilian-mybatis-plus</artifactId>
|
||||||
|
|
||||||
|
|
||||||
|
<description>
|
||||||
|
zhilian-mybatis-plus测试
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- FastDFS -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.tobato</groupId>
|
||||||
|
<artifactId>fastdfs-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Minio -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.minio</groupId>
|
||||||
|
<artifactId>minio</artifactId>
|
||||||
|
<version>${minio.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- zhilian Common Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-swagger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- zhilian Common System-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-system</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zhilian</groupId>
|
||||||
|
<artifactId>zhilian-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.zhilian.mybatis_plus;
|
||||||
|
|
||||||
|
import com.zhilian.common.security.annotation.EnableCustomConfig;
|
||||||
|
import com.zhilian.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: Seer
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/24 10:51
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class MybatisPlusApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(MybatisPlusApplication.class,args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
package com.zhilian.mybatis_plus.controller;
|
||||||
|
|
||||||
|
import com.zhilian.common.core.domain.Result;
|
||||||
|
import com.zhilian.common.core.web.controller.BaseController;
|
||||||
|
import com.zhilian.common.core.web.page.TableDataInfo;
|
||||||
|
import com.zhilian.common.log.enums.BusinessType;
|
||||||
|
import com.zhilian.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.zhilian.common.security.utils.SecurityUtils;
|
||||||
|
import com.zhilian.mybatis_plus.domain.Clazz;
|
||||||
|
import com.zhilian.mybatis_plus.service.ClazzService;
|
||||||
|
import com.zhilian.common.log.annotation.Log;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: Seer
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/24 10:45
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/clazz")
|
||||||
|
public class ClazzController extends BaseController{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ClazzService clazzService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询班级列表
|
||||||
|
* @param clazz
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<Clazz>> list (Clazz clazz) {
|
||||||
|
startPage();
|
||||||
|
List<Clazz> list = clazzService.pageQuery(clazz);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增班级
|
||||||
|
* @param clazz
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Log(title = "班级管理", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public Result add (@Validated @RequestBody Clazz clazz) {
|
||||||
|
if (!clazzService.checkConfigKeyUnique(clazz)) {
|
||||||
|
return error("新增参数'" + clazz.getName() + "'失败,班级名称已存在");
|
||||||
|
}
|
||||||
|
clazz.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(clazzService.save(clazz));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改班级
|
||||||
|
*/
|
||||||
|
@Log(title = "班级管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public Result edit (@Validated @RequestBody Clazz clazz) {
|
||||||
|
if (!clazzService.checkConfigKeyUnique(clazz)) {
|
||||||
|
return error("修改参数'" + clazz.getName() + "'失败,班级名称已存在");
|
||||||
|
}
|
||||||
|
clazz.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(clazzService.updateById(clazz));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除班级
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:config:remove")
|
||||||
|
@Log(title = "班级管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{clazzIds}")
|
||||||
|
public Result remove (@PathVariable Long[] clazzIds) {
|
||||||
|
clazzService.removeBatchByIds(Arrays.asList(clazzIds));
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.zhilian.mybatis_plus.controller;
|
||||||
|
|
||||||
|
import com.zhilian.common.core.domain.Result;
|
||||||
|
import com.zhilian.common.core.web.controller.BaseController;
|
||||||
|
import com.zhilian.common.core.web.page.TableDataInfo;
|
||||||
|
import com.zhilian.common.log.annotation.Log;
|
||||||
|
import com.zhilian.common.log.enums.BusinessType;
|
||||||
|
import com.zhilian.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.zhilian.common.security.utils.SecurityUtils;
|
||||||
|
import com.zhilian.mybatis_plus.domain.Student;
|
||||||
|
import com.zhilian.mybatis_plus.domain.response.StudentRes;
|
||||||
|
import com.zhilian.mybatis_plus.service.StudentService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: LiYuan
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/25 15:12
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/student")
|
||||||
|
public class StudentController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StudentService studentService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询学生列表
|
||||||
|
* @param student
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<StudentRes>> list (Student student) {
|
||||||
|
startPage();
|
||||||
|
List<StudentRes> list = studentService.pageQuery(student);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增学生
|
||||||
|
* @param student
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Log(title = "学生管理", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public Result add (@Validated @RequestBody Student student) {
|
||||||
|
if (!studentService.checkConfigKeyUnique(student)) {
|
||||||
|
return error("新增参数'" + student.getName() + "'失败,学生名称已存在");
|
||||||
|
}
|
||||||
|
student.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(studentService.save(student));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改学生
|
||||||
|
*/
|
||||||
|
@Log(title = "班级管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public Result edit (@Validated @RequestBody Student student) {
|
||||||
|
if (!studentService.checkConfigKeyUnique(student)) {
|
||||||
|
return error("修改参数'" + student.getName() + "'失败,学生名称已存在");
|
||||||
|
}
|
||||||
|
student.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(studentService.updateById(student));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除学生
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:config:remove")
|
||||||
|
@Log(title = "学生管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{studentIds}")
|
||||||
|
public Result remove (@PathVariable Long[] studentIds) {
|
||||||
|
studentService.removeBatchByIds(Arrays.asList(studentIds));
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.zhilian.mybatis_plus.domain;//package com.zhilian.mybatis_plus.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.zhilian.common.core.annotation.Excel;
|
||||||
|
import com.zhilian.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: Seer
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/24 10:37
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_clazz")
|
||||||
|
public class Clazz extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班级编号 主键
|
||||||
|
*/
|
||||||
|
@Excel(name = "班级编号",cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班级名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 创建者
|
||||||
|
// */
|
||||||
|
// private String createBy;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 创建时间
|
||||||
|
// */
|
||||||
|
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
// private Date createTime;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 更新者
|
||||||
|
// */
|
||||||
|
// private String updateBy;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 更新时间
|
||||||
|
// */
|
||||||
|
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
// private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.zhilian.mybatis_plus.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.zhilian.common.core.annotation.Excel;
|
||||||
|
import com.zhilian.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: Seer
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/24 10:37
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_student")
|
||||||
|
public class Student extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 学生 编号 主键
|
||||||
|
*/
|
||||||
|
@Excel(name = "学生编号",cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 学生姓名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 学生照片
|
||||||
|
*/
|
||||||
|
private String photo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 学生班级
|
||||||
|
*/
|
||||||
|
private Long tClazz;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 学生性别
|
||||||
|
*/
|
||||||
|
private Integer sex;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.zhilian.mybatis_plus.domain.response;
|
||||||
|
|
||||||
|
import com.zhilian.mybatis_plus.domain.Clazz;
|
||||||
|
import com.zhilian.mybatis_plus.domain.Student;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: LiYuan
|
||||||
|
* @description: 学生+所属班级
|
||||||
|
* @date: 2024/3/25 15:17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class StudentRes {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 学生
|
||||||
|
*/
|
||||||
|
private Student student;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 该学生所属班级
|
||||||
|
*/
|
||||||
|
private Clazz clazz;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.zhilian.mybatis_plus.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zhilian.mybatis_plus.domain.Clazz;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: Seer
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/24 10:48
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ClazzMapper extends BaseMapper<Clazz> {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.zhilian.mybatis_plus.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zhilian.mybatis_plus.domain.Student;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: LiYuan
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/25 15:14
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface StudentMapper extends BaseMapper<Student> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.zhilian.mybatis_plus.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.zhilian.mybatis_plus.domain.Clazz;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: Seer
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/24 10:46
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface ClazzService extends IService<Clazz> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询班级列表
|
||||||
|
* @param clazz
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Clazz> pageQuery(Clazz clazz);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测参数是否唯一
|
||||||
|
* @param clazz
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean checkConfigKeyUnique(Clazz clazz);
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.zhilian.mybatis_plus.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.zhilian.mybatis_plus.domain.Student;
|
||||||
|
import com.zhilian.mybatis_plus.domain.response.StudentRes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: LiYuan
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/25 15:13
|
||||||
|
*/
|
||||||
|
public interface StudentService extends IService<Student> {
|
||||||
|
/**
|
||||||
|
* 查询学生列表
|
||||||
|
* @param student
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<StudentRes> pageQuery(Student student);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测参数学生名称是否唯一
|
||||||
|
* @param student
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean checkConfigKeyUnique(Student student);
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.zhilian.mybatis_plus.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.zhilian.common.core.utils.StringUtils;
|
||||||
|
import com.zhilian.mybatis_plus.domain.Clazz;
|
||||||
|
import com.zhilian.mybatis_plus.mapper.ClazzMapper;
|
||||||
|
import com.zhilian.mybatis_plus.service.ClazzService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: Seer
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/24 10:46
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ClazzServiceImpl extends ServiceImpl<ClazzMapper,Clazz> implements ClazzService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询班级列表
|
||||||
|
* @param clazz
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Clazz> pageQuery(Clazz clazz) {
|
||||||
|
LambdaQueryWrapper<Clazz> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotEmpty(clazz.getName())){
|
||||||
|
queryWrapper.like(Clazz::getName,clazz.getName());
|
||||||
|
}
|
||||||
|
Object beginTime = clazz.getParams().get("beginTime");
|
||||||
|
if (Objects.nonNull(beginTime) && beginTime instanceof Date beginDate){
|
||||||
|
queryWrapper.gt(Clazz::getCreateTime, beginDate);
|
||||||
|
}
|
||||||
|
Object endTime = clazz.getParams().get("endTime");
|
||||||
|
if (Objects.nonNull(endTime) && endTime instanceof Date endDate){
|
||||||
|
queryWrapper.lt(Clazz::getCreateTime, endDate);
|
||||||
|
}
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测参数班级名称是否唯一
|
||||||
|
* @param clazz
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean checkConfigKeyUnique(Clazz clazz) {
|
||||||
|
LambdaQueryWrapper<Clazz> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(Clazz::getName, clazz.getName());
|
||||||
|
return this.count(queryWrapper) > 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
package com.zhilian.mybatis_plus.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.zhilian.common.core.utils.StringUtils;
|
||||||
|
import com.zhilian.mybatis_plus.domain.Clazz;
|
||||||
|
import com.zhilian.mybatis_plus.domain.Student;
|
||||||
|
import com.zhilian.mybatis_plus.domain.response.StudentRes;
|
||||||
|
import com.zhilian.mybatis_plus.mapper.StudentMapper;
|
||||||
|
import com.zhilian.mybatis_plus.service.StudentService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version:
|
||||||
|
* @Author: LiYuan
|
||||||
|
* @description:
|
||||||
|
* @date: 2024/3/25 15:13
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements StudentService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StudentMapper studentMapper;
|
||||||
|
@Autowired
|
||||||
|
private ClazzServiceImpl clazzService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询学生列表
|
||||||
|
*
|
||||||
|
* @param student
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<StudentRes> pageQuery(Student student) {
|
||||||
|
//获取班级列表
|
||||||
|
List<Clazz> clazzList = clazzService.pageQuery(new Clazz() {{
|
||||||
|
setId(student.getTClazz());
|
||||||
|
}});
|
||||||
|
//获取学生列表
|
||||||
|
LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotEmpty(student.getName())) {
|
||||||
|
queryWrapper.like(Student::getName, student.getName());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(student.getTClazz()) && 0 != student.getTClazz()) {
|
||||||
|
queryWrapper.like(Student::getTClazz, student.getTClazz());
|
||||||
|
}
|
||||||
|
Object beginTime = student.getParams().get("beginTime");
|
||||||
|
if (Objects.nonNull(beginTime) && beginTime instanceof Date beginDate) {
|
||||||
|
queryWrapper.gt(Student::getCreateTime, beginDate);
|
||||||
|
}
|
||||||
|
Object endTime = student.getParams().get("endTime");
|
||||||
|
if (Objects.nonNull(endTime) && endTime instanceof Date endDate) {
|
||||||
|
queryWrapper.lt(Student::getCreateTime, endDate);
|
||||||
|
}
|
||||||
|
List<Student> list = this.list(queryWrapper);
|
||||||
|
|
||||||
|
//将学生对象与班级对象进行关联
|
||||||
|
List<StudentRes> studentRes = list.stream().map(stu -> {
|
||||||
|
StudentRes res = new StudentRes();
|
||||||
|
Long tClazz = stu.getTClazz();
|
||||||
|
Optional<Clazz> foundClazz = clazzList.stream().filter(clazz -> Objects.equals(clazz.getId(), tClazz)).findFirst();
|
||||||
|
|
||||||
|
//未找到班级对象则说明脏数据出现
|
||||||
|
if (!foundClazz.isPresent()) {
|
||||||
|
throw new RuntimeException("班级数据异常");
|
||||||
|
}
|
||||||
|
Clazz targetClass = foundClazz.get();
|
||||||
|
res.setStudent(stu);
|
||||||
|
res.setClazz(targetClass);
|
||||||
|
return res;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return studentRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测参数学生名称是否唯一
|
||||||
|
* @param student
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean checkConfigKeyUnique(Student student) {
|
||||||
|
LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(Student::getName, student.getName());
|
||||||
|
return this.count(queryWrapper) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9301
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: zhilian-mybatis
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 10.10.25.2:8848
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 10.10.25.2:8848
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="logs/zhilian-mybatis-plus" />
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="com.zhilian" level="info" />
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn" />
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info" />
|
||||||
|
<appender-ref ref="file_error" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?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.zhilian.mybatis_plus.mapper.ClazzMapper">
|
||||||
|
|
||||||
|
<resultMap id="ClazzResult" type="com.zhilian.mybatis_plus.domain.Clazz">
|
||||||
|
<id property="id" column="id"/>
|
||||||
|
<result property="name" column="name"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.zhilian.mybatis_plus.mapper.StudentMapper">
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -80,6 +80,7 @@ public class SysConfigController extends BaseController {
|
||||||
return toAjax(configService.save(config));
|
return toAjax(configService.save(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改参数配置
|
* 修改参数配置
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue