Commit ad4d289f by 邓实川

权限重新做

parent 1be1a397
...@@ -27,12 +27,15 @@ public class QyzxEmpEntAsso extends Model<QyzxEmpEntAsso> { ...@@ -27,12 +27,15 @@ public class QyzxEmpEntAsso extends Model<QyzxEmpEntAsso> {
@ApiModelProperty(value="组织机构代码 组织机构代码",example="101") @ApiModelProperty(value="组织机构代码 组织机构代码",example="101")
private Integer orgCode; private Integer orgCode;
@ApiModelProperty(value="用户类型 1 超管理员 2子管理 3 普通员工",example="101") @ApiModelProperty(value="用户类型 0 超管理员 1子管理 2 普通员工",example="101")
private Integer userType; private Integer userType;
@ApiModelProperty(value="用户状态",example="1") @ApiModelProperty(value="用户状态",example="1")
private Integer status; private Integer status;
@ApiModelProperty(value="最大数量",example="10")
private Integer maxNum;
@ApiModelProperty(value="为0的id",example="0") @ApiModelProperty(value="为0的id",example="0")
private Integer id; private Integer id;
} }
\ No newline at end of file
...@@ -37,7 +37,6 @@ import cn.timer.api.bean.qyzx.QyzxEmpEntAsso; ...@@ -37,7 +37,6 @@ import cn.timer.api.bean.qyzx.QyzxEmpEntAsso;
import cn.timer.api.bean.qyzx.QyzxEmpLogin; import cn.timer.api.bean.qyzx.QyzxEmpLogin;
import cn.timer.api.bean.qyzx.QyzxEntInfoM; import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import cn.timer.api.bean.qyzx.QyzxSms; import cn.timer.api.bean.qyzx.QyzxSms;
import cn.timer.api.bean.qyzx.auth.QyzxAuthAccount;
import cn.timer.api.bean.qyzx.businessService.QyzxRemainingQuantity; import cn.timer.api.bean.qyzx.businessService.QyzxRemainingQuantity;
import cn.timer.api.bean.yggl.YgglMainEmp; import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.bean.zzgl.ZzglAuth; import cn.timer.api.bean.zzgl.ZzglAuth;
...@@ -513,8 +512,7 @@ public class LoginController { ...@@ -513,8 +512,7 @@ public class LoginController {
System.err.println("kanxia"); System.err.println("kanxia");
// 员工信息 // 员工信息
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(phone).pw(Md5.md5(pw)) QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(phone).pw(Md5.md5(pw))
.sts(CommonEnum.U_STS_ON.getType()).orgId(qyId).regTime(DateUtil.date()) .sts(CommonEnum.U_STS_ON.getType()).orgId(qyId).regTime(DateUtil.date()).build();
.build();
boolean b2 = qyzxEmpLogin.insert(); boolean b2 = qyzxEmpLogin.insert();
if (!b2) { if (!b2) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
...@@ -523,18 +521,17 @@ public class LoginController { ...@@ -523,18 +521,17 @@ public class LoginController {
login = qyzxEmpLogin; login = qyzxEmpLogin;
} }
// 1-是主账号管理员 // 1-是主账号管理员
boolean b4 = YgglMainEmp.builder().orgCode(qyId).empNum(login.getId()).rzTime(new Date()) boolean b4 = YgglMainEmp.builder().orgCode(qyId).empNum(login.getId()).rzTime(new Date()).isManager(1)
.isManager(1).name(username).phone(phone) .name(username).phone(phone).jobType(YgJobType.QUANZHI.getType())
.jobType(YgJobType.QUANZHI.getType()).jobStatus(YgEnumInterface.jobStatus.ZHENSHI.getType()).build() .jobStatus(YgEnumInterface.jobStatus.ZHENSHI.getType()).build().insert();
.insert();
if (!b4) { if (!b4) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ResultUtil.error("注册企业失败3"); return ResultUtil.error("注册企业失败3");
} }
// 员工企业关联表 // 员工企业关联表 // 主账号权限
QyzxEmpEntAsso qyzxEmpEntAsso = QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(qyzxEntInfoM.getId()) QyzxEmpEntAsso qyzxEmpEntAsso = QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(qyzxEntInfoM.getId())
.status(1).userType(SysRoleType.U_TYPE_ADMIN.getType()).build(); .maxNum(10).status(1).userType(SysRoleType.U_TYPE_ADMIN.getType()).build();
boolean b3 = qyzxEmpEntAsso.insert(); boolean b3 = qyzxEmpEntAsso.insert();
if (!b3) { if (!b3) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
...@@ -543,35 +540,31 @@ public class LoginController { ...@@ -543,35 +540,31 @@ public class LoginController {
SpmkService.createCustomApproval(qyzxEntInfoM.getId()); SpmkService.createCustomApproval(qyzxEntInfoM.getId());
QyzxAuthAccount.builder().createdTime(new Date()).maxChildAccount(maxChildAccount).name(username) // *****************************考勤假期初始化
.accountPhone(phone).empNum(login.getId()).orgCode(qyzxEntInfoM.getId()).build().insert(); // TODO // 获取模板数据
// 主账号权限表 List<KqglAssoLeaveRules> ruless = new LambdaQueryChainWrapper<KqglAssoLeaveRules>(kqglassoleaverulesmapper)
.eq(KqglAssoLeaveRules::getOrgCode, 0).list();
// 查询当前公司是否已初始化
//*****************************考勤假期初始化 KqglAssoLeaveRules rule = kqglassoleaverulesmapper.selectOne(new QueryWrapper<KqglAssoLeaveRules>().lambda()
//获取模板数据 .eq(KqglAssoLeaveRules::getOrgCode, qyzxEntInfoM.getId()).eq(KqglAssoLeaveRules::getLeaveType, 1)
List<KqglAssoLeaveRules> ruless = new LambdaQueryChainWrapper<KqglAssoLeaveRules>(kqglassoleaverulesmapper).eq(KqglAssoLeaveRules::getOrgCode, 0).list(); .last("LIMIT 1"));
//查询当前公司是否已初始化 if (rule == null) {
KqglAssoLeaveRules rule = kqglassoleaverulesmapper.selectOne(new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getOrgCode, qyzxEntInfoM.getId())
.eq(KqglAssoLeaveRules::getLeaveType, 1).last("LIMIT 1"));
if(rule == null) {
List<KqglAssoLeaveRules> rullist = new ArrayList<KqglAssoLeaveRules>(); List<KqglAssoLeaveRules> rullist = new ArrayList<KqglAssoLeaveRules>();
for(KqglAssoLeaveRules rul : ruless){ for (KqglAssoLeaveRules rul : ruless) {
KqglAssoLeaveRules vice = KqglAssoLeaveRules.builder().name(rul.getName()).company(rul.getCompany()).leaveType(rul.getLeaveType()) KqglAssoLeaveRules vice = KqglAssoLeaveRules.builder().name(rul.getName()).company(rul.getCompany())
.apply(rul.getApply()).createTime(new Date().getTime()).createUserid(999).orgCode(qyzxEntInfoM.getId()) .leaveType(rul.getLeaveType()).apply(rul.getApply()).createTime(new Date().getTime())
.isOpen(rul.getIsOpen()).leaveBalance(rul.getLeaveBalance()).rulesType(rul.getRulesType()).build(); .createUserid(999).orgCode(qyzxEntInfoM.getId()).isOpen(rul.getIsOpen())
.leaveBalance(rul.getLeaveBalance()).rulesType(rul.getRulesType()).build();
rullist.add(vice); rullist.add(vice);
} }
if(rullist.size() > 0) { if (rullist.size() > 0) {
kqglassoleaverulesmapper.insertleaverulesList(rullist); kqglassoleaverulesmapper.insertleaverulesList(rullist);
} }
System.out.println("操作成功!"); System.out.println("操作成功!");
}else { } else {
System.out.println("重复初始化数据!"); System.out.println("重复初始化数据!");
} }
return ResultUtil.success("注册企业成功"); return ResultUtil.success("注册企业成功");
} catch (Exception e) { } catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
...@@ -620,13 +613,12 @@ public class LoginController { ...@@ -620,13 +613,12 @@ public class LoginController {
e.printStackTrace(); e.printStackTrace();
} }
Integer isLeader = zzglBmgwMMapper.selectCount(new QueryWrapper<ZzglBmgwM>().lambda() Integer isLeader = zzglBmgwMMapper
.eq(ZzglBmgwM::getLeader, qyzxEmpLogin1.getId()) .selectCount(new QueryWrapper<ZzglBmgwM>().lambda().eq(ZzglBmgwM::getLeader, qyzxEmpLogin1.getId())
.eq(ZzglBmgwM::getOrgCode, qyzxEmpLogin1.getOrgId())) > 0 ? 0 : 1; .eq(ZzglBmgwM::getOrgCode, qyzxEmpLogin1.getOrgId())) > 0 ? 0 : 1;
QyzxEmpEntAsso eEA = qyzxEmpEntAssoMapper.selectOne(new QueryWrapper<QyzxEmpEntAsso>().lambda() QyzxEmpEntAsso eEA = qyzxEmpEntAssoMapper.selectOne(new QueryWrapper<QyzxEmpEntAsso>().lambda()
.select(QyzxEmpEntAsso::getUserType) .select(QyzxEmpEntAsso::getUserType).eq(QyzxEmpEntAsso::getEmpNum, qyzxEmpLogin1.getId())
.eq(QyzxEmpEntAsso::getEmpNum, qyzxEmpLogin1.getId())
.eq(QyzxEmpEntAsso::getOrgCode, qyzxEmpLogin1.getOrgId())); .eq(QyzxEmpEntAsso::getOrgCode, qyzxEmpLogin1.getOrgId()));
qyzxEmpLogin1.setIsLeader(isLeader); qyzxEmpLogin1.setIsLeader(isLeader);
qyzxEmpLogin1.setUserType(eEA != null ? eEA.getUserType() : null); qyzxEmpLogin1.setUserType(eEA != null ? eEA.getUserType() : null);
...@@ -704,7 +696,7 @@ public class LoginController { ...@@ -704,7 +696,7 @@ public class LoginController {
String phone = entRegisterDto.getPhone(); String phone = entRegisterDto.getPhone();
String pw = entRegisterDto.getPw(); String pw = entRegisterDto.getPw();
if (phone == null || "".equals(phone) ) { if (phone == null || "".equals(phone)) {
return ResultUtil.error("手机号不能为空!"); return ResultUtil.error("手机号不能为空!");
} }
......
/**
* <p>Title: QyzxAuthController.java</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月19日
* @version 1.0
*/
package cn.timer.api.controller.qyzx;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections4.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.timer.api.aspect.lang.annotation.Log;
import cn.timer.api.aspect.lang.enums.BusinessType;
import cn.timer.api.bean.qyzx.QyzxEmpEntAsso;
import cn.timer.api.bean.qyzx.auth.QyzxAuthAccount;
import cn.timer.api.bean.qyzx.auth.QyzxAuthChild;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enums.SysRoleType;
import cn.timer.api.dao.yggl.YgglMainEmpMapper;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* <p>
* Title: Auth.java
* </p>
* <p>
* Description:
* </p>
*
* @author dsc
* @date 2020年5月19日
* @version 1.0
*/
@Transactional
@RestController
@Api(tags = "4.5企业中心(账号权限(新))")
@RequestMapping(value = "/Auth", produces = { "application/json" })
public class Auth {
private QyzxEmpEntAsso selectMain(Integer orgCode, Integer empNum) {
return QyzxEmpEntAsso.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, empNum)
.eq(QyzxEmpEntAsso::getUserType, SysRoleType.U_TYPE_ADMIN.getType()));
}
@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();
QyzxEmpEntAsso qyzxEmpEntAsso = selectMain(orgCode, empNum);
System.err.println(qyzxEmpEntAsso);
if (qyzxEmpEntAsso != null) {
if (QyzxEmpEntAsso.builder().build()
.selectCount(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getUserType, SysRoleType.U_TYPE_C_ADMIN.getType())) >= qyzxEmpEntAsso
.getMaxNum())
return ResultUtil.error("子账号数量超过上限");
if (QyzxEmpEntAsso.builder().empNum(childEmpNum).orgCode(orgCode)
.userType(SysRoleType.U_TYPE_C_ADMIN.getType()).build().insert())
return ResultUtil.success("添加成功");
}
return ResultUtil.error("暂无添加权限");
}
@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 orgCode = userBean.getOrgCode();
Integer empNum = userBean.getEmpNum();
if (selectMain(orgCode, empNum) != null) {
if (QyzxEmpEntAsso.builder().build()
.delete(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, childEmpNum)
.eq(QyzxEmpEntAsso::getUserType, SysRoleType.U_TYPE_C_ADMIN.getType())))
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) {
// Integer orgCode = userBean.getOrgCode();
// Integer empNum = userBean.getEmpNum();
// QyzxEmpEntAsso qyzxEmpEntAsso = selectMain(orgCode, empNum);
// if (qyzxEmpEntAsso != null && qyzxEmpEntAsso.getUserType() == 99) { // 99-后台管理员
// if (QyzxEmpEntAsso.builder().maxNum(maxNum).build().update(
// new QueryWrapper<QyzxEmpEntAsso>().lambda().eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode())))
// return ResultUtil.success("修改成功");
// return ResultUtil.error("修改失败");
// }
// return ResultUtil.error("暂无修改权限");
// }
@GetMapping(value = "/getAll")
@ApiOperation(value = "获取全部账号信息", httpMethod = "GET", notes = "接口发布说明")
public Result<List<YgglMainEmp>> getAll(@CurrentUser UserBean userBean) {
List<Integer> roles = new ArrayList<Integer>();
roles.add(SysRoleType.U_TYPE_ADMIN.getType());
roles.add(SysRoleType.U_TYPE_C_ADMIN.getType());
List<QyzxEmpEntAsso> list = QyzxEmpEntAsso.builder().build().selectList(
new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode())
.in(QyzxEmpEntAsso::getUserType, roles).select(QyzxEmpEntAsso::getEmpNum));
List<YgglMainEmp> ygs = new ArrayList<YgglMainEmp>();
List<Integer> empNums = list.stream().map(QyzxEmpEntAsso::getEmpNum).collect(Collectors.toList());
for (Integer empNum : empNums) {
YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new LambdaQueryWrapper<YgglMainEmp>().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
.eq(YgglMainEmp::getEmpNum, empNum)
.select(YgglMainEmp::getName, YgglMainEmp::getPhone, YgglMainEmp::getEmpNum));
if (yg != null)
ygs.add(yg);
}
return ResultUtil.data(ygs, "查询成功");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment