Commit 2525d85c by zhengxj

finish 新增组织时只能选择该用户管理的组织 on 20190313 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@18468 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent bc68fb13
......@@ -39,6 +39,7 @@ import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.StringUtils;
import com.glsx.usercenter.constants.ResultCodeEnum;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.user.SysUser;
import com.glsx.usercenter.service.ISysOrganizationService;
import com.glsx.usercenter.utils.ShiroUtil;
......@@ -59,6 +60,9 @@ public class OrganizationController extends BaseController{
@RequestMapping(value = "/getByParams", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getByParams(SysOrganization sysOrganization) {
SysUser sysUser = ShiroUtil.getUser();
Integer id = sysOrganization.getId();
String name = sysOrganization.getName();
Byte orgStatus = sysOrganization.getOrgStatus();
......@@ -73,7 +77,7 @@ public class OrganizationController extends BaseController{
// 菜单状态:1,正常、0.停用、2.注销
// 只查询一级菜单
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.selectByExample(null, null));
organizationService.selectByExample(null, null,sysUser));
} else {
if (StringUtils.isNull(name) && (orgStatus != null || id != null)) {
if (orgStatus == null) {
......@@ -90,7 +94,7 @@ public class OrganizationController extends BaseController{
}
// 根据名字和状态搜索
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.selectByExample(name, orgStatus));
organizationService.selectByExample(name, orgStatus,sysUser));
}
}
......
......@@ -39,5 +39,8 @@ public interface SysOrganizationMapper {
List<SysOrganization> getAllGroupByParentId(@Param("id")Integer id,@Param("parentId")Integer parentId);
SysOrganization selectDetailById(Integer id);
List<Integer> selectOrgByUserId(@Param("userId")Integer userId);
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import java.util.Map;
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;
/**
* @ClassName: ISysOrganizationServic
......@@ -24,7 +25,7 @@ public interface ISysOrganizationService {
ResultObject insertSelective(SysOrganization record);
List<SysOrganization> selectByExample(String orgName,Byte orgStatus);
List<SysOrganization> selectByExample(String orgName,Byte orgStatus , SysUser sysUser);
SysOrganization selectByPrimaryKey(Integer id);
......
......@@ -13,6 +13,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.glsx.common.constants.Constants;
import com.glsx.common.constants.ResultCodeEnum;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.StringUtils;
......@@ -20,6 +21,7 @@ import com.glsx.usercenter.mapper.SysOrganizationMapper;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample.Criteria;
import com.glsx.usercenter.pojo.user.SysUser;
import com.glsx.usercenter.service.ISysOrganizationService;
/**
......@@ -115,17 +117,24 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{
*
*/
@Override
public List<SysOrganization> selectByExample(String orgName,Byte orgStatus) {
public List<SysOrganization> selectByExample(String orgName,Byte orgStatus , SysUser sysUser) {
SysOrganizationExample example = new SysOrganizationExample();
Criteria criteria =example.createCriteria();
List<Integer> ids=new ArrayList<>();
if (Constants.USER_TYPE_MANAGER != sysUser.getUserType()) {
ids=orgDao.selectOrgByUserId(sysUser.getId());
if(ids.size()>0){
criteria.andIdIn(ids);
}
}
// TODO 查询当前用户的
List<SysOrganization> resultList = orgDao.selectByExample(example);
// 仅查询一级菜单
if (orgStatus == null && StringUtils.isNull(orgName)) {
example.setOrderByClause("create_time desc");
criteria.andOrgStatusBetween((byte) 0, (byte) 1);
criteria.andOrgStatusBetween((byte)1, (byte) 2);
criteria.andParentIdEqualTo(0);
// TODO 查询当前用户的
return orgDao.selectByExample(example);
......
spring.datasource.name=dev
spring.datasource.url=jdbc:mysql://192.168.0.39:3306/glsx_car_service
spring.datasource.url=jdbc:mysql://14.17.100.222:3307/glsx_car_service
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.password=Msd^*$@online
#spring.datasource.url=jdbc:mysql://192.168.0.39:3306/glsx_car_service
#spring.datasource.username=root
#spring.datasource.password=123456
#spring.datasource.connectionProperties="config.decrypt=true;config.decrypt.key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANj300lzSmW05DuzVoluFG6oza+WlEbv2aYCQA2+pkf0mE4p19UAcxfY/BweOyJ6TBNoY5XebPqoiav5lsKVD6sCAwEAAQ=="
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
......
......@@ -290,4 +290,13 @@
</select>
<select id="selectOrgByUserId" resultType="Integer">
SELECT so.id
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}
</select>
</mapper>
\ 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!