Commit 20aae729 by fsn

部门管理列表添加父级名称

parent e0f04149
...@@ -9,6 +9,7 @@ import com.stylefeng.guns.common.node.ZTreeNode; ...@@ -9,6 +9,7 @@ import com.stylefeng.guns.common.node.ZTreeNode;
import com.stylefeng.guns.core.log.LogObjectHolder; import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.dao.DeptDao; import com.stylefeng.guns.modular.system.dao.DeptDao;
import com.stylefeng.guns.modular.system.warpper.DeptWarpper;
import com.stylefeng.guns.persistence.dao.DeptMapper; import com.stylefeng.guns.persistence.dao.DeptMapper;
import com.stylefeng.guns.persistence.model.Dept; import com.stylefeng.guns.persistence.model.Dept;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
...@@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 部门控制器 * 部门控制器
...@@ -96,7 +98,8 @@ public class DeptController extends BaseController { ...@@ -96,7 +98,8 @@ public class DeptController extends BaseController {
@RequestMapping(value = "/list") @RequestMapping(value = "/list")
@ResponseBody @ResponseBody
public Object list(String condition) { public Object list(String condition) {
return this.deptDao.list(condition); List<Map<String, Object>> list = this.deptDao.list(condition);
return super.warpObject(new DeptWarpper(list));
} }
/** /**
......
package com.stylefeng.guns.modular.system.dao; package com.stylefeng.guns.modular.system.dao;
import com.stylefeng.guns.common.node.ZTreeNode; import com.stylefeng.guns.common.node.ZTreeNode;
import com.stylefeng.guns.persistence.model.Dept;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 部门dao * 部门dao
...@@ -22,5 +22,5 @@ public interface DeptDao { ...@@ -22,5 +22,5 @@ public interface DeptDao {
*/ */
List<ZTreeNode> tree(); List<ZTreeNode> tree();
List<Dept> list(@Param("condition") String condition); List<Map<String, Object>> list(@Param("condition") String condition);
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
) as open from _dept ) as open from _dept
</select> </select>
<select id="list" resultType="dept"> <select id="list" resultType="map">
select * from _dept select * from _dept
<if test="condition != null and condition != ''"> <if test="condition != null and condition != ''">
where simplename like CONCAT('%',#{condition},'%') or fullname like CONCAT('%',#{condition},'%') where simplename like CONCAT('%',#{condition},'%') or fullname like CONCAT('%',#{condition},'%')
......
package com.stylefeng.guns.modular.system.warpper;
import com.stylefeng.guns.common.constant.factory.ConstantFactory;
import com.stylefeng.guns.common.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.util.ToolUtil;
import java.util.Map;
/**
* 部门列表的包装
*
* @author fengshuonan
* @date 2017年4月25日 18:10:31
*/
public class DeptWarpper extends BaseControllerWarpper {
public DeptWarpper(Object list) {
super(list);
}
@Override
public void warpTheMap(Map<String, Object> map) {
Integer pid = (Integer) map.get("pid");
if (ToolUtil.isEmpty(pid) || pid.equals(0)) {
map.put("pName", "--");
} else {
map.put("pName", ConstantFactory.me().getDeptName(pid));
}
}
}
...@@ -15,7 +15,7 @@ Dept.initColumn = function () { ...@@ -15,7 +15,7 @@ Dept.initColumn = function () {
return [ return [
{field: 'selectItem', radio: true}, {field: 'selectItem', radio: true},
{title: 'id', field: 'id', align: 'center', valign: 'middle'}, {title: 'id', field: 'id', align: 'center', valign: 'middle'},
{title: '父级id', field: 'pid', align: 'center', valign: 'middle'}, {title: '父级部门', field: 'pName', align: 'center', valign: 'middle'},
{title: '部门简称', field: 'simplename', align: 'center', valign: 'middle'}, {title: '部门简称', field: 'simplename', align: 'center', valign: 'middle'},
{title: '部门全称', field: 'fullname', align: 'center', valign: 'middle'}, {title: '部门全称', field: 'fullname', align: 'center', valign: 'middle'},
{title: '排序', field: 'num', align: 'center', valign: 'middle'}, {title: '排序', field: 'num', align: 'center', valign: 'middle'},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment