QyzxAuthController.java 7.94 KB
Newer Older
邓实川 committed
1 2 3 4 5 6
/**  
* <p>Title: QyzxAuthController.java</p>  
* <p>Description: </p>  
* @author dsc  
* @date 2020年5月19日  
* @version 1.0  
7
*/
邓实川 committed
8 9
package cn.timer.api.controller.qyzx;

10 11 12 13 14 15 16 17 18 19 20 21
/**
 * <p>
 * Title: QyzxAuthController.java
 * </p>
 * <p>
 * Description:
 * </p>
 * 
 * @author dsc
 * @date 2020年5月19日
 * @version 1.0
 */
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
//@Transactional
//@RestController
//@Api(tags = "4.2企业中心(账号权限)")
//@RequestMapping(value = "/qyzxAuth", produces = { "application/json" })
//public class QyzxAuthController {
//
//	@Transactional
//	@PostMapping(value = "/addChildAccount")
//	@ApiOperation(value = "新增子账号", httpMethod = "POST", notes = "接口发布说明")
//	@Log(title = "新增-子账号", businessType = BusinessType.INSERT)
//	public Result<QyzxAuthChild> addChildAccount(@CurrentUser UserBean userBean, @RequestParam Integer childEmpNum) {
//		Integer orgCode = userBean.getOrgCode();
//		Integer empNum = userBean.getEmpNum();
//		QyzxAuthAccount qyzxAuthAccount = QyzxAuthAccount.builder().build()
//				.selectOne(new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, orgCode)); // 主账号
//		Integer mainEmpNum = qyzxAuthAccount.getEmpNum();
//		if (!empNum.equals(mainEmpNum))
//			return ResultUtil.error("当前用户没有添加权限");
//		Integer max = qyzxAuthAccount.getMaxChildAccount(); // 最大子账号数量
//		Integer count = QyzxAuthChild.builder().build().selectCount(new QueryWrapper<QyzxAuthChild>().lambda()
//				.eq(QyzxAuthChild::getOrgCode, orgCode).ne(QyzxAuthChild::getIsDel, 1)); // 子账号数量
//		if (count >= max)
//			return ResultUtil.error("子账号数量达到上限");
//		YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
//				.eq(YgglMainEmp::getEmpNum, childEmpNum).eq(YgglMainEmp::getOrgCode, orgCode));
//		if (ygglMainEmp == null)
//			return ResultUtil.error("该确认该员工是否存在");
//
//		Integer jobStatus = ygglMainEmp.getJobStatus();
//		if (jobStatus == 2 || jobStatus == 3)
//			return ResultUtil.error("该员工已离职或离职中");
//
//		QyzxAuthChild oldAuthChild = QyzxAuthChild.builder().build().selectOne(new QueryWrapper<QyzxAuthChild>()
//				.lambda().eq(QyzxAuthChild::getOrgCode, orgCode).eq(QyzxAuthChild::getEmpNum, childEmpNum));
//
//		if (mainEmpNum == childEmpNum)
//			return ResultUtil.error("添加失败,该账号是主账号");
//		if (oldAuthChild != null && oldAuthChild.getIsDel() == 0)
//			return ResultUtil.error("添加失败,该账号已是企业子账号");
//		else if (oldAuthChild != null && oldAuthChild.getIsDel() == 1) {
//			oldAuthChild.setIsDel(0);
//			oldAuthChild.setModifiedTime(new Date());
//			oldAuthChild.setModifiedUser(empNum);
//			oldAuthChild.updateById();
//
//			ygglMainEmp.setIsManager(2);
//			ygglMainEmp.updateById();
//			return ResultUtil.data(oldAuthChild, "添加企业子账号成功");
//		}
//		QyzxAuthChild qyzxAuthChild = new QyzxAuthChild();
//		qyzxAuthChild.setCreatedUser(empNum);
//		qyzxAuthChild.setCreatedTime(new Date());
//		qyzxAuthChild.setEmpNum(childEmpNum);
//		qyzxAuthChild.setOrgCode(orgCode);
//		qyzxAuthChild.setIsDel(0);
////		qyzxAuthChild.setIsOpen(1);
//		qyzxAuthChild.insert();
//
//		ygglMainEmp.setIsManager(2);
//		ygglMainEmp.updateById();
//		return ResultUtil.data(qyzxAuthChild, "添加企业子账号成功");
//	}
//
//	@Transactional
//	@DeleteMapping(value = "/delChildAccount/{childEmpNum}")
//	@ApiOperation(value = "删除子账号", httpMethod = "DELETE", notes = "接口发布说明")
//	@Log(title = "删除-子账号", businessType = BusinessType.DELETE)
//	public Result<String> delChildAccount(@CurrentUser UserBean userBean, @PathVariable Integer childEmpNum) {
//		Integer empNum = userBean.getEmpNum();
//		QyzxAuthAccount qyzxAuthAccount = QyzxAuthAccount.builder().build().selectOne(
//				new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, userBean.getOrgCode()));
//		Integer mainEmpNum = qyzxAuthAccount.getEmpNum();
//		if (!empNum.equals(mainEmpNum))
//			return ResultUtil.error("没有操作权限");
//		if (mainEmpNum.equals(childEmpNum))
//			return ResultUtil.error("企业主账号不能被删除");
//		boolean result = QyzxAuthChild.builder().isDel(1).build().update(
//				new QueryWrapper<QyzxAuthChild>().lambda().eq(QyzxAuthChild::getOrgCode, userBean.getOrgCode()));
//		YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
//				.eq(YgglMainEmp::getEmpNum, childEmpNum).eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()));
//		ygglMainEmp.setIsManager(0);
//		if (result && ygglMainEmp.updateById())
//			return ResultUtil.success("删除成功");
//		return ResultUtil.error("删除失败");
//	}
//
//	@PostMapping(value = "/modifyMaxChild")
//	@ApiOperation(value = "修改子账号最大数量", httpMethod = "POST", notes = "接口发布说明")
//	@Log(title = "修改-子账号最大数量", businessType = BusinessType.UPDATE)
//	public Result<QyzxAuthChild> modifyMaxChild(@CurrentUser UserBean userBean, @RequestParam Integer maxNum) {
//		if (QyzxAuthAccount.builder().maxChildAccount(maxNum).build().update(
//				new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, userBean.getOrgCode())))
//			return ResultUtil.success("修改成功");
//		return ResultUtil.error("修改失败");
//	}
//
//	@GetMapping(value = "/getAll")
//	@ApiOperation(value = "获取全部账号信息", httpMethod = "GET", notes = "接口发布说明")
//	public Result<List<Object>> getAll(@CurrentUser UserBean userBean) {
//		List<Object> list = new ArrayList<Object>();
//
//		Map<String, Object> map = new HashedMap<String, Object>();
//		QyzxAuthAccount qyzxAuthAccount = QyzxAuthAccount.builder().build().selectOne(
//				new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, userBean.getOrgCode())); // 主账号
//		map.put("mainAccount", qyzxAuthAccount);
//
//		List<QyzxAuthChild> childs = QyzxAuthChild.builder().build().selectList(new QueryWrapper<QyzxAuthChild>()
//				.lambda().eq(QyzxAuthChild::getOrgCode, userBean.getOrgCode()).ne(QyzxAuthChild::getIsDel, 1)); // 子账号
//		System.err.println(childs);
//		List<YgglMainEmp> list2 = new ArrayList<YgglMainEmp>();
//		for (QyzxAuthChild qyzxAuthChild : childs) {
//			Integer empNum = qyzxAuthChild.getEmpNum();
//			YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(
//					new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
//							.eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getHeadUrl, YgglMainEmp::getName,
//									YgglMainEmp::getPhone, YgglMainEmp::getEmpNum)); // 子账号员工信息
//			list2.add(ygglMainEmp);
//		}
//		map.put("childAccount", list2);
//		list.add(map);
//
//		return ResultUtil.data(list, "查询成功");
//
//	}
//
//	@GetMapping(value = "/getYgAuth")
//	@ApiOperation(value = "获取全部权限信息", httpMethod = "GET", notes = "接口发布说明")
//	public Result<List<YgglMainEmp>> getYgAuth(@CurrentUser UserBean userBean) {
//		YgglMainEmp main = YgglMainEmp.builder().build()
//				.selectOne(new LambdaQueryWrapper<YgglMainEmp>().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
//						.eq(YgglMainEmp::getIsManager, 1).select(YgglMainEmp::getName, YgglMainEmp::getPhone,
//								YgglMainEmp::getEmpNum, YgglMainEmp::getIsManager));
//
//		List<YgglMainEmp> child = YgglMainEmp.builder().build()
//				.selectList(new LambdaQueryWrapper<YgglMainEmp>().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
//						.eq(YgglMainEmp::getIsManager, 2).select(YgglMainEmp::getName, YgglMainEmp::getPhone,
//								YgglMainEmp::getEmpNum, YgglMainEmp::getIsManager));
//		child.add(main);
//
//		Collections.sort(child, Comparator.comparing(YgglMainEmp::getIsManager));
//		return ResultUtil.data(child, "查询成功");
//	}
//
//}