diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java new file mode 100644 index 0000000..090650f --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java @@ -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 add(@ApiParam("代码内容") String codeContent, + @ApiParam("参数释义")@RequestParam(required = false) String parameterContent, + @ApiParam("步骤名称(一级标签)") String stepName, + @ApiParam("案例名称(二级标签)") String caseName, + @RequestParam(required = false) List 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 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 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 = adminComponentCodeMapper.selectByExampleWithBLOBs(codeExample); + + PageInfo pageInfo = PageUtil.pageHelper(adminComponentCodeWithBLOBs, index, size); + + + return new ResultEntity<>(HttpStatus.OK, "成功!",pageInfo); + } + + @PostMapping("addFile") + @ApiOperation("编辑/文件单独新增") + @AnonymousAccess + private ResultEntity 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.OK, "上传成功!"); + } + + @PostMapping("deleteFile") + @ApiOperation("编辑/单个数据文件删除") + @AnonymousAccess + private ResultEntity 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.OK, "删除成功!"); + } + + + @PostMapping("updateStatus") + @ApiOperation("发布或禁用") + @AnonymousAccess + private ResultEntity 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 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 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); + } + + + } +} diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuComponentCodeController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuComponentCodeController.java new file mode 100644 index 0000000..6840e00 --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuComponentCodeController.java @@ -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 byCourseName = adminComponentCodeMapper.getByCourseName(); + + //查询出所有数据 + List adminComponentCodes = adminComponentCodeMapper.selectByExampleWithBLOBs(null); + + + List componentCodeDTOS=new ArrayList<>(); + + + for (String courseName : byCourseName) { + StuComponentCodeDTO componentCodeDTO=new StuComponentCodeDTO(); + componentCodeDTO.setCourseName(courseName); + + componentCodeDTOS.add(componentCodeDTO); + } + + //遍历 + for (StuComponentCodeDTO componentCodeDTO : componentCodeDTOS) { + + List 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); + } +} diff --git a/src/main/java/com/sztzjy/resource_center/entity/AdminComponentCode.java b/src/main/java/com/sztzjy/resource_center/entity/AdminComponentCode.java new file mode 100644 index 0000000..50d1d3b --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/entity/AdminComponentCode.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/entity/AdminComponentCodeExample.java b/src/main/java/com/sztzjy/resource_center/entity/AdminComponentCodeExample.java new file mode 100644 index 0000000..7a2002b --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/entity/AdminComponentCodeExample.java @@ -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 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 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 criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List 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 values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List 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 values) { + addCriterion("course_name in", values, "courseName"); + return (Criteria) this; + } + + public Criteria andCourseNameNotIn(List 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 values) { + addCriterion("chapter_name in", values, "chapterName"); + return (Criteria) this; + } + + public Criteria andChapterNameNotIn(List 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 values) { + addCriterion("source in", values, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotIn(List 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 values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List 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 values) { + addCriterion("status in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List 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); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/entity/AdminComponentCodeWithBLOBs.java b/src/main/java/com/sztzjy/resource_center/entity/AdminComponentCodeWithBLOBs.java new file mode 100644 index 0000000..66666db --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/entity/AdminComponentCodeWithBLOBs.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/entity/dto/StuCodeDTO.java b/src/main/java/com/sztzjy/resource_center/entity/dto/StuCodeDTO.java new file mode 100644 index 0000000..74d8e70 --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/entity/dto/StuCodeDTO.java @@ -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; +} diff --git a/src/main/java/com/sztzjy/resource_center/entity/dto/StuComponentCodeDTO.java b/src/main/java/com/sztzjy/resource_center/entity/dto/StuComponentCodeDTO.java new file mode 100644 index 0000000..4610829 --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/entity/dto/StuComponentCodeDTO.java @@ -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 children; +} diff --git a/src/main/java/com/sztzjy/resource_center/mapper/AdminComponentCodeMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/AdminComponentCodeMapper.java new file mode 100644 index 0000000..f97124e --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/mapper/AdminComponentCodeMapper.java @@ -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 selectByExampleWithBLOBs(AdminComponentCodeExample example); + + List 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 getByCourseName(); +} \ No newline at end of file diff --git a/src/main/resources/mapper/AdminComponentCodeMapper.xml b/src/main/resources/mapper/AdminComponentCodeMapper.xml new file mode 100644 index 0000000..22089b4 --- /dev/null +++ b/src/main/resources/mapper/AdminComponentCodeMapper.xml @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, course_name, chapter_name, source, create_time, status + + + item, definition + + + + + + delete from admin_component_code + where id = #{id,jdbcType=INTEGER} + + + delete from admin_component_code + + + + + + 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 into admin_component_code + + + id, + + + course_name, + + + chapter_name, + + + source, + + + create_time, + + + status, + + + item, + + + definition, + + + + + #{id,jdbcType=INTEGER}, + + + #{courseName,jdbcType=VARCHAR}, + + + #{chapterName,jdbcType=VARCHAR}, + + + #{source,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{status,jdbcType=INTEGER}, + + + #{item,jdbcType=LONGVARCHAR}, + + + #{definition,jdbcType=LONGVARCHAR}, + + + + + + update admin_component_code + + + 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}, + + + + + + + + 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} + + + + + + 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} + + + + + + update admin_component_code + + + 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 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 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} + + + + \ No newline at end of file