【字典控制器】优化方法,删除不必要的查询和引用

pull/64/head
chenjinlong 2021-01-22 16:14:30 +08:00
parent 9ff9f10345
commit f84113b4aa
2 changed files with 29 additions and 63 deletions

View File

@ -15,38 +15,41 @@ import org.springframework.stereotype.Controller;
@ApiResource(name = "字典类型管理相关的界面渲染") @ApiResource(name = "字典类型管理相关的界面渲染")
public class DictTypeViewController { public class DictTypeViewController {
private String PREFIX = "/modular/system/dict/";
/** /**
* -- * -
* *
* @author huangyao * @author chenjinlong
* @date 2021/1/6 21:08 * @date 2021/1/22 16:09
*/ */
@GetResource(name = "字典类型管理-列表-视图", path = "/view/dictType") @GetResource(name = "字典类型管理-列表-视图", path = "/view/dictType")
public String indexView() { public String indexView() {
//return "/modular/system/dictType/dictType.html"; return PREFIX + "dictType.html";
return "/modular/system/dict/dictionary.html";
} }
/** /**
* -- * --
* *
* @author huangyao * @author chenjinlong
* @date 2021/1/6 21:25 * @date 2021/1/22 16:09
*/ */
@GetResource(name = "字典类型管理-添加-视图", path = "/view/dictType/addView") @GetResource(name = "字典类型管理-添加-视图", path = "/view/dictType/addView")
public String addView() { public String addView() {
return "/modular/system/dict/dictType_add.html"; return PREFIX + "dictType_add.html";
} }
/** /**
* -- * --
* *
* @author huangyao * @author chenjinlong
* @date 2021/1/6 21:26 * @date 2021/1/22 16:09
*/ */
@GetResource(name = "字典类型管理-编辑-视图", path = "/view/dictType/editView") @GetResource(name = "字典类型管理-编辑-视图", path = "/view/dictType/editView")
public String editView() { public String editView() {
return "/modular/system/dict/dictType_edit.html"; return PREFIX + "dictType_edit.html";
} }
} }

View File

@ -1,90 +1,53 @@
package cn.stylefeng.guns.modular.dict; 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.ApiResource;
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource; 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.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
/** /**
* *
* *
* @author huangyao * @author chenjinlong
* @date 2021/1/16 19:07 * @date 2021/1/22 16:09
*/ */
@Controller @Controller
@ApiResource(name = "字典管理相关的界面渲染") @ApiResource(name = "字典管理相关的界面渲染")
public class DictViewController { public class DictViewController {
@Resource
private DictService dictService;
@Resource private String PREFIX = "/modular/system/dict/";
private DictTypeService dictTypeService;
/** /**
* -- * --
* *
* @author huangyao * @author chenjinlong
* @date 2021/1/9 22:37 * @date 2021/1/22 16:09
*/ */
@GetResource(name = "字典管理-列表-视图", path = "/view/dict") @GetResource(name = "字典管理-列表-视图", path = "/view/dict")
public ModelAndView indexView(ModelAndView view, @RequestParam Long dictTypeId) { public String indexView() {
SysDictType dictType = dictTypeService.getById(dictTypeId); return PREFIX + "dict.html";
view.addObject("dictTypeId", dictType.getDictTypeId());
view.addObject("dictTypeName", dictType.getDictTypeName());
view.addObject("dictTypeCode", dictType.getDictTypeCode());
view.setViewName("/modular/system/dict/dict.html");
return view;
} }
/** /**
* -- * --
* *
* @author huangyao * @author chenjinlong
* @date 2021/1/9 22:37 * @date 2021/1/22 16:09
*/ */
@GetResource(name = "字典管理-添加-视图", path = "/view/dict/addView") @GetResource(name = "字典管理-添加-视图", path = "/view/dict/addView")
public ModelAndView addView(ModelAndView view, @RequestParam Long dictTypeId) { public String addView() {
SysDictType dictType = dictTypeService.getById(dictTypeId); return PREFIX + "dict_add.html";
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;
} }
/** /**
* -- * --
* *
* @author huangyao * @author chenjinlong
* @date 2021/1/9 22:38 * @date 2021/1/22 16:09
*/ */
@GetResource(name = "字典管理-编辑-视图", path = "/view/dict/editView") @GetResource(name = "字典管理-编辑-视图", path = "/view/dict/editView")
public ModelAndView editView(ModelAndView view, @RequestParam Long dictId) { public String editView() {
SysDict dict = dictService.getById(dictId); return PREFIX + "dict_edit.html";
// 根据字典获取字典类型
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;
} }
} }