package com.zbooksoft.gdmis.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.ruili.wcp.web.model.AjaxResponse;
|
import com.ruili.wcp.web.model.ErrorInfo;
|
import com.zbooksoft.gdmis.data.entity.CatAjjxx;
|
import com.zbooksoft.gdmis.data.entity.StudyMaterial;
|
import com.zbooksoft.gdmis.data.entity.StudyType;
|
import com.zbooksoft.gdmis.service.CatAjjxxService;
|
import com.zbooksoft.gdmis.service.StudyMaterialService;
|
import com.zbooksoft.gdmis.service.StudyTypeService;
|
import org.apache.shiro.authz.annotation.RequiresUser;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.servlet.ModelAndView;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @Description:专题
|
* @Author: zhai
|
* @Date: 2024/9/24
|
**/
|
@Controller
|
@RequestMapping("/study")
|
public class StudyController {
|
|
@Autowired
|
StudyMaterialService studyMaterialService;
|
|
@Autowired
|
StudyTypeService studyTypeService;
|
|
@Autowired
|
CatAjjxxService catAjjxxService;
|
|
/**
|
* 处理选择的数据(加入专题)
|
*
|
* @param idList 选中的文件主键列表
|
* @return
|
*/
|
@RequestMapping(value = "/addStudyData")
|
@ResponseBody
|
@RequiresUser
|
public Object dealSelectedDataList(Long studyId, @RequestBody List<Long> idList) {
|
String message = studyMaterialService.addByIdList(studyId, idList);
|
return new AjaxResponse(message);
|
}
|
|
@RequestMapping("studyList")
|
@RequiresUser
|
public ModelAndView studyList() {
|
ModelAndView mav = new ModelAndView("gh/study/studyList");
|
return mav;
|
}
|
|
@RequestMapping(value = "getStudyList", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
|
@ResponseBody
|
@RequiresUser
|
public Object getStudyList(String searchText) {
|
QueryWrapper<StudyType> query = new QueryWrapper<>();
|
|
if (searchText != null && searchText != "") {
|
query.like("type_name", searchText);
|
}
|
query.orderByAsc("id");
|
List<StudyType> list = studyTypeService.list(query);
|
return list;
|
}
|
|
|
@RequestMapping("/getStudyData")
|
@ResponseBody
|
@RequiresUser
|
public Object getStudyData(HttpServletRequest request, HttpServletResponse response, Long id) {
|
try {
|
QueryWrapper<StudyMaterial> studyMaterialQueryWrapper = new QueryWrapper<>();
|
studyMaterialQueryWrapper.eq("type_id", id);
|
studyMaterialQueryWrapper.select("KEY_ID");
|
List<Object> idList = studyMaterialService.listObjs(studyMaterialQueryWrapper);
|
List<CatAjjxx> list = new ArrayList<>();
|
if (idList.size() > 0) {
|
QueryWrapper<CatAjjxx> catAjjxxQueryWrapper = new QueryWrapper<>();
|
catAjjxxQueryWrapper.in("id", idList);
|
list = catAjjxxService.list(catAjjxxQueryWrapper);
|
return new AjaxResponse(list);
|
}
|
return new AjaxResponse(list);
|
|
} catch (Exception e) {
|
return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
|
}
|
}
|
|
}
|