mirror of https://gitee.com/stylefeng/guns
【字典控制器】优化方法,删除不必要的查询和引用
parent
9ff9f10345
commit
f84113b4aa
|
@ -15,38 +15,41 @@ import org.springframework.stereotype.Controller;
|
|||
@ApiResource(name = "字典类型管理相关的界面渲染")
|
||||
public class DictTypeViewController {
|
||||
|
||||
private String PREFIX = "/modular/system/dict/";
|
||||
|
||||
/**
|
||||
* 字典类型管理-字典类型-视图
|
||||
* 字典管理-视图
|
||||
*
|
||||
* @author huangyao
|
||||
* @date 2021/1/6 21:08
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/22 16:09
|
||||
*/
|
||||
@GetResource(name = "字典类型管理-列表-视图", path = "/view/dictType")
|
||||
public String indexView() {
|
||||
//return "/modular/system/dictType/dictType.html";
|
||||
return "/modular/system/dict/dictionary.html";
|
||||
return PREFIX + "dictType.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型管理-添加-视图
|
||||
*
|
||||
* @author huangyao
|
||||
* @date 2021/1/6 21:25
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/22 16:09
|
||||
*/
|
||||
@GetResource(name = "字典类型管理-添加-视图", path = "/view/dictType/addView")
|
||||
public String addView() {
|
||||
return "/modular/system/dict/dictType_add.html";
|
||||
return PREFIX + "dictType_add.html";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 字典类型管理-编辑-视图
|
||||
*
|
||||
* @author huangyao
|
||||
* @date 2021/1/6 21:26
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/22 16:09
|
||||
*/
|
||||
@GetResource(name = "字典类型管理-编辑-视图", path = "/view/dictType/editView")
|
||||
public String editView() {
|
||||
return "/modular/system/dict/dictType_edit.html";
|
||||
return PREFIX + "dictType_edit.html";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,90 +1,53 @@
|
|||
package cn.stylefeng.guns.modular.dict;
|
||||
|
||||
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.service.DictService;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.service.DictTypeService;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 字典视图控制器
|
||||
*
|
||||
* @author huangyao
|
||||
* @date 2021/1/16 19:07
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/22 16:09
|
||||
*/
|
||||
@Controller
|
||||
@ApiResource(name = "字典管理相关的界面渲染")
|
||||
public class DictViewController {
|
||||
|
||||
@Resource
|
||||
private DictService dictService;
|
||||
|
||||
@Resource
|
||||
private DictTypeService dictTypeService;
|
||||
private String PREFIX = "/modular/system/dict/";
|
||||
|
||||
/**
|
||||
* 字典管理-列表-视图
|
||||
*
|
||||
* @author huangyao
|
||||
* @date 2021/1/9 22:37
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/22 16:09
|
||||
*/
|
||||
@GetResource(name = "字典管理-列表-视图", path = "/view/dict")
|
||||
public ModelAndView indexView(ModelAndView view, @RequestParam Long dictTypeId) {
|
||||
SysDictType dictType = dictTypeService.getById(dictTypeId);
|
||||
|
||||
view.addObject("dictTypeId", dictType.getDictTypeId());
|
||||
view.addObject("dictTypeName", dictType.getDictTypeName());
|
||||
view.addObject("dictTypeCode", dictType.getDictTypeCode());
|
||||
view.setViewName("/modular/system/dict/dict.html");
|
||||
|
||||
return view;
|
||||
public String indexView() {
|
||||
return PREFIX + "dict.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典管理-添加-视图
|
||||
*
|
||||
* @author huangyao
|
||||
* @date 2021/1/9 22:37
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/22 16:09
|
||||
*/
|
||||
@GetResource(name = "字典管理-添加-视图", path = "/view/dict/addView")
|
||||
public ModelAndView addView(ModelAndView view, @RequestParam Long dictTypeId) {
|
||||
SysDictType dictType = dictTypeService.getById(dictTypeId);
|
||||
|
||||
view.addObject("dictTypeName", dictType.getDictTypeName());
|
||||
view.addObject("dictTypeId", dictType.getDictTypeId());
|
||||
view.addObject("dictTypeCode", dictType.getDictTypeCode());
|
||||
view.setViewName("/modular/system/dict/dict_add.html");
|
||||
|
||||
return view;
|
||||
public String addView() {
|
||||
return PREFIX + "dict_add.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典管理-编辑-视图
|
||||
*
|
||||
* @author huangyao
|
||||
* @date 2021/1/9 22:38
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/22 16:09
|
||||
*/
|
||||
@GetResource(name = "字典管理-编辑-视图", path = "/view/dict/editView")
|
||||
public ModelAndView editView(ModelAndView view, @RequestParam Long dictId) {
|
||||
SysDict dict = dictService.getById(dictId);
|
||||
|
||||
// 根据字典获取字典类型
|
||||
SysDictType dictType = dictTypeService.getOne(new QueryWrapper<SysDictType>().lambda().eq(SysDictType::getDelFlag, "N")
|
||||
.eq(SysDictType::getDictTypeCode, dict.getDictTypeCode()));
|
||||
|
||||
view.addObject("dictTypeName", dictType.getDictTypeName());
|
||||
view.addObject("dictId", dictId);
|
||||
view.addObject("dictTypeCode", dictType.getDictTypeCode());
|
||||
view.setViewName("/modular/system/dict/dict_edit.html");
|
||||
|
||||
return view;
|
||||
public String editView() {
|
||||
return PREFIX + "dict_edit.html";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue