组件代码学生端动态展示、超管端支持更新修改

master
@t2652009480 8 months ago
parent 578787d5ff
commit 634c1da3af

@ -0,0 +1,348 @@
package com.sztzjy.resource_center.controller.new_module.admin;
import cn.hutool.core.util.IdUtil;
import com.github.pagehelper.PageInfo;
import com.google.common.reflect.TypeToken;
import com.nimbusds.jose.shaded.gson.Gson;
import com.nimbusds.jose.shaded.gson.JsonSyntaxException;
import com.sztzjy.resource_center.annotation.AnonymousAccess;
import com.sztzjy.resource_center.entity.*;
import com.sztzjy.resource_center.entity.admin.*;
import com.sztzjy.resource_center.mapper.AdminComponentCodeMapper;
import com.sztzjy.resource_center.mapper.AdminJupyterTokenMapper;
import com.sztzjy.resource_center.mapper.admin.AdminFileMapper;
import com.sztzjy.resource_center.util.PageUtil;
import com.sztzjy.resource_center.util.ResultEntity;
import com.sztzjy.resource_center.util.file.IFileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
* @author tz
* @date 2024/7/26 10:16
*/
@RestController
@Api(tags = "管理员端组件代码案例管理")
@RequestMapping("api/admin/componentCode")
public class AdminComponentCodeController {
@Autowired
private IFileUtil fileUtil;
@Value("${file.path}")
private String filePath;
@Resource
AdminFileMapper adminFileMapper;
@Resource
AdminComponentCodeMapper adminComponentCodeMapper;
@Autowired
private AdminJupyterTokenMapper adminJupyterTokenMapper;
@Value("${tch.serverAddress}")
String JUPYTER_URL;
@PostMapping("/add")
@ApiOperation("新增")
@AnonymousAccess
@Transactional
public ResultEntity<String> add(@ApiParam("代码内容") String codeContent,
@ApiParam("参数释义")@RequestParam(required = false) String parameterContent,
@ApiParam("步骤名称(一级标签)") String stepName,
@ApiParam("案例名称(二级标签)") String caseName,
@RequestParam(required = false) List<MultipartFile> dataFile) {
if (StringUtils.isBlank(stepName)) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入步骤名称!");
}
if (StringUtils.isBlank(caseName)) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入案例名称!");
}
if (StringUtils.isBlank(codeContent)) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入代码内容!");
}
if (StringUtils.isBlank(parameterContent)) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入参数释义!");
}
//新增
AdminComponentCodeWithBLOBs adminComponentCode = new AdminComponentCodeWithBLOBs();
Integer uuid = UUID.randomUUID().toString().replaceAll("-", "").hashCode();
uuid = uuid < 0 ? -uuid : uuid;//String.hashCode() 值会为空
adminComponentCode.setId(uuid);
adminComponentCode.setCourseName(stepName);
adminComponentCode.setChapterName(caseName);
adminComponentCode.setItem(codeContent);
adminComponentCode.setDefinition(parameterContent);
adminComponentCode.setStatus(0); //默认下架,发布后上架
adminComponentCode.setCreateTime(new Date());
//设置数据文件
if (dataFile != null && !dataFile.isEmpty()) {
List<AdminFile> list = new ArrayList<>();
for (MultipartFile file : dataFile) {
AdminFile adminFile = new AdminFile();
adminFile.setFileId(IdUtil.randomUUID());
String dataUrl = fileUtil.upload(file);
String fullFileName = file.getOriginalFilename();
adminFile.setFileUrl(dataUrl);
adminFile.setName(fullFileName);
adminFile.setSource("案例表");
adminFile.setDataCaseId(String.valueOf(uuid));
list.add(adminFile);
}
//批量新增数据文件
adminFileMapper.insertBatch(list);
}
//新增案例
adminComponentCodeMapper.insert(adminComponentCode);
return new ResultEntity<>(HttpStatus.OK, "新增成功!");
}
@PostMapping("updateAdminData")
@ApiOperation("编辑")
@AnonymousAccess
@Transactional
public ResultEntity<String> updateAdminData(@ApiParam("案例ID") @RequestParam Integer id,
@ApiParam("代码内容")@RequestParam(required = false) String codeContent,
@ApiParam("参数释义")@RequestParam(required = false) String parameterContent,
@ApiParam("步骤名称(一级标签)")@RequestParam(required = false) String stepName,
@ApiParam("案例名称(二级标签)")@RequestParam(required = false) String caseName) {
//编辑
try {
AdminComponentCodeWithBLOBs adminComponentCode = new AdminComponentCodeWithBLOBs();
adminComponentCode.setId(id);
adminComponentCode.setCourseName(stepName);
adminComponentCode.setChapterName(caseName);
adminComponentCode.setItem(codeContent);
adminComponentCode.setDefinition(parameterContent);
adminComponentCode.setStatus(0); //默认下架,发布后上架
adminComponentCode.setCreateTime(new Date()); //修改时间
// 更新对象
adminComponentCodeMapper.updateByPrimaryKeyWithBLOBs(adminComponentCode);
} catch (Exception e) {
e.printStackTrace();
return new ResultEntity<>(HttpStatus.INTERNAL_SERVER_ERROR, "编辑失败请联系管理员!");
}
return new ResultEntity<>(HttpStatus.OK, "编辑成功!");
}
@PostMapping("getAdminData")
@ApiOperation("展示")
@AnonymousAccess
@Transactional
public ResultEntity getAdminData(@RequestParam Integer index,
@RequestParam Integer size,
@RequestParam(required = false) String caseName ) {
AdminComponentCodeExample codeExample=new AdminComponentCodeExample();
if(!caseName.isEmpty()){
codeExample.createCriteria().andChapterNameLike("%"+caseName+"%");
}
List<AdminComponentCodeWithBLOBs> adminComponentCodeWithBLOBs = adminComponentCodeMapper.selectByExampleWithBLOBs(codeExample);
PageInfo pageInfo = PageUtil.pageHelper(adminComponentCodeWithBLOBs, index, size);
return new ResultEntity<>(HttpStatus.OK, "成功!",pageInfo);
}
@PostMapping("addFile")
@ApiOperation("编辑/文件单独新增")
@AnonymousAccess
private ResultEntity<HttpStatus> addFile(@RequestParam String dataId,
@RequestParam MultipartFile dataFile) {
try {
AdminFile adminFile = new AdminFile();
String url = fileUtil.upload(dataFile);
adminFile.setFileId(IdUtil.randomUUID());
adminFile.setDataCaseId(dataId);
adminFile.setName(dataFile.getOriginalFilename());
adminFile.setSource("管理员");
adminFile.setFileUrl(url);
adminFileMapper.insert(adminFile);
} catch (Exception e) {
e.printStackTrace();
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "上传失败,请联系管理员!");
}
return new ResultEntity<HttpStatus>(HttpStatus.OK, "上传成功!");
}
@PostMapping("deleteFile")
@ApiOperation("编辑/单个数据文件删除")
@AnonymousAccess
private ResultEntity<HttpStatus> deleteFile(@RequestParam String fileId) {
try {
AdminFile adminFile = adminFileMapper.selectByPrimaryKey(fileId);
if (adminFile != null) {
adminFileMapper.deleteByPrimaryKey(adminFile.getFileId());
}
} catch (Exception e) {
e.printStackTrace();
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "删除失败,请联系管理员!");
}
return new ResultEntity<HttpStatus>(HttpStatus.OK, "删除成功!");
}
@PostMapping("updateStatus")
@ApiOperation("发布或禁用")
@AnonymousAccess
private ResultEntity<String> updateStatus(@RequestParam Integer id,
@ApiParam("传0禁用传1发布上架") @RequestParam int status) {
try {
AdminComponentCodeWithBLOBs adminComponentCodeWithBLOBs = adminComponentCodeMapper.selectByPrimaryKey(id);
adminComponentCodeWithBLOBs.setStatus(status);
adminComponentCodeMapper.updateByPrimaryKeyWithBLOBs(adminComponentCodeWithBLOBs);
} catch (Exception e) {
e.printStackTrace();
return new ResultEntity<>(HttpStatus.INTERNAL_SERVER_ERROR, "发生错误,请联系管理员!");
}
if (status == 0) {
return new ResultEntity<>(HttpStatus.OK, "成功禁用!");
}
if (status == 1) {
return new ResultEntity<>(HttpStatus.OK, "成功发布!");
}
return null;
}
@ApiOperation("后端根据名字创建notebook")
@GetMapping("/createNoteBook")
@AnonymousAccess
public ResultEntity createNoteBook(@ApiParam("参数为:案例名") String name,
@ApiParam("代码内容") String codeContent) {
//判断有无这个案例
//
// String path = "/usr/local/tianzeProject/jupyter/tch";
//
// // 创建表示该目录的 File 对象
// File directory = new File(path);
//
// // 获取目录中的所有文件和子目录
// File[] filesList = directory.listFiles();
//
//
// if (filesList != null) {
// // 使用流查找目标文件
// Optional<File> targetFile = Arrays.stream(filesList)
// .filter(file -> file.getName().equals(name))
// .findFirst();
//
// if (targetFile.isPresent()) {
// return new ResultEntity<>(HttpStatus.OK,"文件已存在");
// }
// }
//没有就创建
AdminJupyterTokenExample tokenExample = new AdminJupyterTokenExample();
tokenExample.createCriteria().andTypeEqualTo(1);
List<AdminJupyterToken> adminJupyterTokenList = adminJupyterTokenMapper.selectByExample(tokenExample);
if (adminJupyterTokenList.isEmpty())
{
return new ResultEntity<>(HttpStatus.BAD_REQUEST,"Token不存在");
}
try (CloseableHttpClient client = HttpClients.createDefault()) {
String notebookContent = "{"
+ "\"cells\": ["
+ "{"
+ "\"cell_type\": \"code\","
+ "\"execution_count\": null,"
+ "\"metadata\": {},"
+ "\"outputs\": [],"
+ "\"source\": ["+codeContent+"]"
+ "},"
// + "{"
// + "\"cell_type\": \"raw\","
// + "\"execution_count\": null,"
// + "\"metadata\": {},"
// + "\"outputs\": [],"
// + "\"source\": [\"print('This is text!')\"]"
// + "},"
+ "{"
+ "\"cell_type\": \"markdown\","
+ "\"metadata\": {},"
+ "\"source\": [\"# Markdown Cell\\n\", \"This is a markdown cell.\"]"
+ "}"
+ "],"
+ "\"metadata\": {"
+ " \"kernelspec\": {"
+ " \"display_name\": \"Python 3\","
+ " \"language\": \"python\","
+ " \"name\": \"python3\""
+ " }"
+ "},"
+ "\"nbformat\": 4,"
+ "\"nbformat_minor\": 2"
+ "}";
// 在根目录下创建新的笔记本
HttpPut createNotebookRequest = new HttpPut(JUPYTER_URL + "/api/contents/"+name+".ipynb");
createNotebookRequest.addHeader("Authorization", "token " + adminJupyterTokenList.get(0).getToken());
createNotebookRequest.addHeader("Content-Type", "application/json");
createNotebookRequest.setEntity(new StringEntity("{\"type\": \"notebook\", \"content\": " + notebookContent + "}"));
try (CloseableHttpResponse createNotebookResponse = client.execute(createNotebookRequest)) {
int statusCode = createNotebookResponse.getStatusLine().getStatusCode();
if (statusCode == 201) {
System.out.println("Notebook created successfully!");
return new ResultEntity<>(HttpStatus.OK,"创建成功!");
} else {
String responseBody = EntityUtils.toString(createNotebookResponse.getEntity());
System.out.println("Failed to create notebook: " + responseBody);
return new ResultEntity<>(HttpStatus.OK,"已经存在,不用重复创建");
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,84 @@
package com.sztzjy.resource_center.controller.new_module.stu;
import cn.hutool.json.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.sztzjy.resource_center.annotation.AnonymousAccess;
import com.sztzjy.resource_center.entity.AdminComponentCode;
import com.sztzjy.resource_center.entity.AdminComponentCodeWithBLOBs;
import com.sztzjy.resource_center.entity.dto.StuCodeDTO;
import com.sztzjy.resource_center.entity.dto.StuComponentCodeDTO;
import com.sztzjy.resource_center.mapper.AdminComponentCodeMapper;
import com.sztzjy.resource_center.util.ConvertUtil;
import com.sztzjy.resource_center.util.ResultEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.codehaus.jackson.JsonFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/**
* @author tz
* @date 2024/7/26 10:13
*/
@RestController
@Api(tags = "学生端组件代码模块")
@RequestMapping("api/stu/componentCode")
public class StuComponentCodeController {
@Resource
AdminComponentCodeMapper adminComponentCodeMapper;
@Resource
ConvertUtil convertUtil;
@PostMapping("/getComponentCode")
@ApiOperation("组件代码展示")
@AnonymousAccess
public ResultEntity getComponentCode(){
//查询所有一级标签
List<String> byCourseName = adminComponentCodeMapper.getByCourseName();
//查询出所有数据
List<AdminComponentCodeWithBLOBs> adminComponentCodes = adminComponentCodeMapper.selectByExampleWithBLOBs(null);
List<StuComponentCodeDTO> componentCodeDTOS=new ArrayList<>();
for (String courseName : byCourseName) {
StuComponentCodeDTO componentCodeDTO=new StuComponentCodeDTO();
componentCodeDTO.setCourseName(courseName);
componentCodeDTOS.add(componentCodeDTO);
}
//遍历
for (StuComponentCodeDTO componentCodeDTO : componentCodeDTOS) {
List<StuCodeDTO> stuCodeDTOS=new ArrayList<>();
for (AdminComponentCodeWithBLOBs adminComponentCode : adminComponentCodes) {
if (adminComponentCode.getCourseName().equals(componentCodeDTO.getCourseName())) {
StuCodeDTO stuCodeDTO = convertUtil.entityToDTO(adminComponentCode, StuCodeDTO.class);
stuCodeDTOS.add(stuCodeDTO);
}
}
componentCodeDTO.setChildren(stuCodeDTOS);
}
return new ResultEntity(HttpStatus.OK,"成功",componentCodeDTOS);
}
}

@ -0,0 +1,77 @@
package com.sztzjy.resource_center.entity;
import java.util.Date;
import io.swagger.annotations.ApiModelProperty;
/**
*
* @author xcj
* admin_component_code
*/
public class AdminComponentCode {
@ApiModelProperty("ID")
private Integer id;
@ApiModelProperty("步骤名称(一级标签)")
private String courseName;
@ApiModelProperty("案例名称(二级标签)")
private String chapterName;
@ApiModelProperty("管理员/学校ID")
private String source;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("0下架 1上架")
private Integer status;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName == null ? null : courseName.trim();
}
public String getChapterName() {
return chapterName;
}
public void setChapterName(String chapterName) {
this.chapterName = chapterName == null ? null : chapterName.trim();
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source == null ? null : source.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

@ -0,0 +1,590 @@
package com.sztzjy.resource_center.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class AdminComponentCodeExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public AdminComponentCodeExample() {
oredCriteria = new ArrayList<>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andCourseNameIsNull() {
addCriterion("course_name is null");
return (Criteria) this;
}
public Criteria andCourseNameIsNotNull() {
addCriterion("course_name is not null");
return (Criteria) this;
}
public Criteria andCourseNameEqualTo(String value) {
addCriterion("course_name =", value, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameNotEqualTo(String value) {
addCriterion("course_name <>", value, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameGreaterThan(String value) {
addCriterion("course_name >", value, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameGreaterThanOrEqualTo(String value) {
addCriterion("course_name >=", value, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameLessThan(String value) {
addCriterion("course_name <", value, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameLessThanOrEqualTo(String value) {
addCriterion("course_name <=", value, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameLike(String value) {
addCriterion("course_name like", value, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameNotLike(String value) {
addCriterion("course_name not like", value, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameIn(List<String> values) {
addCriterion("course_name in", values, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameNotIn(List<String> values) {
addCriterion("course_name not in", values, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameBetween(String value1, String value2) {
addCriterion("course_name between", value1, value2, "courseName");
return (Criteria) this;
}
public Criteria andCourseNameNotBetween(String value1, String value2) {
addCriterion("course_name not between", value1, value2, "courseName");
return (Criteria) this;
}
public Criteria andChapterNameIsNull() {
addCriterion("chapter_name is null");
return (Criteria) this;
}
public Criteria andChapterNameIsNotNull() {
addCriterion("chapter_name is not null");
return (Criteria) this;
}
public Criteria andChapterNameEqualTo(String value) {
addCriterion("chapter_name =", value, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameNotEqualTo(String value) {
addCriterion("chapter_name <>", value, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameGreaterThan(String value) {
addCriterion("chapter_name >", value, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameGreaterThanOrEqualTo(String value) {
addCriterion("chapter_name >=", value, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameLessThan(String value) {
addCriterion("chapter_name <", value, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameLessThanOrEqualTo(String value) {
addCriterion("chapter_name <=", value, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameLike(String value) {
addCriterion("chapter_name like", value, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameNotLike(String value) {
addCriterion("chapter_name not like", value, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameIn(List<String> values) {
addCriterion("chapter_name in", values, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameNotIn(List<String> values) {
addCriterion("chapter_name not in", values, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameBetween(String value1, String value2) {
addCriterion("chapter_name between", value1, value2, "chapterName");
return (Criteria) this;
}
public Criteria andChapterNameNotBetween(String value1, String value2) {
addCriterion("chapter_name not between", value1, value2, "chapterName");
return (Criteria) this;
}
public Criteria andSourceIsNull() {
addCriterion("source is null");
return (Criteria) this;
}
public Criteria andSourceIsNotNull() {
addCriterion("source is not null");
return (Criteria) this;
}
public Criteria andSourceEqualTo(String value) {
addCriterion("source =", value, "source");
return (Criteria) this;
}
public Criteria andSourceNotEqualTo(String value) {
addCriterion("source <>", value, "source");
return (Criteria) this;
}
public Criteria andSourceGreaterThan(String value) {
addCriterion("source >", value, "source");
return (Criteria) this;
}
public Criteria andSourceGreaterThanOrEqualTo(String value) {
addCriterion("source >=", value, "source");
return (Criteria) this;
}
public Criteria andSourceLessThan(String value) {
addCriterion("source <", value, "source");
return (Criteria) this;
}
public Criteria andSourceLessThanOrEqualTo(String value) {
addCriterion("source <=", value, "source");
return (Criteria) this;
}
public Criteria andSourceLike(String value) {
addCriterion("source like", value, "source");
return (Criteria) this;
}
public Criteria andSourceNotLike(String value) {
addCriterion("source not like", value, "source");
return (Criteria) this;
}
public Criteria andSourceIn(List<String> values) {
addCriterion("source in", values, "source");
return (Criteria) this;
}
public Criteria andSourceNotIn(List<String> values) {
addCriterion("source not in", values, "source");
return (Criteria) this;
}
public Criteria andSourceBetween(String value1, String value2) {
addCriterion("source between", value1, value2, "source");
return (Criteria) this;
}
public Criteria andSourceNotBetween(String value1, String value2) {
addCriterion("source not between", value1, value2, "source");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("status is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("status is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(Integer value) {
addCriterion("status =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(Integer value) {
addCriterion("status <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(Integer value) {
addCriterion("status >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(Integer value) {
addCriterion("status >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(Integer value) {
addCriterion("status <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(Integer value) {
addCriterion("status <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<Integer> values) {
addCriterion("status in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<Integer> values) {
addCriterion("status not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(Integer value1, Integer value2) {
addCriterion("status between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(Integer value1, Integer value2) {
addCriterion("status not between", value1, value2, "status");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

@ -0,0 +1,31 @@
package com.sztzjy.resource_center.entity;
import io.swagger.annotations.ApiModelProperty;
/**
*
* @author xcj
* admin_component_code
*/
public class AdminComponentCodeWithBLOBs extends AdminComponentCode {
@ApiModelProperty("代码内容")
private String item;
@ApiModelProperty("参数释义")
private String definition;
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item == null ? null : item.trim();
}
public String getDefinition() {
return definition;
}
public void setDefinition(String definition) {
this.definition = definition == null ? null : definition.trim();
}
}

@ -0,0 +1,16 @@
package com.sztzjy.resource_center.entity.dto;
import lombok.Data;
/**
* @author tz
* @date 2024/7/26 16:16
*/
@Data
public class StuCodeDTO {
private String chapterName;
private String item;
private String definition;
}

@ -0,0 +1,16 @@
package com.sztzjy.resource_center.entity.dto;
import lombok.Data;
import java.util.List;
/**
* @author tz
* @date 2024/7/26 16:14
*/
@Data
public class StuComponentCodeDTO {
private String courseName;
private List<StuCodeDTO> children;
}

@ -0,0 +1,41 @@
package com.sztzjy.resource_center.mapper;
import com.sztzjy.resource_center.entity.AdminComponentCode;
import com.sztzjy.resource_center.entity.AdminComponentCodeExample;
import com.sztzjy.resource_center.entity.AdminComponentCodeWithBLOBs;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface AdminComponentCodeMapper {
long countByExample(AdminComponentCodeExample example);
int deleteByExample(AdminComponentCodeExample example);
int deleteByPrimaryKey(Integer id);
int insert(AdminComponentCodeWithBLOBs record);
int insertSelective(AdminComponentCodeWithBLOBs record);
List<AdminComponentCodeWithBLOBs> selectByExampleWithBLOBs(AdminComponentCodeExample example);
List<AdminComponentCode> selectByExample(AdminComponentCodeExample example);
AdminComponentCodeWithBLOBs selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") AdminComponentCodeWithBLOBs record, @Param("example") AdminComponentCodeExample example);
int updateByExampleWithBLOBs(@Param("record") AdminComponentCodeWithBLOBs record, @Param("example") AdminComponentCodeExample example);
int updateByExample(@Param("record") AdminComponentCode record, @Param("example") AdminComponentCodeExample example);
int updateByPrimaryKeySelective(AdminComponentCodeWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(AdminComponentCodeWithBLOBs record);
int updateByPrimaryKey(AdminComponentCode record);
List<String> getByCourseName();
}

@ -0,0 +1,306 @@
<?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.sztzjy.resource_center.mapper.AdminComponentCodeMapper">
<resultMap id="BaseResultMap" type="com.sztzjy.resource_center.entity.AdminComponentCode">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="course_name" jdbcType="VARCHAR" property="courseName" />
<result column="chapter_name" jdbcType="VARCHAR" property="chapterName" />
<result column="source" jdbcType="VARCHAR" property="source" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="status" jdbcType="INTEGER" property="status" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.sztzjy.resource_center.entity.AdminComponentCodeWithBLOBs">
<result column="item" jdbcType="LONGVARCHAR" property="item" />
<result column="definition" jdbcType="LONGVARCHAR" property="definition" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="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="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">
id, course_name, chapter_name, source, create_time, status
</sql>
<sql id="Blob_Column_List">
item, definition
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.sztzjy.resource_center.entity.AdminComponentCodeExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from admin_component_code
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.sztzjy.resource_center.entity.AdminComponentCodeExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from admin_component_code
<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.Integer" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from admin_component_code
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from admin_component_code
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.resource_center.entity.AdminComponentCodeExample">
delete from admin_component_code
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.resource_center.entity.AdminComponentCodeWithBLOBs">
insert into admin_component_code (id, course_name, chapter_name,
source, create_time, status,
item, definition)
values (#{id,jdbcType=INTEGER}, #{courseName,jdbcType=VARCHAR}, #{chapterName,jdbcType=VARCHAR},
#{source,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER},
#{item,jdbcType=LONGVARCHAR}, #{definition,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.AdminComponentCodeWithBLOBs">
insert into admin_component_code
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="courseName != null">
course_name,
</if>
<if test="chapterName != null">
chapter_name,
</if>
<if test="source != null">
source,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="status != null">
status,
</if>
<if test="item != null">
item,
</if>
<if test="definition != null">
definition,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="courseName != null">
#{courseName,jdbcType=VARCHAR},
</if>
<if test="chapterName != null">
#{chapterName,jdbcType=VARCHAR},
</if>
<if test="source != null">
#{source,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="item != null">
#{item,jdbcType=LONGVARCHAR},
</if>
<if test="definition != null">
#{definition,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.resource_center.entity.AdminComponentCodeExample" resultType="java.lang.Long">
select count(*) from admin_component_code
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update admin_component_code
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.courseName != null">
course_name = #{record.courseName,jdbcType=VARCHAR},
</if>
<if test="record.chapterName != null">
chapter_name = #{record.chapterName,jdbcType=VARCHAR},
</if>
<if test="record.source != null">
source = #{record.source,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.item != null">
item = #{record.item,jdbcType=LONGVARCHAR},
</if>
<if test="record.definition != null">
definition = #{record.definition,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update admin_component_code
set id = #{record.id,jdbcType=INTEGER},
course_name = #{record.courseName,jdbcType=VARCHAR},
chapter_name = #{record.chapterName,jdbcType=VARCHAR},
source = #{record.source,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
status = #{record.status,jdbcType=INTEGER},
item = #{record.item,jdbcType=LONGVARCHAR},
definition = #{record.definition,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update admin_component_code
set id = #{record.id,jdbcType=INTEGER},
course_name = #{record.courseName,jdbcType=VARCHAR},
chapter_name = #{record.chapterName,jdbcType=VARCHAR},
source = #{record.source,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
status = #{record.status,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.resource_center.entity.AdminComponentCodeWithBLOBs">
update admin_component_code
<set>
<if test="courseName != null">
course_name = #{courseName,jdbcType=VARCHAR},
</if>
<if test="chapterName != null">
chapter_name = #{chapterName,jdbcType=VARCHAR},
</if>
<if test="source != null">
source = #{source,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="item != null">
item = #{item,jdbcType=LONGVARCHAR},
</if>
<if test="definition != null">
definition = #{definition,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.sztzjy.resource_center.entity.AdminComponentCodeWithBLOBs">
update admin_component_code
set course_name = #{courseName,jdbcType=VARCHAR},
chapter_name = #{chapterName,jdbcType=VARCHAR},
source = #{source,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER},
item = #{item,jdbcType=LONGVARCHAR},
definition = #{definition,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.sztzjy.resource_center.entity.AdminComponentCode">
update admin_component_code
set course_name = #{courseName,jdbcType=VARCHAR},
chapter_name = #{chapterName,jdbcType=VARCHAR},
source = #{source,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getByCourseName" resultType="java.lang.String">
select DISTINCT course_name from admin_component_code
</select>
</mapper>
Loading…
Cancel
Save