Commit 9cfcd68e by zhengxj

finish 组织mapper,controller on 20190121 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@16899 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent e143a5c5
...@@ -11,6 +11,8 @@ package com.glsx.manager.constants; ...@@ -11,6 +11,8 @@ package com.glsx.manager.constants;
* *
*/ */
public interface Constants { public interface Constants {
final static int OPERATION_INSERT = 1; final static byte BUTTON = 1;
final static int OPERATION_UPDATE = 2; final static byte MENU = 2;
final static byte CATALOG = 3;
} }
/*
* Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved.
* GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.glsx.manager.controller;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.StringUtils;
import com.glsx.manager.constants.ResultCodeEnum;
import com.glsx.manager.pojo.menu.SysOrganization;
import com.glsx.manager.service.ISysOrganizationService;
/**
* @ClassName: OrganizationController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月22日
*
*/
@RestController
@RequestMapping("/organization")
public class OrganizationController extends BaseController{
@Autowired
private ISysOrganizationService organizationService;
@RequestMapping(value = "/getByParams", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getByParams(Integer id, String name, Byte menuStatus) {
if (!StringUtils.isNull(name)) {
name = name.replaceAll(" ", "");
}
Map map = new HashMap();
if (StringUtils.isNull(name) && menuStatus == null && id == null) {
// 菜单状态:1,正常、0.停用、2.注销
// 只查询一级菜单
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.selectByExample(null, null));
} else {
if (StringUtils.isNull(name) && (menuStatus != null || id != null)) {
if (menuStatus == null) {
// 根据id递归查询子菜单
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.findAllRecursion(id));
} else if (id != null) {
// // 根据id和状态递归查询子菜单
map.put("menu_status", menuStatus);
map.put("id", id);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.findMenuByParams(map));
}
}
// 根据名字和状态搜索
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.selectByExample(name, menuStatus));
}
}
@RequestMapping(value = "/add", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject add(@RequestParam(value = "SysOrganization", required = true) SysOrganization sysOrganization) {
int i = organizationService.insertSelective(sysOrganization);
String msg = i == 0 ? ResultCodeEnum.FAIL.getMsg() : ResultCodeEnum.SUCCESS.getMsg();
int code = i == 0 ? ResultCodeEnum.FAIL.getCode() : ResultCodeEnum.SUCCESS.getCode();
return new ResultObject(code, msg);
}
@RequestMapping(value = "/deleteById", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject deleteById(@RequestParam(value = "id", required = false) Integer id) {
if (id == null) {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.PARAM_ERROR);
}
int i = organizationService.deleteByPrimaryKey(id);
String msg = i == 0 ? ResultCodeEnum.FAIL.getMsg() : ResultCodeEnum.SUCCESS.getMsg();
int code = i == 0 ? ResultCodeEnum.FAIL.getCode() : ResultCodeEnum.SUCCESS.getCode();
return new ResultObject(code, msg);
}
@RequestMapping(value = "/update", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject update(@RequestParam(value = "sysOrganization", required = false) SysOrganization sysOrganization) {
organizationService.updateByPrimaryKeySelective(sysOrganization);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
}
...@@ -15,7 +15,6 @@ public interface SysOrganizationMapper { ...@@ -15,7 +15,6 @@ public interface SysOrganizationMapper {
int deleteByPrimaryKey(Integer id); int deleteByPrimaryKey(Integer id);
int insert(SysOrganization record);
int insertSelective(SysOrganization record); int insertSelective(SysOrganization record);
......
...@@ -32,7 +32,6 @@ public interface ISysMenuService { ...@@ -32,7 +32,6 @@ public interface ISysMenuService {
int updateByPrimaryKey(SysMenu sysMenu); int updateByPrimaryKey(SysMenu sysMenu);
List<SysMenu> getRecordByKeywordRecursive(SysMenuExample example);
List<SysMenu> findMenuByParams(Map map); List<SysMenu> findMenuByParams(Map map);
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
package com.glsx.manager.service; package com.glsx.manager.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.glsx.manager.pojo.menu.SysMenu;
import com.glsx.manager.pojo.menu.SysOrganization; import com.glsx.manager.pojo.menu.SysOrganization;
import com.glsx.manager.pojo.menu.SysOrganizationExample; import com.glsx.manager.pojo.menu.SysOrganizationExample;
...@@ -22,11 +24,14 @@ public interface ISysOrganizationService { ...@@ -22,11 +24,14 @@ public interface ISysOrganizationService {
int insertSelective(SysOrganization record); int insertSelective(SysOrganization record);
List<SysOrganization> selectByExample(SysOrganizationExample example); List<SysOrganization> selectByExample(String orgName,Byte orgStatus);
SysOrganization selectByPrimaryKey(Integer id); SysOrganization selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SysOrganization record); int updateByPrimaryKeySelective(SysOrganization record);
List<SysMenu> findMenuByParams(Map map);
SysMenu findAllRecursion(Integer id);
} }
...@@ -4,54 +4,61 @@ ...@@ -4,54 +4,61 @@
package com.glsx.manager.service.impl; package com.glsx.manager.service.impl;
import java.util.List; import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import com.glsx.manager.mapper.SysOrganizationMapper;
import com.glsx.manager.pojo.menu.SysMenu;
import com.glsx.manager.pojo.menu.SysOrganization; import com.glsx.manager.pojo.menu.SysOrganization;
import com.glsx.manager.pojo.menu.SysOrganizationExample; import com.glsx.manager.pojo.menu.SysOrganizationExample;
import com.glsx.manager.service.ISysOrganizationService; import com.glsx.manager.service.ISysOrganizationService;
/** /**
*
* @ClassName: SysOrganizationServiceImpl * @ClassName: SysOrganizationServiceImpl
* @Description: TODO(这里用一句话描述这个类的作用) * @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun * @author Zheng Xiajun
* @date 2019年1月21日 * @date 2019年1月22日
* *
*/ */
public class SysOrganizationServiceImpl implements ISysOrganizationService{ public class SysOrganizationServiceImpl implements ISysOrganizationService{
/* (non-Javadoc) @Autowired
* @see com.glsx.manager.service.ISysOrganizationService#countByExample(com.glsx.manager.pojo.menu.SysOrganizationExample) private SysOrganizationMapper orgDao;
/**
*
*/ */
@Override @Override
public long countByExample(SysOrganizationExample example) { public long countByExample(SysOrganizationExample example) {
// TODO Auto-generated method stub
return 0; return orgDao.countByExample(example);
} }
/* (non-Javadoc)
* @see com.glsx.manager.service.ISysOrganizationService#deleteByPrimaryKey(java.lang.Integer)
*/
@Override @Override
public int deleteByPrimaryKey(Integer id) { public int deleteByPrimaryKey(Integer id) {
// TODO Auto-generated method stub
return 0; return orgDao.deleteByPrimaryKey(id);
} }
/* (non-Javadoc) /**
* @see com.glsx.manager.service.ISysOrganizationService#insertSelective(com.glsx.manager.pojo.menu.SysOrganization) *
*/ */
@Override @Override
public int insertSelective(SysOrganization record) { public int insertSelective(SysOrganization record) {
// TODO Auto-generated method stub
return 0; return orgDao.insertSelective(record);
} }
/* (non-Javadoc) /**
* @see com.glsx.manager.service.ISysOrganizationService#selectByExample(com.glsx.manager.pojo.menu.SysOrganizationExample) *
*/ */
@Override @Override
public List<SysOrganization> selectByExample(SysOrganizationExample example) { public List<SysOrganization> selectByExample(String orgName,Byte orgStatus) {
// TODO Auto-generated method stub SysOrganizationExample example=new SysOrganizationExample();
return null; return orgDao.selectByExample(example);
} }
/** /**
...@@ -59,8 +66,8 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{ ...@@ -59,8 +66,8 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{
*/ */
@Override @Override
public SysOrganization selectByPrimaryKey(Integer id) { public SysOrganization selectByPrimaryKey(Integer id) {
// TODO Auto-generated method stub
return null; return orgDao.selectByPrimaryKey(id);
} }
/** /**
...@@ -68,8 +75,28 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{ ...@@ -68,8 +75,28 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{
*/ */
@Override @Override
public int updateByPrimaryKeySelective(SysOrganization record) { public int updateByPrimaryKeySelective(SysOrganization record) {
// TODO Auto-generated method stub
return 0; return orgDao.updateByPrimaryKeySelective(record);
}
/* (non-Javadoc)
* @see com.glsx.manager.service.ISysOrganizationService#findMenuByParams(java.util.Map)
*/
@Override
public List<SysMenu> findMenuByParams(Map map) {
return null;
}
/* (non-Javadoc)
* @see com.glsx.manager.service.ISysOrganizationService#findAllRecursion(java.lang.Integer)
*/
@Override
public SysMenu findAllRecursion(Integer id) {
return null;
} }
} }
...@@ -229,4 +229,36 @@ ...@@ -229,4 +229,36 @@
org_group = #{orgGroup,jdbcType=VARCHAR} org_group = #{orgGroup,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<resultMap id="recursionOrgMap" type="com.glsx.manager.pojo.menu.SysOrganization" extends="BaseResultMap" >
<collection property="children" ofType="com.glsx.manager.pojo.menu.SysOrganization" column="{id=id,org_status=,org_status}"
select="findOrgByParams" />
</resultMap>
<select id="findOrgByParams" resultMap="recursionOrgMap" parameterType="java.util.Map" >
SELECT
<include refid="Base_Column_List" />
from sys_organization WHERE 1=1
<if test="id != null">
and parent_id = #{id}
</if>
<if test="orgStatus != null">
and org_status = #{orgStatus}
</if>
ORDER BY
`sort` ASC
</select>
<resultMap id="recursionOrgResultMap" type="com.glsx.manager.pojo.menu.SysOrganization" extends="BaseResultMap" >
<collection property="children" ofType="com.glsx.manager.pojo.menu.SysOrganization" column="{id=id,org_status=org_status}"
select="findOrgByParentId" />
</resultMap>
<select id="findOrgByParentId" resultMap="recursionOrgResultMap">
SELECT
<include refid="Base_Column_List" />
from sys_organization WHERE parent_id = #{id}
and org_status in (0,1)
ORDER BY
`sort` ASC
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!