Initial commit
This commit is contained in:
51
jc-club-subject/jc-club-infra/pom.xml
Normal file
51
jc-club-subject/jc-club-infra/pom.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>jc-club-subject</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jc-club-infra</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>jc-club-infra</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!--jdbcStarter-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
<version>2.4.2</version>
|
||||
</dependency>
|
||||
<!--druid连接池-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.21</version>
|
||||
</dependency>
|
||||
<!--mysql-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
<!--mybatis plus-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.landaiqing</groupId>
|
||||
<artifactId>jc-club-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@@ -0,0 +1,59 @@
|
||||
package com.landaiqing.subject.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 题目分类(SubjectCategory)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-07 16:17:17
|
||||
*/
|
||||
@Data
|
||||
public class SubjectCategory implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
private String categoryName;
|
||||
/**
|
||||
* 分类类型
|
||||
*/
|
||||
private Integer categoryType;
|
||||
/**
|
||||
* 图标连接
|
||||
*/
|
||||
private String imageUrl;
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 是否删除 0: 未删除 1: 已删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,74 @@
|
||||
package com.landaiqing.subject.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectCategory;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目分类(SubjectCategory)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-07 16:17:16
|
||||
*/
|
||||
public interface SubjectCategoryDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectCategory queryById(Long id);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param subjectCategory 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(SubjectCategory subjectCategory);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectCategory 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(SubjectCategory subjectCategory);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<SubjectCategory> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<SubjectCategory> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<SubjectCategory> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<SubjectCategory> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectCategory 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(SubjectCategory subjectCategory);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
List<SubjectCategory> queryCategory(SubjectCategory subjectCategory);
|
||||
}
|
||||
|
@@ -0,0 +1,52 @@
|
||||
package com.landaiqing.subject.infra.basic.service;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectCategory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目分类(SubjectCategory)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-07 16:17:20
|
||||
*/
|
||||
public interface SubjectCategoryService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectCategory queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectCategory 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectCategory insert(SubjectCategory subjectCategory);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectCategory 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(SubjectCategory subjectCategory);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 查询岗位大类
|
||||
* @return
|
||||
*/
|
||||
List<SubjectCategory> queryCategory(SubjectCategory subjectCategory);
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
package com.landaiqing.subject.infra.basic.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectCategory;
|
||||
import com.landaiqing.subject.infra.basic.mapper.SubjectCategoryDao;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectCategoryService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目分类(SubjectCategory)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-07 16:17:20
|
||||
*/
|
||||
@Service("subjectCategoryService")
|
||||
@Slf4j
|
||||
public class SubjectCategoryServiceImpl implements SubjectCategoryService {
|
||||
@Resource
|
||||
private SubjectCategoryDao subjectCategoryDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectCategory queryById(Long id) {
|
||||
return this.subjectCategoryDao.queryById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectCategory 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectCategory insert(SubjectCategory subjectCategory) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectCategoryController.add.subjectCategory:{}", JSON.toJSONString(subjectCategory));
|
||||
}
|
||||
this.subjectCategoryDao.insert(subjectCategory);
|
||||
return subjectCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectCategory 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(SubjectCategory subjectCategory) {
|
||||
return this.subjectCategoryDao.update(subjectCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.subjectCategoryDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubjectCategory> queryCategory(SubjectCategory subjectCategory) {
|
||||
return this.subjectCategoryDao.queryCategory(subjectCategory);
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package com.landaiqing.subject.infra.basic.utils;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigTools;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
|
||||
/**
|
||||
* 数据库加密util
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/7
|
||||
*/
|
||||
public class DruidEncryptUtil {
|
||||
|
||||
private static String publicKey;
|
||||
|
||||
private static String privateKey;
|
||||
|
||||
static {
|
||||
try {
|
||||
String[] keyPair = ConfigTools.genKeyPair(512);
|
||||
privateKey=keyPair[0];
|
||||
System.out.println("privateKey:"+privateKey);
|
||||
publicKey=keyPair[1];
|
||||
System.out.println("publicKey:"+publicKey);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (NoSuchProviderException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public static String encrypt(String plainText) throws Exception {
|
||||
String encrypt = ConfigTools.encrypt(privateKey, plainText);
|
||||
System.out.println("encrypt:"+encrypt);
|
||||
return encrypt;
|
||||
}
|
||||
public static String decrypt(String encryptText) throws Exception {
|
||||
String decrypt = ConfigTools.decrypt(publicKey, encryptText);
|
||||
System.out.println("decrypt:"+decrypt);
|
||||
return decrypt;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String encrypt = encrypt("1611");
|
||||
System.out.println("encrypt:"+encrypt);
|
||||
}
|
||||
}
|
@@ -0,0 +1,188 @@
|
||||
<?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.landaiqing.subject.infra.basic.mapper.SubjectCategoryDao">
|
||||
|
||||
<resultMap type="com.landaiqing.subject.infra.basic.entity.SubjectCategory" id="SubjectCategoryMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="categoryName" column="category_name" jdbcType="VARCHAR"/>
|
||||
<result property="categoryType" column="category_type" jdbcType="INTEGER"/>
|
||||
<result property="imageUrl" column="image_url" jdbcType="VARCHAR"/>
|
||||
<result property="parentId" column="parent_id" jdbcType="INTEGER"/>
|
||||
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="SubjectCategoryMap">
|
||||
select id,
|
||||
category_name,
|
||||
category_type,
|
||||
image_url,
|
||||
parent_id,
|
||||
created_by,
|
||||
created_time,
|
||||
update_by,
|
||||
update_time
|
||||
from subject_category
|
||||
where id = #{id}
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from subject_category
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="categoryName != null and categoryName != ''">
|
||||
and category_name = #{categoryName}
|
||||
</if>
|
||||
<if test="categoryType != null">
|
||||
and category_type = #{categoryType}
|
||||
</if>
|
||||
<if test="imageUrl != null and imageUrl != ''">
|
||||
and image_url = #{imageUrl}
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
and parent_id = #{parentId}
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
and created_time = #{createdTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<!--查询分类-->
|
||||
<select id="queryCategory" resultMap="SubjectCategoryMap">
|
||||
select * from subject_category
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="categoryName != null and categoryName != ''">
|
||||
and category_name = #{categoryName}
|
||||
</if>
|
||||
<if test="categoryType != null">
|
||||
and category_type = #{categoryType}
|
||||
</if>
|
||||
<if test="imageUrl != null and imageUrl != ''">
|
||||
and image_url = #{imageUrl}
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
and parent_id = #{parentId}
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
and created_time = #{createdTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_category(category_name, category_type, image_url, parent_id, created_by, created_time,
|
||||
update_by, update_time, is_deleted)
|
||||
values (#{categoryName}, #{categoryType}, #{imageUrl}, #{parentId}, #{createdBy}, #{createdTime}, #{updateBy},
|
||||
#{updateTime}, #{isDeleted})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_category(category_name, category_type, image_url, parent_id, created_by, created_time,
|
||||
update_by, update_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.categoryName}, #{entity.categoryType}, #{entity.imageUrl}, #{entity.parentId},
|
||||
#{entity.createdBy}, #{entity.createdTime}, #{entity.updateBy}, #{entity.updateTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_category(category_name, category_type, image_url, parent_id, created_by, created_time,
|
||||
update_by, update_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.categoryName}, #{entity.categoryType}, #{entity.imageUrl}, #{entity.parentId},
|
||||
#{entity.createdBy}, #{entity.createdTime}, #{entity.updateBy}, #{entity.updateTime})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
category_name = values(category_name),
|
||||
category_type = values(category_type),
|
||||
image_url = values(image_url),
|
||||
parent_id = values(parent_id),
|
||||
created_by = values(created_by),
|
||||
created_time = values(created_time),
|
||||
update_by = values(update_by),
|
||||
update_time = values(update_time)
|
||||
</insert>
|
||||
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update subject_category
|
||||
<set>
|
||||
<if test="categoryName != null and categoryName != ''">
|
||||
category_name = #{categoryName},
|
||||
</if>
|
||||
<if test="categoryType != null">
|
||||
category_type = #{categoryType},
|
||||
</if>
|
||||
<if test="imageUrl != null and imageUrl != ''">
|
||||
image_url = #{imageUrl},
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
parent_id = #{parentId},
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
created_by = #{createdBy},
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
created_time = #{createdTime},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by = #{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
is_deleted = #{isDeleted},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete from subject_category where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user