新增三方接口

master
xiaoCJ 8 months ago
parent 2974b95f48
commit 2a6d5d2033

@ -11,13 +11,17 @@ import com.sztzjy.resource_center.mapper.SysResourceMapper;
import com.sztzjy.resource_center.util.file.IFileUtil; import com.sztzjy.resource_center.util.file.IFileUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.core.io.FileSystemResource;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RestController; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -28,17 +32,16 @@ import java.util.stream.Collectors;
@Api(tags = "资源方面API") @Api(tags = "资源方面API")
@RequestMapping("api/tea/ResourceApi") @RequestMapping("api/tea/ResourceApi")
public class ResourceApi { public class ResourceApi {
@Autowired @Autowired
private SysResourceMapper sysResourceMapper; private SysResourceMapper sysResourceMapper;
@Value("${file.path}")
private String filePath;
@Autowired @Autowired
private SysResourceAndCourseMapper sysResourceAndCourseMapper; private IFileUtil fileUtil;
@Autowired @Autowired
private SysCaseQuestionMapper sysCaseQuestionMapper; private SysResourceAndCourseMapper sysResourceAndCourseMapper;
@Autowired @Autowired
SysOneCatalogMapper oneCatalogMapper; SysOneCatalogMapper oneCatalogMapper;
@Autowired
private IFileUtil fileUtil;
private SysOneCatalog getSysOneCatalogs(String systemOwner) { private SysOneCatalog getSysOneCatalogs(String systemOwner) {
@ -190,6 +193,93 @@ public class ResourceApi {
} }
//下载资源文件
@GetMapping("downloadResource")
@ApiOperation("下载资源文件")
@AnonymousAccess
public void downloadResource(@ApiParam("资源ID") @RequestParam String resourceId, HttpServletResponse response) {
SysResource sysResource = sysResourceMapper.selectByPrimaryKey(resourceId);
if ("课件".equals(sysResource.getResourceType())) {
fileUtil.download(response, sysResource.getResourceName(), sysResource.getUrl());
}
if (sysResource.getCount() == null) {
sysResource.setCount(1);
} else {
sysResource.setCount(sysResource.getCount() + 1);
}
sysResourceMapper.updateByPrimaryKey(sysResource);
}
@GetMapping("/getResource")
@ApiOperation("预览/获取视频或课件")
@AnonymousAccess
public ResponseEntity<FileSystemResource> streamVideo(@ApiParam("资源ID") @RequestParam String id) {
SysResource sysResource = sysResourceMapper.selectByPrimaryKey(id);
String url = sysResource.getUrl();
String videoPath = filePath + url;
File videoFile = new File(videoPath);
if ("视频".equals(sysResource.getResourceType())) {
if (videoFile.exists()) {
// Path path = Paths.get(videoPath);
FileSystemResource fileSystemResource = new FileSystemResource(videoFile);
//设置count
if (sysResource.getCount() == null) {
sysResource.setCount(1);
} else {
sysResource.setCount(sysResource.getCount() + 1);
}
sysResourceMapper.updateByPrimaryKey(sysResource);
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("video/mp4"))
.body(fileSystemResource);
} else {
return ResponseEntity.notFound().build();
}
} else if ("课件".equals(sysResource.getResourceType())) {
if (videoFile.exists()) {
FileSystemResource fileSystemResource = new FileSystemResource(videoFile);
//设置count
if (sysResource.getCount() == null) {
sysResource.setCount(1);
} else {
sysResource.setCount(sysResource.getCount() + 1);
}
sysResourceMapper.updateByPrimaryKey(sysResource);
if (url.endsWith("pptx")) {
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.presentationml.presentation"))
.body(fileSystemResource);
} else if (url.endsWith("ppt")) {
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("application/vnd.ms-powerpoint"))
.body(fileSystemResource);
} else {
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("application/pdf"))
.body(fileSystemResource);
}
} else {
return ResponseEntity.notFound().build();
}
}
return ResponseEntity.notFound().build();
}
/** /**
* *
* getMostPopularName * getMostPopularName

@ -43,6 +43,9 @@ public class SysResource {
private String threeName; private String threeName;
@ApiModelProperty("使用次数")
private Integer count;
@ApiModelProperty("启用状态 1已启用 0未启用") @ApiModelProperty("启用状态 1已启用 0未启用")
private Integer status; private Integer status;
@ -145,6 +148,14 @@ public class SysResource {
this.threeName = threeName == null ? null : threeName.trim(); this.threeName = threeName == null ? null : threeName.trim();
} }
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Integer getStatus() { public Integer getStatus() {
return status; return status;
} }

@ -945,6 +945,66 @@ public class SysResourceExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCountIsNull() {
addCriterion("count is null");
return (Criteria) this;
}
public Criteria andCountIsNotNull() {
addCriterion("count is not null");
return (Criteria) this;
}
public Criteria andCountEqualTo(Integer value) {
addCriterion("count =", value, "count");
return (Criteria) this;
}
public Criteria andCountNotEqualTo(Integer value) {
addCriterion("count <>", value, "count");
return (Criteria) this;
}
public Criteria andCountGreaterThan(Integer value) {
addCriterion("count >", value, "count");
return (Criteria) this;
}
public Criteria andCountGreaterThanOrEqualTo(Integer value) {
addCriterion("count >=", value, "count");
return (Criteria) this;
}
public Criteria andCountLessThan(Integer value) {
addCriterion("count <", value, "count");
return (Criteria) this;
}
public Criteria andCountLessThanOrEqualTo(Integer value) {
addCriterion("count <=", value, "count");
return (Criteria) this;
}
public Criteria andCountIn(List<Integer> values) {
addCriterion("count in", values, "count");
return (Criteria) this;
}
public Criteria andCountNotIn(List<Integer> values) {
addCriterion("count not in", values, "count");
return (Criteria) this;
}
public Criteria andCountBetween(Integer value1, Integer value2) {
addCriterion("count between", value1, value2, "count");
return (Criteria) this;
}
public Criteria andCountNotBetween(Integer value1, Integer value2) {
addCriterion("count not between", value1, value2, "count");
return (Criteria) this;
}
public Criteria andStatusIsNull() { public Criteria andStatusIsNull() {
addCriterion("status is null"); addCriterion("status is null");
return (Criteria) this; return (Criteria) this;

@ -2,14 +2,12 @@ package com.sztzjy.resource_center.mapper;
import com.sztzjy.resource_center.entity.SysResource; import com.sztzjy.resource_center.entity.SysResource;
import com.sztzjy.resource_center.entity.SysResourceExample; import com.sztzjy.resource_center.entity.SysResourceExample;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.sztzjy.resource_center.entity.dto.SysResourceDto; import com.sztzjy.resource_center.entity.dto.SysResourceDto;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@Mapper @Mapper
public interface SysResourceMapper { public interface SysResourceMapper {
long countByExample(SysResourceExample example); long countByExample(SysResourceExample example);
@ -45,5 +43,5 @@ public interface SysResourceMapper {
@Param("threeId") String threeId, @Param("threeId") String threeId,
@Param("resourceName") String resourceName); @Param("resourceName") String resourceName);
Map<String, Integer> getCountByType(@Param("list") List<String> ids,@Param("schoolId") String schoolId); Map<String, Integer> getCountByType(@Param("list") List<String> ids, @Param("schoolId") String schoolId);
} }

@ -23,7 +23,7 @@
<property name="useInformationSchema" value="true"/> <!--useInformationSchema 实体类上添加数据表的注释 --> <property name="useInformationSchema" value="true"/> <!--useInformationSchema 实体类上添加数据表的注释 -->
</jdbcConnection> </jdbcConnection>
<!-- 配置实体类的位置 --> <!-- 配置实体类的位置 -->
<javaModelGenerator targetPackage="com.sztzjy.resource_center.entity.admin" targetProject="src/main/java"> <javaModelGenerator targetPackage="com.sztzjy.resource_center.entity" targetProject="src/main/java">
<!-- 生成的Java模型是否支持序列化 --> <!-- 生成的Java模型是否支持序列化 -->
<property name="enableSubPackages" value="true"/> <property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/> <property name="trimStrings" value="true"/>
@ -35,7 +35,7 @@
</sqlMapGenerator> </sqlMapGenerator>
<!-- 配置Mapper接口的位置 --> <!-- 配置Mapper接口的位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.sztzjy.resource_center.mapper.admin" <javaClientGenerator type="XMLMAPPER" targetPackage="com.sztzjy.resource_center.mapper"
targetProject="src/main/java"> targetProject="src/main/java">
<property name="enableSubPackages" value="true"/> <property name="enableSubPackages" value="true"/>
</javaClientGenerator> </javaClientGenerator>
@ -46,14 +46,14 @@
<!-- <table tableName="sys_model_question" domainObjectName="SysModelQuestion" />--> <!-- <table tableName="sys_model_question" domainObjectName="SysModelQuestion" />-->
<!-- <table tableName="sys_objective_questions" domainObjectName="SysObjectiveQuestions" />--> <!-- <table tableName="sys_objective_questions" domainObjectName="SysObjectiveQuestions" />-->
<!-- <table tableName="sys_one_catalog" domainObjectName="SysOneCatalog" />--> <!-- <table tableName="sys_one_catalog" domainObjectName="SysOneCatalog" />-->
<!-- <table tableName="sys_resource" domainObjectName="SysResource" />--> <table tableName="sys_resource" domainObjectName="SysResource" />
<!-- <table tableName="sys_resource_and_course" domainObjectName="SysResourceAndCourse" />--> <!-- <table tableName="sys_resource_and_course" domainObjectName="SysResourceAndCourse" />-->
<!-- <table tableName="sys_resource_data" domainObjectName="SysResourceData" />--> <!-- <table tableName="sys_resource_data" domainObjectName="SysResourceData" />-->
<!-- <table tableName="sys_school" domainObjectName="SysSchool" />--> <!-- <table tableName="sys_school" domainObjectName="SysSchool" />-->
<!-- <table tableName="sys_three_catalog" domainObjectName="SysThreeCatalog" />--> <!-- <table tableName="sys_three_catalog" domainObjectName="SysThreeCatalog" />-->
<!-- <table tableName="sys_topic_and_course" domainObjectName="SysTopicAndCourse" />--> <!-- <table tableName="sys_topic_and_course" domainObjectName="SysTopicAndCourse" />-->
<table tableName="admin_case" domainObjectName="AdminCase" /> <!-- <table tableName="admin_case" domainObjectName="AdminCase" />-->
<table tableName="admin_data" domainObjectName="AdminData" /> <!-- <table tableName="admin_data" domainObjectName="AdminData" />-->
<!-- <table tableName="admin_collect_case" domainObjectName="AdminCollectCase" />--> <!-- <table tableName="admin_collect_case" domainObjectName="AdminCollectCase" />-->
<!-- <table tableName="admin_collect_data" domainObjectName="AdminCollectData" />--> <!-- <table tableName="admin_collect_data" domainObjectName="AdminCollectData" />-->
<!-- <table tableName="admin_data_label" domainObjectName="AdminDataLabel" />--> <!-- <table tableName="admin_data_label" domainObjectName="AdminDataLabel" />-->

@ -1,436 +1,447 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sztzjy.resource_center.mapper.SysResourceMapper"> <mapper namespace="com.sztzjy.resource_center.mapper.SysResourceMapper">
<resultMap id="BaseResultMap" type="com.sztzjy.resource_center.entity.SysResource"> <resultMap id="BaseResultMap" type="com.sztzjy.resource_center.entity.SysResource">
<id column="resource_id" jdbcType="VARCHAR" property="resourceId"/> <id column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<result column="resource_name" jdbcType="VARCHAR" property="resourceName"/> <result column="resource_name" jdbcType="VARCHAR" property="resourceName" />
<result column="url" jdbcType="VARCHAR" property="url"/> <result column="url" jdbcType="VARCHAR" property="url" />
<result column="picture_url" jdbcType="VARCHAR" property="pictureUrl"/> <result column="picture_url" jdbcType="VARCHAR" property="pictureUrl" />
<result column="resource_type" jdbcType="VARCHAR" property="resourceType"/> <result column="resource_type" jdbcType="VARCHAR" property="resourceType" />
<result column="source" jdbcType="VARCHAR" property="source"/> <result column="source" jdbcType="VARCHAR" property="source" />
<result column="one_tag" jdbcType="VARCHAR" property="oneTag"/> <result column="one_tag" jdbcType="VARCHAR" property="oneTag" />
<result column="one_name" jdbcType="VARCHAR" property="oneName"/> <result column="one_name" jdbcType="VARCHAR" property="oneName" />
<result column="two_tag" jdbcType="VARCHAR" property="twoTag"/> <result column="two_tag" jdbcType="VARCHAR" property="twoTag" />
<result column="two_name" jdbcType="VARCHAR" property="twoName"/> <result column="two_name" jdbcType="VARCHAR" property="twoName" />
<result column="three_tag" jdbcType="VARCHAR" property="threeTag"/> <result column="three_tag" jdbcType="VARCHAR" property="threeTag" />
<result column="three_name" jdbcType="VARCHAR" property="threeName"/> <result column="three_name" jdbcType="VARCHAR" property="threeName" />
<result column="status" jdbcType="INTEGER" property="status"/> <result column="count" jdbcType="INTEGER" property="count" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> <result column="status" jdbcType="INTEGER" property="status" />
</resultMap> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<sql id="Example_Where_Clause"> </resultMap>
<where> <sql id="Example_Where_Clause">
<foreach collection="oredCriteria" item="criteria" separator="or"> <where>
<if test="criteria.valid"> <foreach collection="oredCriteria" item="criteria" separator="or">
<trim prefix="(" prefixOverrides="and" suffix=")"> <if test="criteria.valid">
<foreach collection="criteria.criteria" item="criterion"> <trim prefix="(" prefixOverrides="and" suffix=")">
<choose> <foreach collection="criteria.criteria" item="criterion">
<when test="criterion.noValue"> <choose>
and ${criterion.condition} <when test="criterion.noValue">
</when> and ${criterion.condition}
<when test="criterion.singleValue"> </when>
and ${criterion.condition} #{criterion.value} <when test="criterion.singleValue">
</when> and ${criterion.condition} #{criterion.value}
<when test="criterion.betweenValue"> </when>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} <when test="criterion.betweenValue">
</when> and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
<when test="criterion.listValue"> </when>
and ${criterion.condition} <when test="criterion.listValue">
<foreach close=")" collection="criterion.value" item="listItem" open="(" and ${criterion.condition}
separator=","> <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
</choose> </choose>
</foreach>
</trim>
</if>
</foreach> </foreach>
</where> </trim>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
resource_id
, resource_name, url, picture_url, resource_type, source, one_tag, one_name,
two_tag, two_name, three_tag, three_name, status, create_time
</sql>
<select id="selectByExample" parameterType="com.sztzjy.resource_center.entity.SysResourceExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from sys_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from sys_resource
where resource_id = #{resourceId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete
from sys_resource
where resource_id = #{resourceId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.resource_center.entity.SysResourceExample">
delete from sys_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if> </if>
</delete> </foreach>
<insert id="insert" parameterType="com.sztzjy.resource_center.entity.SysResource"> </where>
insert into sys_resource (resource_id, resource_name, url, </sql>
picture_url, resource_type, source, <sql id="Update_By_Example_Where_Clause">
one_tag, one_name, two_tag, <where>
two_name, three_tag, three_name, <foreach collection="example.oredCriteria" item="criteria" separator="or">
status, create_time) <if test="criteria.valid">
values (#{resourceId,jdbcType=VARCHAR}, #{resourceName,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, <trim prefix="(" prefixOverrides="and" suffix=")">
#{pictureUrl,jdbcType=VARCHAR}, #{resourceType,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR}, <foreach collection="criteria.criteria" item="criterion">
#{oneTag,jdbcType=VARCHAR}, #{oneName,jdbcType=VARCHAR}, #{twoTag,jdbcType=VARCHAR}, <choose>
#{twoName,jdbcType=VARCHAR}, #{threeTag,jdbcType=VARCHAR}, #{threeName,jdbcType=VARCHAR}, <when test="criterion.noValue">
#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}) and ${criterion.condition}
</insert> </when>
<insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.SysResource"> <when test="criterion.singleValue">
insert into sys_resource and ${criterion.condition} #{criterion.value}
<trim prefix="(" suffix=")" suffixOverrides=","> </when>
<if test="resourceId != null"> <when test="criterion.betweenValue">
resource_id, and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</if> </when>
<if test="resourceName != null"> <when test="criterion.listValue">
resource_name, and ${criterion.condition}
</if> <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
<if test="url != null"> #{listItem}
url, </foreach>
</if> </when>
<if test="pictureUrl != null"> </choose>
picture_url, </foreach>
</if> </trim>
<if test="resourceType != null">
resource_type,
</if>
<if test="source != null">
source,
</if>
<if test="oneTag != null">
one_tag,
</if>
<if test="oneName != null">
one_name,
</if>
<if test="twoTag != null">
two_tag,
</if>
<if test="twoName != null">
two_name,
</if>
<if test="threeTag != null">
three_tag,
</if>
<if test="threeName != null">
three_name,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="resourceId != null">
#{resourceId,jdbcType=VARCHAR},
</if>
<if test="resourceName != null">
#{resourceName,jdbcType=VARCHAR},
</if>
<if test="url != null">
#{url,jdbcType=VARCHAR},
</if>
<if test="pictureUrl != null">
#{pictureUrl,jdbcType=VARCHAR},
</if>
<if test="resourceType != null">
#{resourceType,jdbcType=VARCHAR},
</if>
<if test="source != null">
#{source,jdbcType=VARCHAR},
</if>
<if test="oneTag != null">
#{oneTag,jdbcType=VARCHAR},
</if>
<if test="oneName != null">
#{oneName,jdbcType=VARCHAR},
</if>
<if test="twoTag != null">
#{twoTag,jdbcType=VARCHAR},
</if>
<if test="twoName != null">
#{twoName,jdbcType=VARCHAR},
</if>
<if test="threeTag != null">
#{threeTag,jdbcType=VARCHAR},
</if>
<if test="threeName != null">
#{threeName,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.resource_center.entity.SysResourceExample"
resultType="java.lang.Long">
select count(*) from sys_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update sys_resource
<set>
<if test="record.resourceId != null">
resource_id = #{record.resourceId,jdbcType=VARCHAR},
</if>
<if test="record.resourceName != null">
resource_name = #{record.resourceName,jdbcType=VARCHAR},
</if>
<if test="record.url != null">
url = #{record.url,jdbcType=VARCHAR},
</if>
<if test="record.pictureUrl != null">
picture_url = #{record.pictureUrl,jdbcType=VARCHAR},
</if>
<if test="record.resourceType != null">
resource_type = #{record.resourceType,jdbcType=VARCHAR},
</if>
<if test="record.source != null">
source = #{record.source,jdbcType=VARCHAR},
</if>
<if test="record.oneTag != null">
one_tag = #{record.oneTag,jdbcType=VARCHAR},
</if>
<if test="record.oneName != null">
one_name = #{record.oneName,jdbcType=VARCHAR},
</if>
<if test="record.twoTag != null">
two_tag = #{record.twoTag,jdbcType=VARCHAR},
</if>
<if test="record.twoName != null">
two_name = #{record.twoName,jdbcType=VARCHAR},
</if>
<if test="record.threeTag != null">
three_tag = #{record.threeTag,jdbcType=VARCHAR},
</if>
<if test="record.threeName != null">
three_name = #{record.threeName,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if> </if>
</update> </foreach>
<update id="updateByExample" parameterType="map"> </where>
update sys_resource </sql>
set resource_id = #{record.resourceId,jdbcType=VARCHAR}, <sql id="Base_Column_List">
resource_id, resource_name, url, picture_url, resource_type, source, one_tag, one_name,
two_tag, two_name, three_tag, three_name, count, status, create_time
</sql>
<select id="selectByExample" parameterType="com.sztzjy.resource_center.entity.SysResourceExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from sys_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_resource
where resource_id = #{resourceId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from sys_resource
where resource_id = #{resourceId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.resource_center.entity.SysResourceExample">
delete from sys_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.resource_center.entity.SysResource">
insert into sys_resource (resource_id, resource_name, url,
picture_url, resource_type, source,
one_tag, one_name, two_tag,
two_name, three_tag, three_name,
count, status, create_time
)
values (#{resourceId,jdbcType=VARCHAR}, #{resourceName,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR},
#{pictureUrl,jdbcType=VARCHAR}, #{resourceType,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR},
#{oneTag,jdbcType=VARCHAR}, #{oneName,jdbcType=VARCHAR}, #{twoTag,jdbcType=VARCHAR},
#{twoName,jdbcType=VARCHAR}, #{threeTag,jdbcType=VARCHAR}, #{threeName,jdbcType=VARCHAR},
#{count,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.SysResource">
insert into sys_resource
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="resourceId != null">
resource_id,
</if>
<if test="resourceName != null">
resource_name,
</if>
<if test="url != null">
url,
</if>
<if test="pictureUrl != null">
picture_url,
</if>
<if test="resourceType != null">
resource_type,
</if>
<if test="source != null">
source,
</if>
<if test="oneTag != null">
one_tag,
</if>
<if test="oneName != null">
one_name,
</if>
<if test="twoTag != null">
two_tag,
</if>
<if test="twoName != null">
two_name,
</if>
<if test="threeTag != null">
three_tag,
</if>
<if test="threeName != null">
three_name,
</if>
<if test="count != null">
count,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="resourceId != null">
#{resourceId,jdbcType=VARCHAR},
</if>
<if test="resourceName != null">
#{resourceName,jdbcType=VARCHAR},
</if>
<if test="url != null">
#{url,jdbcType=VARCHAR},
</if>
<if test="pictureUrl != null">
#{pictureUrl,jdbcType=VARCHAR},
</if>
<if test="resourceType != null">
#{resourceType,jdbcType=VARCHAR},
</if>
<if test="source != null">
#{source,jdbcType=VARCHAR},
</if>
<if test="oneTag != null">
#{oneTag,jdbcType=VARCHAR},
</if>
<if test="oneName != null">
#{oneName,jdbcType=VARCHAR},
</if>
<if test="twoTag != null">
#{twoTag,jdbcType=VARCHAR},
</if>
<if test="twoName != null">
#{twoName,jdbcType=VARCHAR},
</if>
<if test="threeTag != null">
#{threeTag,jdbcType=VARCHAR},
</if>
<if test="threeName != null">
#{threeName,jdbcType=VARCHAR},
</if>
<if test="count != null">
#{count,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.resource_center.entity.SysResourceExample" resultType="java.lang.Long">
select count(*) from sys_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update sys_resource
<set>
<if test="record.resourceId != null">
resource_id = #{record.resourceId,jdbcType=VARCHAR},
</if>
<if test="record.resourceName != null">
resource_name = #{record.resourceName,jdbcType=VARCHAR}, resource_name = #{record.resourceName,jdbcType=VARCHAR},
</if>
<if test="record.url != null">
url = #{record.url,jdbcType=VARCHAR}, url = #{record.url,jdbcType=VARCHAR},
</if>
<if test="record.pictureUrl != null">
picture_url = #{record.pictureUrl,jdbcType=VARCHAR}, picture_url = #{record.pictureUrl,jdbcType=VARCHAR},
</if>
<if test="record.resourceType != null">
resource_type = #{record.resourceType,jdbcType=VARCHAR}, resource_type = #{record.resourceType,jdbcType=VARCHAR},
</if>
<if test="record.source != null">
source = #{record.source,jdbcType=VARCHAR}, source = #{record.source,jdbcType=VARCHAR},
</if>
<if test="record.oneTag != null">
one_tag = #{record.oneTag,jdbcType=VARCHAR}, one_tag = #{record.oneTag,jdbcType=VARCHAR},
</if>
<if test="record.oneName != null">
one_name = #{record.oneName,jdbcType=VARCHAR}, one_name = #{record.oneName,jdbcType=VARCHAR},
</if>
<if test="record.twoTag != null">
two_tag = #{record.twoTag,jdbcType=VARCHAR}, two_tag = #{record.twoTag,jdbcType=VARCHAR},
</if>
<if test="record.twoName != null">
two_name = #{record.twoName,jdbcType=VARCHAR}, two_name = #{record.twoName,jdbcType=VARCHAR},
</if>
<if test="record.threeTag != null">
three_tag = #{record.threeTag,jdbcType=VARCHAR}, three_tag = #{record.threeTag,jdbcType=VARCHAR},
</if>
<if test="record.threeName != null">
three_name = #{record.threeName,jdbcType=VARCHAR}, three_name = #{record.threeName,jdbcType=VARCHAR},
</if>
<if test="record.count != null">
count = #{record.count,jdbcType=INTEGER},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=INTEGER}, status = #{record.status,jdbcType=INTEGER},
create_time = #{record.createTime,jdbcType=TIMESTAMP} </if>
<if test="_parameter != null"> <if test="record.createTime != null">
<include refid="Update_By_Example_Where_Clause"/> create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if> </if>
</update> </set>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.resource_center.entity.SysResource"> <if test="_parameter != null">
update sys_resource <include refid="Update_By_Example_Where_Clause" />
<set> </if>
<if test="resourceName != null"> </update>
resource_name = #{resourceName,jdbcType=VARCHAR}, <update id="updateByExample" parameterType="map">
</if> update sys_resource
<if test="url != null"> set resource_id = #{record.resourceId,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR}, resource_name = #{record.resourceName,jdbcType=VARCHAR},
</if> url = #{record.url,jdbcType=VARCHAR},
<if test="pictureUrl != null"> picture_url = #{record.pictureUrl,jdbcType=VARCHAR},
picture_url = #{pictureUrl,jdbcType=VARCHAR}, resource_type = #{record.resourceType,jdbcType=VARCHAR},
</if> source = #{record.source,jdbcType=VARCHAR},
<if test="resourceType != null"> one_tag = #{record.oneTag,jdbcType=VARCHAR},
resource_type = #{resourceType,jdbcType=VARCHAR}, one_name = #{record.oneName,jdbcType=VARCHAR},
</if> two_tag = #{record.twoTag,jdbcType=VARCHAR},
<if test="source != null"> two_name = #{record.twoName,jdbcType=VARCHAR},
source = #{source,jdbcType=VARCHAR}, three_tag = #{record.threeTag,jdbcType=VARCHAR},
</if> three_name = #{record.threeName,jdbcType=VARCHAR},
<if test="oneTag != null"> count = #{record.count,jdbcType=INTEGER},
one_tag = #{oneTag,jdbcType=VARCHAR}, status = #{record.status,jdbcType=INTEGER},
</if> create_time = #{record.createTime,jdbcType=TIMESTAMP}
<if test="oneName != null"> <if test="_parameter != null">
one_name = #{oneName,jdbcType=VARCHAR}, <include refid="Update_By_Example_Where_Clause" />
</if> </if>
<if test="twoTag != null"> </update>
two_tag = #{twoTag,jdbcType=VARCHAR}, <update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.resource_center.entity.SysResource">
</if> update sys_resource
<if test="twoName != null"> <set>
two_name = #{twoName,jdbcType=VARCHAR}, <if test="resourceName != null">
</if> resource_name = #{resourceName,jdbcType=VARCHAR},
<if test="threeTag != null"> </if>
three_tag = #{threeTag,jdbcType=VARCHAR}, <if test="url != null">
</if> url = #{url,jdbcType=VARCHAR},
<if test="threeName != null"> </if>
three_name = #{threeName,jdbcType=VARCHAR}, <if test="pictureUrl != null">
</if> picture_url = #{pictureUrl,jdbcType=VARCHAR},
<if test="status != null"> </if>
status = #{status,jdbcType=INTEGER}, <if test="resourceType != null">
</if> resource_type = #{resourceType,jdbcType=VARCHAR},
<if test="createTime != null"> </if>
create_time = #{createTime,jdbcType=TIMESTAMP}, <if test="source != null">
</if> source = #{source,jdbcType=VARCHAR},
</set> </if>
where resource_id = #{resourceId,jdbcType=VARCHAR} <if test="oneTag != null">
</update> one_tag = #{oneTag,jdbcType=VARCHAR},
<update id="updateByPrimaryKey" parameterType="com.sztzjy.resource_center.entity.SysResource"> </if>
update sys_resource <if test="oneName != null">
set resource_name = #{resourceName,jdbcType=VARCHAR}, one_name = #{oneName,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR}, </if>
picture_url = #{pictureUrl,jdbcType=VARCHAR}, <if test="twoTag != null">
resource_type = #{resourceType,jdbcType=VARCHAR}, two_tag = #{twoTag,jdbcType=VARCHAR},
source = #{source,jdbcType=VARCHAR}, </if>
one_tag = #{oneTag,jdbcType=VARCHAR}, <if test="twoName != null">
one_name = #{oneName,jdbcType=VARCHAR}, two_name = #{twoName,jdbcType=VARCHAR},
two_tag = #{twoTag,jdbcType=VARCHAR}, </if>
two_name = #{twoName,jdbcType=VARCHAR}, <if test="threeTag != null">
three_tag = #{threeTag,jdbcType=VARCHAR}, three_tag = #{threeTag,jdbcType=VARCHAR},
three_name = #{threeName,jdbcType=VARCHAR}, </if>
status = #{status,jdbcType=INTEGER}, <if test="threeName != null">
create_time = #{createTime,jdbcType=TIMESTAMP} three_name = #{threeName,jdbcType=VARCHAR},
where resource_id = #{resourceId,jdbcType=VARCHAR} </if>
</update> <if test="count != null">
count = #{count,jdbcType=INTEGER},
<resultMap id="DtoMap" type="com.sztzjy.resource_center.entity.SysResource"> </if>
<id column="resource_id" jdbcType="VARCHAR" property="resourceId"/> <if test="status != null">
<result column="resource_name" jdbcType="VARCHAR" property="resourceName"/> status = #{status,jdbcType=INTEGER},
<result column="url" jdbcType="VARCHAR" property="url"/> </if>
<result column="picture_url" jdbcType="VARCHAR" property="pictureUrl"/> <if test="createTime != null">
<result column="resource_type" jdbcType="VARCHAR" property="resourceType"/> create_time = #{createTime,jdbcType=TIMESTAMP},
<result column="source" jdbcType="VARCHAR" property="source"/> </if>
<result column="one_id" jdbcType="VARCHAR" property="oneTag"/> </set>
<result column="one_name" jdbcType="VARCHAR" property="oneName"/> where resource_id = #{resourceId,jdbcType=VARCHAR}
<result column="two_id" jdbcType="VARCHAR" property="twoTag"/> </update>
<result column="two_name" jdbcType="VARCHAR" property="twoName"/> <update id="updateByPrimaryKey" parameterType="com.sztzjy.resource_center.entity.SysResource">
<result column="three_id" jdbcType="VARCHAR" property="threeTag"/> update sys_resource
<result column="three_name" jdbcType="VARCHAR" property="threeName"/> set resource_name = #{resourceName,jdbcType=VARCHAR},
<result column="status" jdbcType="INTEGER" property="status"/> url = #{url,jdbcType=VARCHAR},
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> picture_url = #{pictureUrl,jdbcType=VARCHAR},
</resultMap> resource_type = #{resourceType,jdbcType=VARCHAR},
source = #{source,jdbcType=VARCHAR},
one_tag = #{oneTag,jdbcType=VARCHAR},
one_name = #{oneName,jdbcType=VARCHAR},
two_tag = #{twoTag,jdbcType=VARCHAR},
two_name = #{twoName,jdbcType=VARCHAR},
three_tag = #{threeTag,jdbcType=VARCHAR},
three_name = #{threeName,jdbcType=VARCHAR},
count = #{count,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP}
where resource_id = #{resourceId,jdbcType=VARCHAR}
</update>
<!--重复--> <resultMap id="DtoMap" type="com.sztzjy.resource_center.entity.SysResource">
<select id="selectResourceByRepeat" parameterType="java.lang.String" resultMap="DtoMap"> <id column="resource_id" jdbcType="VARCHAR" property="resourceId" />
SELECT sc.one_id,sc.two_id,sc.three_id,sc.one_name,sc.two_name,sc.three_name,sr.resource_name,sr.resource_id,sr.url,sr.picture_url,sr.resource_type,sr.source,sr.status,sr.create_time <result column="resource_name" jdbcType="VARCHAR" property="resourceName" />
FROM sys_resource sr <result column="url" jdbcType="VARCHAR" property="url" />
left JOIN <result column="picture_url" jdbcType="VARCHAR" property="pictureUrl" />
sys_resource_and_course sc <result column="resource_type" jdbcType="VARCHAR" property="resourceType" />
on sr.resource_id =sc.resource_id <result column="source" jdbcType="VARCHAR" property="source" />
<where> <result column="one_id" jdbcType="VARCHAR" property="oneTag" />
<if test="oneId != null and oneId != ''"> <result column="one_name" jdbcType="VARCHAR" property="oneName" />
sc.one_id = #{oneId} <result column="two_id" jdbcType="VARCHAR" property="twoTag" />
</if> <result column="two_name" jdbcType="VARCHAR" property="twoName" />
<if test="twoId != null and twoId != ''"> <result column="three_id" jdbcType="VARCHAR" property="threeTag" />
and sc.two_id = #{twoId} <result column="three_name" jdbcType="VARCHAR" property="threeName" />
</if> <result column="status" jdbcType="INTEGER" property="status" />
<if test="threeId != null and threeId != ''"> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
and sc.three_id = #{threeId} </resultMap>
</if>
<if test="resourceName != null and resourceName != ''">
and sr.resource_name LIKE CONCAT('%', #{resourceName}, '%')
</if>
</where>
order by sr.create_time
</select>
<!--不重复--> <!--重复-->
<select id="selectResource" parameterType="java.lang.String" resultMap="DtoMap"> <select id="selectResourceByRepeat" parameterType="java.lang.String" resultMap="DtoMap">
SELECT DISTINCT sc.one_id,sc.two_id,sc.three_id,sc.one_name,sc.two_name,sc.three_name,sr.resource_name,sr.resource_id,sr.url,sr.picture_url,sr.resource_type,sr.source,sr.status,sr.create_time SELECT sc.one_id,sc.two_id,sc.three_id,sc.one_name,sc.two_name,sc.three_name,sr.resource_name,sr.resource_id,sr.url,sr.picture_url,sr.resource_type,sr.source,sr.status,sr.create_time
FROM sys_resource sr FROM sys_resource sr
left JOIN left JOIN
sys_resource_and_course sc sys_resource_and_course sc
on sr.resource_id =sc.resource_id on sr.resource_id =sc.resource_id
<where> <where>
<if test="oneId != null and oneId != ''"> <if test="oneId != null and oneId != ''">
sc.one_id = #{oneId} sc.one_id = #{oneId}
</if> </if>
<if test="twoId != null and twoId != ''"> <if test="twoId != null and twoId != ''">
and sc.two_id = #{twoId} and sc.two_id = #{twoId}
</if> </if>
<if test="threeId != null and threeId != ''"> <if test="threeId != null and threeId != ''">
and sc.three_id = #{threeId} and sc.three_id = #{threeId}
</if> </if>
<if test="source != null and source != ''"> <if test="resourceName != null and resourceName != ''">
and sr.source = #{source} and sr.resource_name LIKE CONCAT('%', #{resourceName}, '%')
</if> </if>
</where> </where>
order by sr.create_time order by sr.create_time
</select> </select>
<select id="getCountByType" resultType="map"> <!--不重复-->
SELECT resource_type, count(*) as count <select id="selectResource" parameterType="java.lang.String" resultMap="DtoMap">
FROM sys_resource SELECT DISTINCT sc.one_id,sc.two_id,sc.three_id,sc.one_name,sc.two_name,sc.three_name,sr.resource_name,sr.resource_id,sr.url,sr.picture_url,sr.resource_type,sr.source,sr.status,sr.create_time
WHERE resource_id IN FROM sys_resource sr
<foreach item="item" index="index" collection="list" open="(" separator="," close=")"> left JOIN
#{item} sys_resource_and_course sc
</foreach> on sr.resource_id =sc.resource_id
AND source = #{schoolId} <where>
GROUP BY resource_type <if test="oneId != null and oneId != ''">
</select> sc.one_id = #{oneId}
</if>
<if test="twoId != null and twoId != ''">
and sc.two_id = #{twoId}
</if>
<if test="threeId != null and threeId != ''">
and sc.three_id = #{threeId}
</if>
<if test="source != null and source != ''">
and sr.source = #{source}
</if>
</where>
order by sr.create_time
</select>
<select id="getCountByType" resultType="map">
SELECT resource_type, count(*) as count
FROM sys_resource
WHERE resource_id IN
<foreach close=")" collection="list" index="index" item="item" open="(" separator=",">
#{item}
</foreach>
AND source = #{schoolId}
GROUP BY resource_type
</select>
</mapper> </mapper>
Loading…
Cancel
Save