feat(unit): 新增单元管理功能及相关接口
- 新增单元的请求和响应VO类,实现分页查询单元列表 - 新增UnitController,提供单元列表查询、添加和删除API接口 - 实现UnitService及其实现类,完成单元相关数据库操作和业务逻辑 - 扩展UnitDOMapper及对应XML,实现单元列表和数量查询功能 - 扩展GradeUnitDOMapper,支持单元与年级关联的插入与删除 - 在enlish-vue中新增单元列表展示、分页、删除及新增对话框功能 - 编写AddUnitDialog组件,实现新增单元UI及逻辑 - 新增unit.js接口封装单元相关的API请求 - 注释掉LessonPlansServiceImpl中的导出Word文档相关代码逻辑调整 - 调整class.vue页面样式和布局,集成单元管理模块并优化查询交互
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package com.yinlihupo.enlish.service.controller;
|
||||
|
||||
import com.yinlihupo.enlish.service.domain.dataobject.UnitDO;
|
||||
import com.yinlihupo.enlish.service.model.vo.unit.AddUnitReqVO;
|
||||
import com.yinlihupo.enlish.service.model.vo.unit.DeleteUnitReqVO;
|
||||
import com.yinlihupo.enlish.service.model.vo.unit.FindUnitListReqVO;
|
||||
import com.yinlihupo.enlish.service.model.vo.unit.FindUnitListRspVO;
|
||||
import com.yinlihupo.enlish.service.service.UnitService;
|
||||
import com.yinlihupo.framework.biz.operationlog.aspect.ApiOperationLog;
|
||||
import com.yinlihupo.framework.common.response.PageResponse;
|
||||
import com.yinlihupo.framework.common.response.Response;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping("/unit/")
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class UnitController {
|
||||
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@PostMapping("/list")
|
||||
@ApiOperationLog(description = "查询单元")
|
||||
public PageResponse<FindUnitListRspVO> list(@RequestBody FindUnitListReqVO findUnitListReqVO) {
|
||||
Integer page = findUnitListReqVO.getPage();
|
||||
Integer size = findUnitListReqVO.getSize();
|
||||
Integer unitDOListCount = unitService.findUnitDOListCount();
|
||||
|
||||
List<UnitDO> unitDOList = unitService.findUnitDOList(page, size);
|
||||
List<FindUnitListRspVO> findUnitListRspVOS = unitDOList.stream().map(unitDO -> FindUnitListRspVO.builder()
|
||||
.id(unitDO.getId())
|
||||
.title(unitDO.getTitle())
|
||||
.version(unitDO.getVersion())
|
||||
.createAt(unitDO.getCreateAt())
|
||||
.build()
|
||||
).toList();
|
||||
|
||||
return PageResponse.success(findUnitListRspVOS, page, unitDOListCount, size);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperationLog(description = "添加单元")
|
||||
public Response<Void> add(@RequestBody AddUnitReqVO addUnitReqVO) {
|
||||
try {
|
||||
unitService.add(addUnitReqVO);
|
||||
|
||||
return Response.success();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Response.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperationLog(description = "删除单元")
|
||||
public Response<String> delete(@RequestBody DeleteUnitReqVO deleteUnitReqVO) {
|
||||
try {
|
||||
unitService.delete(deleteUnitReqVO.getId());
|
||||
|
||||
return Response.success();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Response.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,8 @@ public interface GradeUnitDOMapper {
|
||||
List<Integer> selectUnitIdsByGradeId(@Param("gradeId") Integer gradeId);
|
||||
|
||||
GradeUnitDO selectByUnitId(@Param("unitId") Integer unitId);
|
||||
|
||||
int insert(GradeUnitDO record);
|
||||
|
||||
int deleteByUnitId(@Param("unitId") Integer unitId);
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.yinlihupo.enlish.service.domain.mapper;
|
||||
|
||||
import com.yinlihupo.enlish.service.domain.dataobject.UnitDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UnitDOMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
@@ -18,4 +21,8 @@ public interface UnitDOMapper {
|
||||
int updateByPrimaryKey(UnitDO record);
|
||||
|
||||
UnitDO selectByTitle(String title);
|
||||
|
||||
List<UnitDO> selectUnitDOList(@Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize);
|
||||
|
||||
Integer selectUnitDOListCount();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yinlihupo.enlish.service.model.vo.unit;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Builder
|
||||
public class AddUnitReqVO {
|
||||
|
||||
private String title;
|
||||
private Integer gradeId;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yinlihupo.enlish.service.model.vo.unit;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Builder
|
||||
public class DeleteUnitReqVO {
|
||||
|
||||
private Integer id;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yinlihupo.enlish.service.model.vo.unit;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Builder
|
||||
public class FindUnitListReqVO {
|
||||
|
||||
private Integer page;
|
||||
private Integer size;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.yinlihupo.enlish.service.model.vo.unit;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Builder
|
||||
public class FindUnitListRspVO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 年级/单元
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createAt;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yinlihupo.enlish.service.service;
|
||||
|
||||
import com.yinlihupo.enlish.service.domain.dataobject.UnitDO;
|
||||
import com.yinlihupo.enlish.service.model.vo.unit.AddUnitReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UnitService {
|
||||
|
||||
List<UnitDO> findUnitDOList(Integer page, Integer size);
|
||||
|
||||
Integer findUnitDOListCount();
|
||||
|
||||
void add(AddUnitReqVO addUnitReqVO);
|
||||
|
||||
void delete(Integer id);
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.yinlihupo.enlish.service.service.plan;
|
||||
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||
import com.yinlihupo.enlish.service.constant.LessonPlanConstant;
|
||||
import com.yinlihupo.enlish.service.domain.dataobject.*;
|
||||
import com.yinlihupo.enlish.service.domain.mapper.*;
|
||||
@@ -11,12 +8,12 @@ import com.yinlihupo.enlish.service.utils.DifyArticleClient;
|
||||
import com.yinlihupo.enlish.service.utils.StringToPlanMapUtil;
|
||||
import com.yinlihupo.framework.common.util.JsonUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -151,6 +148,8 @@ public class LessonPlansServiceImpl implements LessonPlansService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Map<String, Object> generateWeekendPlans(List<VocabularyBankDO> checkList,
|
||||
int day,
|
||||
GradeDO gradeDO, UnitDO unitDO, Integer studentId) throws IOException {
|
||||
@@ -158,14 +157,14 @@ public class LessonPlansServiceImpl implements LessonPlansService {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("title", "第" + day + "天" + "复习" + gradeDO.getTitle() + unitDO.getTitle() + studentId);
|
||||
data.put("checkList", checkList);
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
Configure config = Configure.builder()
|
||||
.bind("checkList", policy)
|
||||
.build();
|
||||
|
||||
XWPFTemplate template = XWPFTemplate.compile(planWeekend, config);
|
||||
template.render(data);
|
||||
template.writeAndClose(new FileOutputStream("C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\tmp\\word" + "复习" + day + ".docx"));
|
||||
// LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
// Configure config = Configure.builder()
|
||||
// .bind("checkList", policy)
|
||||
// .build();
|
||||
//
|
||||
// XWPFTemplate template = XWPFTemplate.compile(planWeekend, config);
|
||||
// template.render(data);
|
||||
// template.writeAndClose(new FileOutputStream("C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\tmp\\word" + "复习" + day + ".docx"));
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -229,22 +228,22 @@ public class LessonPlansServiceImpl implements LessonPlansService {
|
||||
data.put("articleBans", mapB.get(LessonPlanConstant.ANSWER_KEY_EXPLANATION));
|
||||
data.put("articleBtran", mapB.get(LessonPlanConstant.FULL_TRANSLATION));
|
||||
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
Configure config = Configure.builder()
|
||||
.bind("syncVocabList", policy)
|
||||
.bind("gapVocabList", policy)
|
||||
.bind("reviewVocabList", policy)
|
||||
.bind("drillRound1", policy)
|
||||
.bind("drillRound2", policy)
|
||||
.bind("drillRound3", policy)
|
||||
.bind("mixedDrill", policy)
|
||||
.bind("checkList", policy)
|
||||
.bind("checkListAns", policy)
|
||||
.build();
|
||||
|
||||
XWPFTemplate template = XWPFTemplate.compile(planWeekday, config);
|
||||
template.render(data);
|
||||
template.writeAndClose(new FileOutputStream("C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\tmp\\word" + title + ".docx"));
|
||||
// LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
// Configure config = Configure.builder()
|
||||
// .bind("syncVocabList", policy)
|
||||
// .bind("gapVocabList", policy)
|
||||
// .bind("reviewVocabList", policy)
|
||||
// .bind("drillRound1", policy)
|
||||
// .bind("drillRound2", policy)
|
||||
// .bind("drillRound3", policy)
|
||||
// .bind("mixedDrill", policy)
|
||||
// .bind("checkList", policy)
|
||||
// .bind("checkListAns", policy)
|
||||
// .build();
|
||||
//
|
||||
// XWPFTemplate template = XWPFTemplate.compile(planWeekday, config);
|
||||
// template.render(data);
|
||||
// template.writeAndClose(new FileOutputStream("C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\tmp\\word" + title + ".docx"));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.yinlihupo.enlish.service.service.unit;
|
||||
|
||||
import com.yinlihupo.enlish.service.domain.dataobject.GradeUnitDO;
|
||||
import com.yinlihupo.enlish.service.domain.dataobject.UnitDO;
|
||||
import com.yinlihupo.enlish.service.domain.mapper.GradeUnitDOMapper;
|
||||
import com.yinlihupo.enlish.service.domain.mapper.UnitDOMapper;
|
||||
import com.yinlihupo.enlish.service.model.vo.unit.AddUnitReqVO;
|
||||
import com.yinlihupo.enlish.service.service.UnitService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UnitServiceImpl implements UnitService {
|
||||
|
||||
@Resource
|
||||
private UnitDOMapper unitDOMapper;
|
||||
@Resource
|
||||
private GradeUnitDOMapper gradeUnitDOMapper;
|
||||
|
||||
@Override
|
||||
public List<UnitDO> findUnitDOList(Integer page, Integer size) {
|
||||
return unitDOMapper.selectUnitDOList((page - 1) * size, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer findUnitDOListCount() {
|
||||
return unitDOMapper.selectUnitDOListCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(AddUnitReqVO addUnitReqVO) {
|
||||
|
||||
UnitDO unitDO = UnitDO.builder()
|
||||
.title(addUnitReqVO.getTitle())
|
||||
.createAt(LocalDateTime.now())
|
||||
.build();
|
||||
unitDOMapper.insertSelective(unitDO);
|
||||
|
||||
Integer gradeId = addUnitReqVO.getGradeId();
|
||||
gradeUnitDOMapper.insert(GradeUnitDO.builder().gradeId(gradeId).unitId(unitDO.getId()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Integer id) {
|
||||
unitDOMapper.deleteByPrimaryKey(id);
|
||||
gradeUnitDOMapper.deleteByUnitId(id);
|
||||
}
|
||||
}
|
||||
@@ -19,5 +19,13 @@
|
||||
where unit_id = #{unitId}
|
||||
</select>
|
||||
|
||||
<insert id="insert">
|
||||
insert into grade_unit (grade_id, unit_id)
|
||||
values (#{gradeId}, #{unitId})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByUnitId">
|
||||
delete from grade_unit
|
||||
where unit_id = #{unitId}
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -91,4 +91,15 @@
|
||||
where title = #{title}
|
||||
</select>
|
||||
|
||||
<select id="selectUnitDOList" resultMap="BaseResultMap">
|
||||
select *
|
||||
from unit
|
||||
limit #{startIndex}, #{pageSize}
|
||||
</select>
|
||||
|
||||
<select id="selectUnitDOListCount" resultType="java.lang.Integer">
|
||||
select count(*)
|
||||
from unit
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user