package com.ots.project.exam.controller;
|
|
import com.ots.common.utils.StringUtils;
|
import com.ots.common.utils.poi.ExcelUtil;
|
import com.ots.framework.aspectj.lang.annotation.Log;
|
import com.ots.framework.aspectj.lang.enums.BusinessType;
|
import com.ots.framework.web.controller.BaseController;
|
import com.ots.framework.web.domain.AjaxResult;
|
import com.ots.framework.web.page.TableDataInfo;
|
import com.ots.framework.web.service.DictService;
|
import com.ots.project.exam.domain.TExamLevel;
|
import com.ots.project.exam.service.ITExamLevelService;
|
import com.ots.project.system.dict.domain.DictData;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.ModelMap;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
|
/**
|
* 问卷类型Controller
|
*
|
* @author ots
|
* @date 2019-12-15
|
*/
|
@Controller
|
@RequestMapping("/exam/level")
|
public class TExamLevelController extends BaseController {
|
private String prefix = "exam/level";
|
|
@Autowired
|
private ITExamLevelService tExamLevelService;
|
|
@Autowired
|
private DictService dictService;
|
|
@RequiresPermissions("exam:level:view")
|
@GetMapping()
|
public String level() {
|
return prefix + "/level";
|
}
|
|
/**
|
* 查询问卷类型列表
|
*/
|
@RequiresPermissions("exam:level:list")
|
@PostMapping("/list")
|
@ResponseBody
|
public TableDataInfo list(TExamLevel tExamLevel) {
|
startPage();
|
List<TExamLevel> list = tExamLevelService.selectTExamLevelList(tExamLevel);
|
// 翻译一下 Item Template
|
List<DictData> questionnaireTemplate = dictService.getType("questionnaire_template");
|
Map<String, String> dictMap = questionnaireTemplate.stream().collect(Collectors.toMap(DictData::getDictValue, DictData::getDictLabel));
|
list.stream().forEach(t -> {
|
t.setQuestionTemplateName(dictMap.get(t.getQuestionTemplateId()));
|
});
|
return getDataTable(list);
|
}
|
|
/**
|
* 导出问卷类型列表
|
*/
|
@RequiresPermissions("exam:level:export")
|
@PostMapping("/export")
|
@ResponseBody
|
public AjaxResult export(TExamLevel tExamLevel) {
|
List<TExamLevel> list = tExamLevelService.selectTExamLevelList(tExamLevel);
|
ExcelUtil<TExamLevel> util = new ExcelUtil<TExamLevel>(TExamLevel.class);
|
return util.exportExcel(list, "level");
|
}
|
|
/**
|
* 新增问卷类型
|
*/
|
@GetMapping("/add")
|
public String add(String uuid,ModelMap mmap) {
|
if(StringUtils.isNotBlank(uuid)){
|
List<TExamLevel> tExamLevels = tExamLevelService.selectTExamLevelByUuid(uuid);
|
mmap.put("tExamLevel", tExamLevels.get(0));
|
return prefix + "/add-lan";
|
}
|
return prefix + "/add";
|
}
|
|
/**
|
* 新增保存问卷类型
|
*/
|
@RequiresPermissions("exam:level:add")
|
@Log(title = "问卷类型", businessType = BusinessType.INSERT)
|
@PostMapping("/add")
|
@ResponseBody
|
public AjaxResult addSave(TExamLevel tExamLevel) {
|
TExamLevel tExamLevel1 = this.tExamLevelService.selectTExamLevelByUuidLan(tExamLevel.getUuid(), tExamLevel.getLangType());
|
if (tExamLevel1 != null) {
|
return AjaxResult.error("语言已经存在");
|
}
|
return toAjax(tExamLevelService.insertTExamLevel(tExamLevel));
|
}
|
|
/**
|
* 修改问卷类型
|
*/
|
@GetMapping("/edit/{id}")
|
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
|
TExamLevel tExamLevel = tExamLevelService.selectTExamLevelById(id);
|
mmap.put("tExamLevel", tExamLevel);
|
return prefix + "/edit";
|
}
|
|
/**
|
* 修改保存问卷类型
|
*/
|
@RequiresPermissions("exam:level:edit")
|
@Log(title = "问卷类型", businessType = BusinessType.UPDATE)
|
@PostMapping("/edit")
|
@ResponseBody
|
public AjaxResult editSave(TExamLevel tExamLevel) {
|
return toAjax(tExamLevelService.updateTExamLevel(tExamLevel));
|
}
|
|
/**
|
* 删除问卷类型
|
*/
|
@RequiresPermissions("exam:level:remove")
|
@Log(title = "问卷类型", businessType = BusinessType.DELETE)
|
@PostMapping("/remove")
|
@ResponseBody
|
public AjaxResult remove(String ids) {
|
return toAjax(tExamLevelService.deleteTExamLevelByIds(ids));
|
}
|
}
|