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.
* GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
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.constants.Constants;
import com.glsx.common.constants.ResultObject;
......@@ -38,62 +22,78 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @author Zheng Xiajun
* @ClassName: OrganizationController
* @Description: TODO(这里用一句话描述这个类的作用)
* @date 2019年1月22日
*/
@AuthCheck
@RestController
@RequestMapping("/organization")
public class OrganizationController extends BaseController {
@Autowired
private ISysOrganizationService organizationService;
/**
* 根据条件查询组织结构
*
* @param organization 请求体
* @return 结果
*/
@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();
ResultObject result;
SysUser currentUser = ShiroUtil.getUser();
List<SysOrganization> organizationList = this.organizationService.getListByParam(
organization, currentUser);
result = new ResultObject(ResultCodeEnum.SUCCESS.getCode(),
ResultCodeEnum.SUCCESS.getMsg(), organizationList);
Integer id = sysOrganization.getId();
String name = sysOrganization.getName();
Byte orgStatus = sysOrganization.getOrgStatus();
logger.info("接收到的id参数值为:" + id);
if (!StringUtils.isNull(name)) {
name = name.replaceAll(" ", "");
}
return result;
}
Map<String, Object> map = new HashMap<>();
if (StringUtils.isNull(name) && orgStatus == null && id == null) {
// 菜单状态:1,正常、0.停用、2.注销
// 只查询一级菜单
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.selectByExample(null, null, sysUser));
/**
* 根据条件查询组织结构
*
* @param organization 请求体
* @return 结果
*/
@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 {
if (StringUtils.isNull(name) && (orgStatus != null || id != null)) {
if (orgStatus == null) {
// 根据id递归查询子菜单
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));
// orgStatus 不为空则根据状态查询,如果为空则只查询一级菜单
organizationList = organizationService.selectByExample(null, orgStatus,
currentUser);
}
result = new ResultObject(ResultCodeEnum.SUCCESS.getCode(),
ResultCodeEnum.SUCCESS.getMsg(), organizationList);
return result;
}
@Log(menuName = "系统管理-组织管理", operateType = Constants.SYS_LOG_OPERATE_TYPE_SAVE)
......
package com.glsx.usercenter.mapper;
import java.util.List;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface SysOrganizationMapper {
long countByExample(SysOrganizationExample example);
......@@ -31,9 +29,9 @@ public interface SysOrganizationMapper {
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);
......@@ -42,4 +40,4 @@ public interface SysOrganizationMapper {
List<Integer> selectOrgByUserId(@Param("userId") Integer userId);
}
\ No newline at end of file
}
package com.glsx.usercenter.pojo.menu;
import com.glsx.usercenter.pojo.user.SysUser;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.glsx.usercenter.pojo.user.SysUser;
public class SysOrganization {
private Integer id;
......@@ -40,34 +39,10 @@ public class SysOrganization {
private List<SysOrganization> children;
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() {
return id;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public void setId(Integer id) {
this.id = id;
}
......@@ -85,7 +60,15 @@ public class SysOrganization {
}
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() {
......@@ -133,7 +116,7 @@ public class SysOrganization {
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
this.remark = remark;
}
public Integer getUpdateBy() {
......@@ -165,7 +148,31 @@ public class SysOrganization {
}
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() {
......@@ -176,17 +183,27 @@ public class SysOrganization {
this.sysUserList = sysUserList;
}
/**
* @return the parentName
*/
public String getParentName() {
return parentName;
}
/**
* @param parentName the parentName to set
*/
public void setParentName(String parentName) {
this.parentName = parentName;
}
}
\ No newline at end of file
@Override
public String toString() {
return "SysOrganization{" +
"id=" + id +
", parentId=" + parentId +
", name='" + name + '\'' +
", serviceName='" + serviceName + '\'' +
", orgStatus=" + orgStatus +
", orgType=" + orgType +
", sort=" + sort +
", createTime=" + createTime +
", updateTime=" + updateTime +
", remark='" + remark + '\'' +
", updateBy=" + updateBy +
", createBy=" + createBy +
", label=" + label +
", orgGroup='" + orgGroup + '\'' +
", parentName='" + parentName + '\'' +
", phoneNumber='" + phoneNumber + '\'' +
", children=" + children +
", sysUserList=" + sysUserList +
'}';
}
}
......@@ -3,14 +3,12 @@
*/
package com.glsx.usercenter.service;
import java.util.List;
import com.glsx.common.constants.ResultObject;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample;
import com.glsx.usercenter.pojo.user.SysUser;
import java.util.List;
import java.util.Map;
/**
* @author Zheng Xiajun
* @ClassName: ISysOrganizationServic
......@@ -24,13 +22,15 @@ public interface ISysOrganizationService {
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);
int updateByPrimaryKeySelective(SysOrganization record);
List<SysOrganization> findOrgsByParams(Map map);
List<SysOrganization> findOrgByRecord(SysOrganization record);
List<SysOrganization> findOrgById(Integer id);
......
......@@ -155,7 +155,7 @@ public class SysUserServiceImpl implements SysUserService {
private List<SysOrganization> getAllOrgByRootId(Integer orgId) {
List<SysOrganization> orgList;
orgList = sysOrganizationMapper.findOrgByParentId(orgId);
orgList = sysOrganizationMapper.selectByParentId(orgId);
List<SysOrganization> allOrgList = new ArrayList<>(orgList);
if (!orgList.isEmpty()) {
for (SysOrganization org : orgList) {
......@@ -505,7 +505,7 @@ public class SysUserServiceImpl implements SysUserService {
sysOrganization.setCreateBy(sysMerchant.getCreateBy());
sysOrganization.setCreateTime(sysMerchant.getCreateTime());
//排序为目前最大排序加1
List<SysOrganization> sysOrganizations = sysOrganizationMapper.findOrgByParentId(sysMerchant.getOrgId());
List<SysOrganization> sysOrganizations = sysOrganizationMapper.selectByParentId(sysMerchant.getOrgId());
if (sysOrganizations.isEmpty()) {
sysOrganization.setSort(1);
} else {
......
......@@ -234,11 +234,12 @@
<resultMap id="recursionOrgMap" type="com.glsx.usercenter.pojo.menu.SysOrganization" extends="BaseResultMap">
<collection property="children" ofType="com.glsx.usercenter.pojo.menu.SysOrganization"
column="{id=id,org_status=,org_status}"
select="findOrgByParams"/>
column="{id=id, orgStatus=org_status}"
select="selectByRecord"/>
</resultMap>
<select id="findOrgByParams" resultMap="recursionOrgMap" parameterType="java.util.Map">
<select id="selectByRecord" resultMap="recursionOrgMap"
parameterType="com.glsx.usercenter.pojo.menu.SysOrganization">
SELECT
<include refid="Base_Column_List"/>
from sys_organization WHERE 1=1
......@@ -254,10 +255,10 @@
<resultMap id="recursionOrgResultMap" type="com.glsx.usercenter.pojo.menu.SysOrganization" extends="BaseResultMap">
<collection property="children" ofType="com.glsx.usercenter.pojo.menu.SysOrganization"
column="{id=id,org_status=org_status}"
select="findOrgByParentId"/>
column="{id=id, org_status=org_status}"
select="selectByParentId"/>
</resultMap>
<select id="findOrgByParentId" resultMap="BaseResultMap">
<select id="selectByParentId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
from sys_organization WHERE parent_id = #{id}
......@@ -295,8 +296,8 @@
FROM sys_organization so
LEFT JOIN sys_user_org suo ON so.id=suo.org_id
WHERE
so.org_status in(1,2)
and suo.user_id= #{userId}
so.org_status in(1,2)
and suo.user_id= #{userId}
</select>
</mapper>
\ No newline at end of file
</mapper>
......@@ -6,6 +6,7 @@
<result column="username" jdbcType="VARCHAR" property="username"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<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="user_status" jdbcType="VARCHAR" property="userStatus"/>
<result column="create_by" jdbcType="INTEGER" property="createBy"/>
......@@ -28,6 +29,7 @@
<result column="username" jdbcType="VARCHAR" property="username"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<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="user_status" jdbcType="VARCHAR" property="userStatus"/>
<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!