Commit 29f78e74 by dengshichuan

Merge branch 'dsc' into 'develop'

Dsc

See merge request 8timerv2/8timerapiv200!239
parents ddfab24c 03ca0bd3
......@@ -7,24 +7,6 @@
*/
package cn.timer.api.bean.qyzx.auth;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* <p>
* Title: QyzxAuthAccount.java
......@@ -38,42 +20,42 @@ import lombok.NoArgsConstructor;
* @version 1.0
*/
@Entity
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "qyzx_auth_account")
@ApiModel("权限账号表")
public class QyzxAuthAccount extends Model<QyzxAuthAccount> {
private static final long serialVersionUID = -7906463769401403202L;
@Id
@GeneratedValue
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "主键", example = "1")
private Integer id;
@ApiModelProperty(value = "员工id", example = "9688")
private Integer empNum;
@ApiModelProperty(value = "企业id", example = "117")
private Integer orgCode;
@ApiModelProperty(value = "头像url", example = "ossUrl")
private String headUrl;
@ApiModelProperty(value = "姓名", example = "tz")
private String name;
@ApiModelProperty(value = "主账号手机", example = "18711519125")
private String accountPhone;
@ApiModelProperty(value = "子账号最大数量", example = "10")
private Integer maxChildAccount;
@ApiModelProperty(value = "创建时间", example = "2020-05-20")
private Date createdTime;
}
//@Entity
//@Data
//@Builder
//@AllArgsConstructor
//@NoArgsConstructor
//@Table(name = "qyzx_auth_account")
//@ApiModel("权限账号表")
//public class QyzxAuthAccount extends Model<QyzxAuthAccount> {
//
// private static final long serialVersionUID = -7906463769401403202L;
//
// @Id
// @GeneratedValue
// @TableId(type = IdType.AUTO)
// @ApiModelProperty(value = "主键", example = "1")
// private Integer id;
//
// @ApiModelProperty(value = "员工id", example = "9688")
// private Integer empNum;
//
// @ApiModelProperty(value = "企业id", example = "117")
// private Integer orgCode;
//
// @ApiModelProperty(value = "头像url", example = "ossUrl")
// private String headUrl;
//
// @ApiModelProperty(value = "姓名", example = "tz")
// private String name;
//
// @ApiModelProperty(value = "主账号手机", example = "18711519125")
// private String accountPhone;
//
// @ApiModelProperty(value = "子账号最大数量", example = "10")
// private Integer maxChildAccount;
//
// @ApiModelProperty(value = "创建时间", example = "2020-05-20")
// private Date createdTime;
//
//}
......@@ -7,26 +7,6 @@
*/
package cn.timer.api.bean.qyzx.auth;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* <p>
* Title: QyzxAuthChild.java
......@@ -39,47 +19,47 @@ import lombok.NoArgsConstructor;
* @date 2020年5月19日
* @version 1.0
*/
@Entity
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "qyzx_auth_child")
@ApiModel("权限子账号表")
public class QyzxAuthChild extends Model<QyzxAuthChild> {
private static final long serialVersionUID = 3202868427965301934L;
@Id
@GeneratedValue
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "主键", example = "1")
private Integer id;
@ApiModelProperty(value = "员工id", example = "9688")
private Integer empNum;
@ApiModelProperty(value = "企业id", example = "117")
private Integer orgCode;
@ApiModelProperty(value = "是否启用", example = "0-否 1-是")
private Integer isOpen;
@ApiModelProperty(value = "是否删除", example = "0-否 1-是")
private Integer isDel;
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value = "创建时间", example = "2020-05-20")
private Date createdTime;
@ApiModelProperty(value = "创建人id", example = "9688")
private Integer createdUser;
@TableField(fill = FieldFill.INSERT_UPDATE)
@ApiModelProperty(value = "修改时间", example = "2020-05-20")
private Date modifiedTime;
@ApiModelProperty(value = "修改人id", example = "9688")
private Integer modifiedUser;
}
//@Entity
//@Data
//@Builder
//@AllArgsConstructor
//@NoArgsConstructor
//@Table(name = "qyzx_auth_child")
//@ApiModel("权限子账号表")
//public class QyzxAuthChild extends Model<QyzxAuthChild> {
//
// private static final long serialVersionUID = 3202868427965301934L;
//
// @Id
// @GeneratedValue
// @TableId(type = IdType.AUTO)
// @ApiModelProperty(value = "主键", example = "1")
// private Integer id;
//
// @ApiModelProperty(value = "员工id", example = "9688")
// private Integer empNum;
//
// @ApiModelProperty(value = "企业id", example = "117")
// private Integer orgCode;
//
// @ApiModelProperty(value = "是否启用", example = "0-否 1-是")
// private Integer isOpen;
//
// @ApiModelProperty(value = "是否删除", example = "0-否 1-是")
// private Integer isDel;
//
// @TableField(fill = FieldFill.INSERT)
// @ApiModelProperty(value = "创建时间", example = "2020-05-20")
// private Date createdTime;
//
// @ApiModelProperty(value = "创建人id", example = "9688")
// private Integer createdUser;
//
// @TableField(fill = FieldFill.INSERT_UPDATE)
// @ApiModelProperty(value = "修改时间", example = "2020-05-20")
// private Date modifiedTime;
//
// @ApiModelProperty(value = "修改人id", example = "9688")
// private Integer modifiedUser;
//
//}
/**
* Title: CrmController.java
* Description:
* @author dsc
* @date 2020年6月5日
* @version 1.0
*/
package cn.timer.api.controller.crm;
import java.io.IOException;
......@@ -49,9 +42,11 @@ import cn.timer.api.bean.crm.CrmClientContacts;
import cn.timer.api.bean.crm.CrmClientData;
import cn.timer.api.bean.crm.CrmClientFollow;
import cn.timer.api.bean.crm.CrmSeaRule;
import cn.timer.api.bean.qyzx.QyzxEmpEntAsso;
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.crm.CrmClientContactsMapper;
import cn.timer.api.dao.crm.CrmClientDataMapper;
import cn.timer.api.dto.crm.CrmClientDataImportVo;
......@@ -221,10 +216,16 @@ public class CrmController {
Integer nowEmpNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
.eq(YgglMainEmp::getEmpNum, nowEmpNum).select(YgglMainEmp::getIsManager));
if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) {
// YgglMainEmp yg = YgglMainEmp.builder().build()
// .selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
// .eq(YgglMainEmp::getEmpNum, nowEmpNum).select(YgglMainEmp::getIsManager));
// TODO
QyzxEmpEntAsso qyzxEmpEntAsso = QyzxEmpEntAsso.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, nowEmpNum));
if (qyzxEmpEntAsso != null && qyzxEmpEntAsso.getUserType() != null
&& (qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_ADMIN.getType()
|| qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_C_ADMIN.getType())) {
List<CrmBusinessGroup> list = CrmBusinessGroup.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroup>().lambda()
......@@ -284,10 +285,16 @@ public class CrmController {
Integer nowEmpNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
.eq(YgglMainEmp::getEmpNum, nowEmpNum).select(YgglMainEmp::getIsManager));
if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) {
// YgglMainEmp yg = YgglMainEmp.builder().build()
// .selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
// .eq(YgglMainEmp::getEmpNum, nowEmpNum).select(YgglMainEmp::getIsManager));
// if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) {
QyzxEmpEntAsso qyzxEmpEntAsso = QyzxEmpEntAsso.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, nowEmpNum));
if (qyzxEmpEntAsso != null && qyzxEmpEntAsso.getUserType() != null
&& (qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_ADMIN.getType()
|| qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_C_ADMIN.getType())) {
List<CrmBusinessGroup> list = CrmBusinessGroup.builder().build()
.selectList(new LambdaQueryWrapper<CrmBusinessGroup>().eq(CrmBusinessGroup::getOrgCode, orgCode)
.select(CrmBusinessGroup::getName, CrmBusinessGroup::getId));
......@@ -574,11 +581,17 @@ public class CrmController {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
.eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getIsManager));
if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) {
// YgglMainEmp yg = YgglMainEmp.builder().build()
// .selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
// .eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getIsManager));
// if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) {
QyzxEmpEntAsso qyzxEmpEntAsso = QyzxEmpEntAsso.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, empNum));
if (qyzxEmpEntAsso != null && qyzxEmpEntAsso.getUserType() != null
&& (qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_ADMIN.getType()
|| qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_C_ADMIN.getType())) {
List<CrmClientData> list = CrmClientData.builder().build()
.selectList(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getBelongUser, 0)
......@@ -627,10 +640,17 @@ public class CrmController {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
.eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getIsManager));
if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) {
// YgglMainEmp yg = YgglMainEmp.builder().build()
// .selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
// .eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getIsManager));
// if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) {
QyzxEmpEntAsso qyzxEmpEntAsso = QyzxEmpEntAsso.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, empNum));
if (qyzxEmpEntAsso != null && qyzxEmpEntAsso.getUserType() != null
&& (qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_ADMIN.getType()
|| qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_C_ADMIN.getType())) {
List<CrmClientData> datas = CrmClientData.builder().build()
.selectList(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(groupId != null && groupId >= 0, CrmClientData::getBelongGroup, groupId)
......
......@@ -13,6 +13,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -25,7 +26,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.QyzxAuthChild;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
......@@ -53,9 +53,8 @@ import io.swagger.annotations.ApiOperation;
@Api(tags = "4.5企业中心(账号权限(新))")
@RequestMapping(value = "/Auth", produces = { "application/json" })
public class Auth {
// TODO
// @Value("${}")
// private Integer maxNum = 10;
@Value("${config-8timer.register-childAccount-max-num}")
private Integer maxNum;
private QyzxEmpEntAsso selectMain(Integer orgCode, Integer empNum) {
return QyzxEmpEntAsso.builder().build()
......@@ -67,13 +66,16 @@ public class Auth {
@PostMapping(value = "/addChildAccount")
@ApiOperation(value = "新增子账号", httpMethod = "POST", notes = "接口发布说明")
@Log(title = "新增-子账号", businessType = BusinessType.INSERT)
public Result<QyzxAuthChild> addChildAccount(@CurrentUser UserBean userBean, @RequestParam Integer childEmpNum) {
public Result<Void> addChildAccount(@CurrentUser UserBean userBean, @RequestParam Integer childEmpNum) {
Integer orgCode = userBean.getOrgCode();
Integer empNum = userBean.getEmpNum();
QyzxEmpEntAsso qyzxEmpEntAsso = selectMain(orgCode, empNum);
if (qyzxEmpEntAsso != null) {
// if ()
// return ResultUtil.error("子账号数量超过上限");
Integer num = QyzxEmpEntAsso.builder().build()
.selectCount(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getUserType, SysRoleType.U_TYPE_C_ADMIN.getType()));
if (num >= maxNum)
return ResultUtil.error("子账号数量超过上限");
if (QyzxEmpEntAsso.builder().userType(SysRoleType.U_TYPE_C_ADMIN.getType()).build()
.update(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, childEmpNum)))
......@@ -85,13 +87,11 @@ public class Auth {
@PostMapping(value = "/removeChildAccount")
@ApiOperation(value = "移除子账号", httpMethod = "POST", notes = "接口发布说明")
@Log(title = "移除-子账号", businessType = BusinessType.INSERT)
public Result<QyzxAuthChild> removeChildAccount(@CurrentUser UserBean userBean, @RequestParam Integer childEmpNum) {
public Result<Void> removeChildAccount(@CurrentUser UserBean userBean, @RequestParam Integer childEmpNum) {
Integer orgCode = userBean.getOrgCode();
Integer empNum = userBean.getEmpNum();
QyzxEmpEntAsso qyzxEmpEntAsso = selectMain(orgCode, empNum);
if (qyzxEmpEntAsso != null) {
// if ()
// return ResultUtil.error("子账号数量超过上限");
if (QyzxEmpEntAsso.builder().userType(SysRoleType.U_TYPE_EMP.getType()).build()
.update(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, childEmpNum)))
......
......@@ -7,38 +7,6 @@
*/
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 org.apache.commons.collections4.map.HashedMap;
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.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.utils.Result;
import cn.timer.api.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* <p>
* Title: QyzxAuthController.java
......@@ -51,147 +19,147 @@ import io.swagger.annotations.ApiOperation;
* @date 2020年5月19日
* @version 1.0
*/
@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, "查询成功");
}
}
//@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, "查询成功");
// }
//
//}
......@@ -7,20 +7,20 @@
*/
package cn.timer.api.dao.qyzx.auth;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.timer.api.bean.qyzx.auth.QyzxAuthAccount;
/**
* <p>Title: QyzxAuthChildMapper.java</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月19日
* @version 1.0
*/
@Repository
public interface QyzxAuthAccountMapper extends BaseMapper<QyzxAuthAccount>{
}
//import org.springframework.stereotype.Repository;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//
//import cn.timer.api.bean.qyzx.auth.QyzxAuthAccount;
//
///**
//* <p>Title: QyzxAuthChildMapper.java</p>
//* <p>Description: </p>
//* @author dsc
//* @date 2020年5月19日
//* @version 1.0
//*/
//@Repository
//public interface QyzxAuthAccountMapper extends BaseMapper<QyzxAuthAccount>{
//
//}
......@@ -7,20 +7,20 @@
*/
package cn.timer.api.dao.qyzx.auth;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.timer.api.bean.qyzx.auth.QyzxAuthChild;
/**
* <p>Title: QyzxAuthChildMapper.java</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月19日
* @version 1.0
*/
@Repository
public interface QyzxAuthChildMapper extends BaseMapper<QyzxAuthChild>{
}
//import org.springframework.stereotype.Repository;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//
//import cn.timer.api.bean.qyzx.auth.QyzxAuthChild;
//
///**
//* <p>Title: QyzxAuthChildMapper.java</p>
//* <p>Description: </p>
//* @author dsc
//* @date 2020年5月19日
//* @version 1.0
//*/
//@Repository
//public interface QyzxAuthChildMapper extends BaseMapper<QyzxAuthChild>{
//
//}
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