Commit b45e3f72 by wubh

包活干V2.2.0-服务商获取组织列表功能

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@29250 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 6dea1fc7
/* /*
* Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved.
* GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/ */
package com.glsx.usercenter.controller; package com.glsx.usercenter.controller;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.glsx.common.annotation.AuthCheck;
import com.glsx.common.annotation.Log; import com.glsx.common.annotation.Log;
import com.glsx.common.constants.Constants; import com.glsx.common.constants.Constants;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
...@@ -38,62 +22,78 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -38,62 +22,78 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/** /**
* @author Zheng Xiajun * @author Zheng Xiajun
* @ClassName: OrganizationController * @ClassName: OrganizationController
* @Description: TODO(这里用一句话描述这个类的作用)
* @date 2019年1月22日 * @date 2019年1月22日
*/ */
@AuthCheck
@RestController @RestController
@RequestMapping("/organization") @RequestMapping("/organization")
public class OrganizationController extends BaseController { public class OrganizationController extends BaseController {
@Autowired @Autowired
private ISysOrganizationService organizationService; private ISysOrganizationService organizationService;
/**
* 根据条件查询组织结构
*
* @param organization 请求体
* @return 结果
*/
@RequestMapping(value = "/getByParams", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getByParams", method = {RequestMethod.GET, RequestMethod.POST})
public ResultObject getByParams(SysOrganization sysOrganization) { public ResultObject getListByParam(SysOrganization organization) {
logger.info("/getListByParam param: {}", JSON.toJSONString(organization));
SysUser sysUser = ShiroUtil.getUser();
Integer id = sysOrganization.getId(); ResultObject result;
String name = sysOrganization.getName(); SysUser currentUser = ShiroUtil.getUser();
Byte orgStatus = sysOrganization.getOrgStatus(); List<SysOrganization> organizationList = this.organizationService.getListByParam(
organization, currentUser);
result = new ResultObject(ResultCodeEnum.SUCCESS.getCode(),
ResultCodeEnum.SUCCESS.getMsg(), organizationList);
logger.info("接收到的id参数值为:" + id); return result;
if (!StringUtils.isNull(name)) {
name = name.replaceAll(" ", "");
} }
Map<String, Object> map = new HashMap<>(); /**
if (StringUtils.isNull(name) && orgStatus == null && id == null) { * 根据条件查询组织结构
// 菜单状态:1,正常、0.停用、2.注销 *
// 只查询一级菜单 * @param organization 请求体
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), * @return 结果
organizationService.selectByExample(null, null, sysUser)); */
@RequestMapping(value = "/getByParams2", method = {RequestMethod.GET, RequestMethod.POST})
public ResultObject getByParams2(SysOrganization organization) {
logger.info("/getByParams2 param: {}", JSON.toJSONString(organization));
ResultObject result;
SysUser currentUser = ShiroUtil.getUser();
Integer orgId = organization.getId();
String orgName = StringUtils.isNotBlank(organization.getName())
? organization.getName().replaceAll(" ", "") : "";
Byte orgStatus = organization.getOrgStatus();
List<SysOrganization> organizationList;
if (StringUtils.isNotBlank(orgName)) {
// 根据 name 和 orgStatus 搜索
organizationList = organizationService.selectByExample(orgName, orgStatus, currentUser);
} else if (orgId != null && orgStatus != null) {
// 根据 id 和 orgStatus 递归查询子菜单
SysOrganization record = new SysOrganization();
record.setId(orgId);
record.setOrgStatus(orgStatus);
organizationList = organizationService.findOrgByRecord(record);
} else if (orgId != null) {
// 根据 id 递归查询子菜单
organizationList = organizationService.findOrgById(orgId);
} else { } else {
if (StringUtils.isNull(name) && (orgStatus != null || id != null)) { // orgStatus 不为空则根据状态查询,如果为空则只查询一级菜单
if (orgStatus == null) { organizationList = organizationService.selectByExample(null, orgStatus,
// 根据id递归查询子菜单 currentUser);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.findOrgById(id));
} else if (id != null) {
// // 根据id和状态递归查询子菜单
map.put("orgStatus", orgStatus);
map.put("id", id);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.findOrgsByParams(map));
}
}
// 根据名字和状态搜索
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.selectByExample(name, orgStatus, sysUser));
} }
result = new ResultObject(ResultCodeEnum.SUCCESS.getCode(),
ResultCodeEnum.SUCCESS.getMsg(), organizationList);
return result;
} }
@Log(menuName = "系统管理-组织管理", operateType = Constants.SYS_LOG_OPERATE_TYPE_SAVE) @Log(menuName = "系统管理-组织管理", operateType = Constants.SYS_LOG_OPERATE_TYPE_SAVE)
......
package com.glsx.usercenter.mapper; package com.glsx.usercenter.mapper;
import java.util.List;
import com.glsx.usercenter.pojo.menu.SysOrganization; import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample; import com.glsx.usercenter.pojo.menu.SysOrganizationExample;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface SysOrganizationMapper { public interface SysOrganizationMapper {
long countByExample(SysOrganizationExample example); long countByExample(SysOrganizationExample example);
...@@ -31,9 +29,9 @@ public interface SysOrganizationMapper { ...@@ -31,9 +29,9 @@ public interface SysOrganizationMapper {
int updateByPrimaryKey(SysOrganization record); int updateByPrimaryKey(SysOrganization record);
List<SysOrganization> findOrgByParams(Map map); List<SysOrganization> selectByRecord(SysOrganization organization);
List<SysOrganization> findOrgByParentId(@Param("id") Integer id); List<SysOrganization> selectByParentId(@Param("id") Integer id);
List<SysOrganization> getAllGroupByParentId(@Param("id") Integer id, @Param("parentId") Integer parentId); List<SysOrganization> getAllGroupByParentId(@Param("id") Integer id, @Param("parentId") Integer parentId);
......
package com.glsx.usercenter.pojo.menu; package com.glsx.usercenter.pojo.menu;
import com.glsx.usercenter.pojo.user.SysUser;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.glsx.usercenter.pojo.user.SysUser;
public class SysOrganization { public class SysOrganization {
private Integer id; private Integer id;
...@@ -40,34 +39,10 @@ public class SysOrganization { ...@@ -40,34 +39,10 @@ public class SysOrganization {
private List<SysOrganization> children; private List<SysOrganization> children;
private List<SysUser> sysUserList = new ArrayList<>(); private List<SysUser> sysUserList = new ArrayList<>();
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public List<SysOrganization> getChildren() {
return children;
}
public void setChildren(List<SysOrganization> children) {
this.children = children;
}
public Integer getId() { public Integer getId() {
return id; return id;
} }
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
...@@ -85,7 +60,15 @@ public class SysOrganization { ...@@ -85,7 +60,15 @@ public class SysOrganization {
} }
public void setName(String name) { public void setName(String name) {
this.name = name == null ? null : name.trim(); this.name = name;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
} }
public Byte getOrgStatus() { public Byte getOrgStatus() {
...@@ -133,7 +116,7 @@ public class SysOrganization { ...@@ -133,7 +116,7 @@ public class SysOrganization {
} }
public void setRemark(String remark) { public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim(); this.remark = remark;
} }
public Integer getUpdateBy() { public Integer getUpdateBy() {
...@@ -165,7 +148,31 @@ public class SysOrganization { ...@@ -165,7 +148,31 @@ public class SysOrganization {
} }
public void setOrgGroup(String orgGroup) { public void setOrgGroup(String orgGroup) {
this.orgGroup = orgGroup == null ? null : orgGroup.trim(); this.orgGroup = orgGroup;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public List<SysOrganization> getChildren() {
return children;
}
public void setChildren(List<SysOrganization> children) {
this.children = children;
} }
public List<SysUser> getSysUserList() { public List<SysUser> getSysUserList() {
...@@ -176,17 +183,27 @@ public class SysOrganization { ...@@ -176,17 +183,27 @@ public class SysOrganization {
this.sysUserList = sysUserList; this.sysUserList = sysUserList;
} }
/** @Override
* @return the parentName public String toString() {
*/ return "SysOrganization{" +
public String getParentName() { "id=" + id +
return parentName; ", parentId=" + parentId +
} ", name='" + name + '\'' +
", serviceName='" + serviceName + '\'' +
/** ", orgStatus=" + orgStatus +
* @param parentName the parentName to set ", orgType=" + orgType +
*/ ", sort=" + sort +
public void setParentName(String parentName) { ", createTime=" + createTime +
this.parentName = parentName; ", updateTime=" + updateTime +
", remark='" + remark + '\'' +
", updateBy=" + updateBy +
", createBy=" + createBy +
", label=" + label +
", orgGroup='" + orgGroup + '\'' +
", parentName='" + parentName + '\'' +
", phoneNumber='" + phoneNumber + '\'' +
", children=" + children +
", sysUserList=" + sysUserList +
'}';
} }
} }
...@@ -3,14 +3,12 @@ ...@@ -3,14 +3,12 @@
*/ */
package com.glsx.usercenter.service; package com.glsx.usercenter.service;
import java.util.List;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.usercenter.pojo.menu.SysOrganization; import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample; import com.glsx.usercenter.pojo.menu.SysOrganizationExample;
import com.glsx.usercenter.pojo.user.SysUser; import com.glsx.usercenter.pojo.user.SysUser;
import java.util.List;
import java.util.Map;
/** /**
* @author Zheng Xiajun * @author Zheng Xiajun
* @ClassName: ISysOrganizationServic * @ClassName: ISysOrganizationServic
...@@ -24,13 +22,15 @@ public interface ISysOrganizationService { ...@@ -24,13 +22,15 @@ public interface ISysOrganizationService {
ResultObject insertSelective(SysOrganization record, Integer userId); ResultObject insertSelective(SysOrganization record, Integer userId);
List<SysOrganization> selectByExample(String orgName, Byte orgStatus, SysUser sysUser); List<SysOrganization> getListByParam(SysOrganization organization, SysUser user);
List<SysOrganization> selectByExample(String orgName, Byte orgStatus, SysUser user);
SysOrganization selectByPrimaryKey(Integer id); SysOrganization selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SysOrganization record); int updateByPrimaryKeySelective(SysOrganization record);
List<SysOrganization> findOrgsByParams(Map map); List<SysOrganization> findOrgByRecord(SysOrganization record);
List<SysOrganization> findOrgById(Integer id); List<SysOrganization> findOrgById(Integer id);
......
...@@ -155,7 +155,7 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -155,7 +155,7 @@ public class SysUserServiceImpl implements SysUserService {
private List<SysOrganization> getAllOrgByRootId(Integer orgId) { private List<SysOrganization> getAllOrgByRootId(Integer orgId) {
List<SysOrganization> orgList; List<SysOrganization> orgList;
orgList = sysOrganizationMapper.findOrgByParentId(orgId); orgList = sysOrganizationMapper.selectByParentId(orgId);
List<SysOrganization> allOrgList = new ArrayList<>(orgList); List<SysOrganization> allOrgList = new ArrayList<>(orgList);
if (!orgList.isEmpty()) { if (!orgList.isEmpty()) {
for (SysOrganization org : orgList) { for (SysOrganization org : orgList) {
...@@ -505,7 +505,7 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -505,7 +505,7 @@ public class SysUserServiceImpl implements SysUserService {
sysOrganization.setCreateBy(sysMerchant.getCreateBy()); sysOrganization.setCreateBy(sysMerchant.getCreateBy());
sysOrganization.setCreateTime(sysMerchant.getCreateTime()); sysOrganization.setCreateTime(sysMerchant.getCreateTime());
//排序为目前最大排序加1 //排序为目前最大排序加1
List<SysOrganization> sysOrganizations = sysOrganizationMapper.findOrgByParentId(sysMerchant.getOrgId()); List<SysOrganization> sysOrganizations = sysOrganizationMapper.selectByParentId(sysMerchant.getOrgId());
if (sysOrganizations.isEmpty()) { if (sysOrganizations.isEmpty()) {
sysOrganization.setSort(1); sysOrganization.setSort(1);
} else { } else {
......
...@@ -234,11 +234,12 @@ ...@@ -234,11 +234,12 @@
<resultMap id="recursionOrgMap" type="com.glsx.usercenter.pojo.menu.SysOrganization" extends="BaseResultMap"> <resultMap id="recursionOrgMap" type="com.glsx.usercenter.pojo.menu.SysOrganization" extends="BaseResultMap">
<collection property="children" ofType="com.glsx.usercenter.pojo.menu.SysOrganization" <collection property="children" ofType="com.glsx.usercenter.pojo.menu.SysOrganization"
column="{id=id,org_status=,org_status}" column="{id=id, orgStatus=org_status}"
select="findOrgByParams"/> select="selectByRecord"/>
</resultMap> </resultMap>
<select id="findOrgByParams" resultMap="recursionOrgMap" parameterType="java.util.Map"> <select id="selectByRecord" resultMap="recursionOrgMap"
parameterType="com.glsx.usercenter.pojo.menu.SysOrganization">
SELECT SELECT
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from sys_organization WHERE 1=1 from sys_organization WHERE 1=1
...@@ -254,10 +255,10 @@ ...@@ -254,10 +255,10 @@
<resultMap id="recursionOrgResultMap" type="com.glsx.usercenter.pojo.menu.SysOrganization" extends="BaseResultMap"> <resultMap id="recursionOrgResultMap" type="com.glsx.usercenter.pojo.menu.SysOrganization" extends="BaseResultMap">
<collection property="children" ofType="com.glsx.usercenter.pojo.menu.SysOrganization" <collection property="children" ofType="com.glsx.usercenter.pojo.menu.SysOrganization"
column="{id=id,org_status=org_status}" column="{id=id, org_status=org_status}"
select="findOrgByParentId"/> select="selectByParentId"/>
</resultMap> </resultMap>
<select id="findOrgByParentId" resultMap="BaseResultMap"> <select id="selectByParentId" resultMap="BaseResultMap">
SELECT SELECT
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from sys_organization WHERE parent_id = #{id} from sys_organization WHERE parent_id = #{id}
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<result column="username" jdbcType="VARCHAR" property="username"/> <result column="username" jdbcType="VARCHAR" property="username"/>
<result column="name" jdbcType="VARCHAR" property="name"/> <result column="name" jdbcType="VARCHAR" property="name"/>
<result column="org_id" jdbcType="INTEGER" property="orgId"/> <result column="org_id" jdbcType="INTEGER" property="orgId"/>
<result column="group_id" jdbcType="INTEGER" property="groupId"/>
<result column="phone_number" jdbcType="VARCHAR" property="phoneNumber"/> <result column="phone_number" jdbcType="VARCHAR" property="phoneNumber"/>
<result column="user_status" jdbcType="VARCHAR" property="userStatus"/> <result column="user_status" jdbcType="VARCHAR" property="userStatus"/>
<result column="create_by" jdbcType="INTEGER" property="createBy"/> <result column="create_by" jdbcType="INTEGER" property="createBy"/>
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
<result column="username" jdbcType="VARCHAR" property="username"/> <result column="username" jdbcType="VARCHAR" property="username"/>
<result column="name" jdbcType="VARCHAR" property="name"/> <result column="name" jdbcType="VARCHAR" property="name"/>
<result column="org_id" jdbcType="INTEGER" property="orgId"/> <result column="org_id" jdbcType="INTEGER" property="orgId"/>
<result column="group_id" jdbcType="INTEGER" property="groupId"/>
<result column="phone_number" jdbcType="VARCHAR" property="phoneNumber"/> <result column="phone_number" jdbcType="VARCHAR" property="phoneNumber"/>
<result column="user_status" jdbcType="VARCHAR" property="userStatus"/> <result column="user_status" jdbcType="VARCHAR" property="userStatus"/>
<result column="create_by" jdbcType="INTEGER" property="createBy"/> <result column="create_by" jdbcType="INTEGER" property="createBy"/>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!