Commit 29f78e74 by dengshichuan

Merge branch 'dsc' into 'develop'

Dsc

See merge request 8timerv2/8timerapiv200!239
parents ddfab24c 03ca0bd3
...@@ -7,24 +7,6 @@ ...@@ -7,24 +7,6 @@
*/ */
package cn.timer.api.bean.qyzx.auth; 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> * <p>
* Title: QyzxAuthAccount.java * Title: QyzxAuthAccount.java
...@@ -38,42 +20,42 @@ import lombok.NoArgsConstructor; ...@@ -38,42 +20,42 @@ import lombok.NoArgsConstructor;
* @version 1.0 * @version 1.0
*/ */
@Entity //@Entity
@Data //@Data
@Builder //@Builder
@AllArgsConstructor //@AllArgsConstructor
@NoArgsConstructor //@NoArgsConstructor
@Table(name = "qyzx_auth_account") //@Table(name = "qyzx_auth_account")
@ApiModel("权限账号表") //@ApiModel("权限账号表")
public class QyzxAuthAccount extends Model<QyzxAuthAccount> { //public class QyzxAuthAccount extends Model<QyzxAuthAccount> {
//
private static final long serialVersionUID = -7906463769401403202L; // private static final long serialVersionUID = -7906463769401403202L;
//
@Id // @Id
@GeneratedValue // @GeneratedValue
@TableId(type = IdType.AUTO) // @TableId(type = IdType.AUTO)
@ApiModelProperty(value = "主键", example = "1") // @ApiModelProperty(value = "主键", example = "1")
private Integer id; // private Integer id;
//
@ApiModelProperty(value = "员工id", example = "9688") // @ApiModelProperty(value = "员工id", example = "9688")
private Integer empNum; // private Integer empNum;
//
@ApiModelProperty(value = "企业id", example = "117") // @ApiModelProperty(value = "企业id", example = "117")
private Integer orgCode; // private Integer orgCode;
//
@ApiModelProperty(value = "头像url", example = "ossUrl") // @ApiModelProperty(value = "头像url", example = "ossUrl")
private String headUrl; // private String headUrl;
//
@ApiModelProperty(value = "姓名", example = "tz") // @ApiModelProperty(value = "姓名", example = "tz")
private String name; // private String name;
//
@ApiModelProperty(value = "主账号手机", example = "18711519125") // @ApiModelProperty(value = "主账号手机", example = "18711519125")
private String accountPhone; // private String accountPhone;
//
@ApiModelProperty(value = "子账号最大数量", example = "10") // @ApiModelProperty(value = "子账号最大数量", example = "10")
private Integer maxChildAccount; // private Integer maxChildAccount;
//
@ApiModelProperty(value = "创建时间", example = "2020-05-20") // @ApiModelProperty(value = "创建时间", example = "2020-05-20")
private Date createdTime; // private Date createdTime;
//
} //}
...@@ -7,26 +7,6 @@ ...@@ -7,26 +7,6 @@
*/ */
package cn.timer.api.bean.qyzx.auth; 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> * <p>
* Title: QyzxAuthChild.java * Title: QyzxAuthChild.java
...@@ -39,47 +19,47 @@ import lombok.NoArgsConstructor; ...@@ -39,47 +19,47 @@ import lombok.NoArgsConstructor;
* @date 2020年5月19日 * @date 2020年5月19日
* @version 1.0 * @version 1.0
*/ */
@Entity //@Entity
@Data //@Data
@Builder //@Builder
@AllArgsConstructor //@AllArgsConstructor
@NoArgsConstructor //@NoArgsConstructor
@Table(name = "qyzx_auth_child") //@Table(name = "qyzx_auth_child")
@ApiModel("权限子账号表") //@ApiModel("权限子账号表")
public class QyzxAuthChild extends Model<QyzxAuthChild> { //public class QyzxAuthChild extends Model<QyzxAuthChild> {
//
private static final long serialVersionUID = 3202868427965301934L; // private static final long serialVersionUID = 3202868427965301934L;
//
@Id // @Id
@GeneratedValue // @GeneratedValue
@TableId(type = IdType.AUTO) // @TableId(type = IdType.AUTO)
@ApiModelProperty(value = "主键", example = "1") // @ApiModelProperty(value = "主键", example = "1")
private Integer id; // private Integer id;
//
@ApiModelProperty(value = "员工id", example = "9688") // @ApiModelProperty(value = "员工id", example = "9688")
private Integer empNum; // private Integer empNum;
//
@ApiModelProperty(value = "企业id", example = "117") // @ApiModelProperty(value = "企业id", example = "117")
private Integer orgCode; // private Integer orgCode;
//
@ApiModelProperty(value = "是否启用", example = "0-否 1-是") // @ApiModelProperty(value = "是否启用", example = "0-否 1-是")
private Integer isOpen; // private Integer isOpen;
//
@ApiModelProperty(value = "是否删除", example = "0-否 1-是") // @ApiModelProperty(value = "是否删除", example = "0-否 1-是")
private Integer isDel; // private Integer isDel;
//
@TableField(fill = FieldFill.INSERT) // @TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value = "创建时间", example = "2020-05-20") // @ApiModelProperty(value = "创建时间", example = "2020-05-20")
private Date createdTime; // private Date createdTime;
//
@ApiModelProperty(value = "创建人id", example = "9688") // @ApiModelProperty(value = "创建人id", example = "9688")
private Integer createdUser; // private Integer createdUser;
//
@TableField(fill = FieldFill.INSERT_UPDATE) // @TableField(fill = FieldFill.INSERT_UPDATE)
@ApiModelProperty(value = "修改时间", example = "2020-05-20") // @ApiModelProperty(value = "修改时间", example = "2020-05-20")
private Date modifiedTime; // private Date modifiedTime;
//
@ApiModelProperty(value = "修改人id", example = "9688") // @ApiModelProperty(value = "修改人id", example = "9688")
private Integer modifiedUser; // private Integer modifiedUser;
//
} //}
/**
* Title: CrmController.java
* Description:
* @author dsc
* @date 2020年6月5日
* @version 1.0
*/
package cn.timer.api.controller.crm; package cn.timer.api.controller.crm;
import java.io.IOException; import java.io.IOException;
...@@ -49,9 +42,11 @@ import cn.timer.api.bean.crm.CrmClientContacts; ...@@ -49,9 +42,11 @@ import cn.timer.api.bean.crm.CrmClientContacts;
import cn.timer.api.bean.crm.CrmClientData; import cn.timer.api.bean.crm.CrmClientData;
import cn.timer.api.bean.crm.CrmClientFollow; import cn.timer.api.bean.crm.CrmClientFollow;
import cn.timer.api.bean.crm.CrmSeaRule; 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.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser; import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean; 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.CrmClientContactsMapper;
import cn.timer.api.dao.crm.CrmClientDataMapper; import cn.timer.api.dao.crm.CrmClientDataMapper;
import cn.timer.api.dto.crm.CrmClientDataImportVo; import cn.timer.api.dto.crm.CrmClientDataImportVo;
...@@ -221,10 +216,16 @@ public class CrmController { ...@@ -221,10 +216,16 @@ public class CrmController {
Integer nowEmpNum = getEmpNum(userBean); Integer nowEmpNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean); Integer orgCode = getOrgCode(userBean);
YgglMainEmp yg = YgglMainEmp.builder().build() // YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode) // .selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
.eq(YgglMainEmp::getEmpNum, nowEmpNum).select(YgglMainEmp::getIsManager)); // .eq(YgglMainEmp::getEmpNum, nowEmpNum).select(YgglMainEmp::getIsManager));
if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) { // 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() List<CrmBusinessGroup> list = CrmBusinessGroup.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroup>().lambda() .selectList(new QueryWrapper<CrmBusinessGroup>().lambda()
...@@ -284,10 +285,16 @@ public class CrmController { ...@@ -284,10 +285,16 @@ public class CrmController {
Integer nowEmpNum = getEmpNum(userBean); Integer nowEmpNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean); Integer orgCode = getOrgCode(userBean);
YgglMainEmp yg = YgglMainEmp.builder().build() // YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode) // .selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
.eq(YgglMainEmp::getEmpNum, nowEmpNum).select(YgglMainEmp::getIsManager)); // .eq(YgglMainEmp::getEmpNum, nowEmpNum).select(YgglMainEmp::getIsManager));
if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) { // 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() List<CrmBusinessGroup> list = CrmBusinessGroup.builder().build()
.selectList(new LambdaQueryWrapper<CrmBusinessGroup>().eq(CrmBusinessGroup::getOrgCode, orgCode) .selectList(new LambdaQueryWrapper<CrmBusinessGroup>().eq(CrmBusinessGroup::getOrgCode, orgCode)
.select(CrmBusinessGroup::getName, CrmBusinessGroup::getId)); .select(CrmBusinessGroup::getName, CrmBusinessGroup::getId));
...@@ -574,11 +581,17 @@ public class CrmController { ...@@ -574,11 +581,17 @@ public class CrmController {
Integer empNum = getEmpNum(userBean); Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean); Integer orgCode = getOrgCode(userBean);
YgglMainEmp yg = YgglMainEmp.builder().build() // YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode) // .selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
.eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getIsManager)); // .eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getIsManager));
if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) { // 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() List<CrmClientData> list = CrmClientData.builder().build()
.selectList(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode) .selectList(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getBelongUser, 0) .eq(CrmClientData::getBelongUser, 0)
...@@ -627,10 +640,17 @@ public class CrmController { ...@@ -627,10 +640,17 @@ public class CrmController {
Integer empNum = getEmpNum(userBean); Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean); Integer orgCode = getOrgCode(userBean);
YgglMainEmp yg = YgglMainEmp.builder().build() // YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode) // .selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode)
.eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getIsManager)); // .eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getIsManager));
if (yg != null && yg.getIsManager() != null && (yg.getIsManager() == 1 || yg.getIsManager() == 2)) { // 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() List<CrmClientData> datas = CrmClientData.builder().build()
.selectList(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode) .selectList(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(groupId != null && groupId >= 0, CrmClientData::getBelongGroup, groupId) .eq(groupId != null && groupId >= 0, CrmClientData::getBelongGroup, groupId)
......
...@@ -13,6 +13,7 @@ import java.util.Comparator; ...@@ -13,6 +13,7 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -25,7 +26,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -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.annotation.Log;
import cn.timer.api.aspect.lang.enums.BusinessType; import cn.timer.api.aspect.lang.enums.BusinessType;
import cn.timer.api.bean.qyzx.QyzxEmpEntAsso; 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.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser; import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean; import cn.timer.api.config.annotation.UserBean;
...@@ -53,9 +53,8 @@ import io.swagger.annotations.ApiOperation; ...@@ -53,9 +53,8 @@ import io.swagger.annotations.ApiOperation;
@Api(tags = "4.5企业中心(账号权限(新))") @Api(tags = "4.5企业中心(账号权限(新))")
@RequestMapping(value = "/Auth", produces = { "application/json" }) @RequestMapping(value = "/Auth", produces = { "application/json" })
public class Auth { public class Auth {
// TODO @Value("${config-8timer.register-childAccount-max-num}")
// @Value("${}") private Integer maxNum;
// private Integer maxNum = 10;
private QyzxEmpEntAsso selectMain(Integer orgCode, Integer empNum) { private QyzxEmpEntAsso selectMain(Integer orgCode, Integer empNum) {
return QyzxEmpEntAsso.builder().build() return QyzxEmpEntAsso.builder().build()
...@@ -67,13 +66,16 @@ public class Auth { ...@@ -67,13 +66,16 @@ public class Auth {
@PostMapping(value = "/addChildAccount") @PostMapping(value = "/addChildAccount")
@ApiOperation(value = "新增子账号", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "新增子账号", httpMethod = "POST", notes = "接口发布说明")
@Log(title = "新增-子账号", businessType = BusinessType.INSERT) @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 orgCode = userBean.getOrgCode();
Integer empNum = userBean.getEmpNum(); Integer empNum = userBean.getEmpNum();
QyzxEmpEntAsso qyzxEmpEntAsso = selectMain(orgCode, empNum); QyzxEmpEntAsso qyzxEmpEntAsso = selectMain(orgCode, empNum);
if (qyzxEmpEntAsso != null) { if (qyzxEmpEntAsso != null) {
// if () Integer num = QyzxEmpEntAsso.builder().build()
// return ResultUtil.error("子账号数量超过上限"); .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() if (QyzxEmpEntAsso.builder().userType(SysRoleType.U_TYPE_C_ADMIN.getType()).build()
.update(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode) .update(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, childEmpNum))) .eq(QyzxEmpEntAsso::getEmpNum, childEmpNum)))
...@@ -85,13 +87,11 @@ public class Auth { ...@@ -85,13 +87,11 @@ public class Auth {
@PostMapping(value = "/removeChildAccount") @PostMapping(value = "/removeChildAccount")
@ApiOperation(value = "移除子账号", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "移除子账号", httpMethod = "POST", notes = "接口发布说明")
@Log(title = "移除-子账号", businessType = BusinessType.INSERT) @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 orgCode = userBean.getOrgCode();
Integer empNum = userBean.getEmpNum(); Integer empNum = userBean.getEmpNum();
QyzxEmpEntAsso qyzxEmpEntAsso = selectMain(orgCode, empNum); QyzxEmpEntAsso qyzxEmpEntAsso = selectMain(orgCode, empNum);
if (qyzxEmpEntAsso != null) { if (qyzxEmpEntAsso != null) {
// if ()
// return ResultUtil.error("子账号数量超过上限");
if (QyzxEmpEntAsso.builder().userType(SysRoleType.U_TYPE_EMP.getType()).build() if (QyzxEmpEntAsso.builder().userType(SysRoleType.U_TYPE_EMP.getType()).build()
.update(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode) .update(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, childEmpNum))) .eq(QyzxEmpEntAsso::getEmpNum, childEmpNum)))
......
...@@ -7,38 +7,6 @@ ...@@ -7,38 +7,6 @@
*/ */
package cn.timer.api.controller.qyzx; 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> * <p>
* Title: QyzxAuthController.java * Title: QyzxAuthController.java
...@@ -51,147 +19,147 @@ import io.swagger.annotations.ApiOperation; ...@@ -51,147 +19,147 @@ import io.swagger.annotations.ApiOperation;
* @date 2020年5月19日 * @date 2020年5月19日
* @version 1.0 * @version 1.0
*/ */
@Transactional //@Transactional
@RestController //@RestController
@Api(tags = "4.2企业中心(账号权限)") //@Api(tags = "4.2企业中心(账号权限)")
@RequestMapping(value = "/qyzxAuth", produces = { "application/json" }) //@RequestMapping(value = "/qyzxAuth", produces = { "application/json" })
public class QyzxAuthController { //public class QyzxAuthController {
//
@Transactional // @Transactional
@PostMapping(value = "/addChildAccount") // @PostMapping(value = "/addChildAccount")
@ApiOperation(value = "新增子账号", httpMethod = "POST", notes = "接口发布说明") // @ApiOperation(value = "新增子账号", httpMethod = "POST", notes = "接口发布说明")
@Log(title = "新增-子账号", businessType = BusinessType.INSERT) // @Log(title = "新增-子账号", businessType = BusinessType.INSERT)
public Result<QyzxAuthChild> addChildAccount(@CurrentUser UserBean userBean, @RequestParam Integer childEmpNum) { // public Result<QyzxAuthChild> addChildAccount(@CurrentUser UserBean userBean, @RequestParam Integer childEmpNum) {
Integer orgCode = userBean.getOrgCode(); // Integer orgCode = userBean.getOrgCode();
Integer empNum = userBean.getEmpNum(); // Integer empNum = userBean.getEmpNum();
QyzxAuthAccount qyzxAuthAccount = QyzxAuthAccount.builder().build() // QyzxAuthAccount qyzxAuthAccount = QyzxAuthAccount.builder().build()
.selectOne(new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, orgCode)); // 主账号 // .selectOne(new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, orgCode)); // 主账号
Integer mainEmpNum = qyzxAuthAccount.getEmpNum(); // Integer mainEmpNum = qyzxAuthAccount.getEmpNum();
if (!empNum.equals(mainEmpNum)) // if (!empNum.equals(mainEmpNum))
return ResultUtil.error("当前用户没有添加权限"); // return ResultUtil.error("当前用户没有添加权限");
Integer max = qyzxAuthAccount.getMaxChildAccount(); // 最大子账号数量 // Integer max = qyzxAuthAccount.getMaxChildAccount(); // 最大子账号数量
Integer count = QyzxAuthChild.builder().build().selectCount(new QueryWrapper<QyzxAuthChild>().lambda() // Integer count = QyzxAuthChild.builder().build().selectCount(new QueryWrapper<QyzxAuthChild>().lambda()
.eq(QyzxAuthChild::getOrgCode, orgCode).ne(QyzxAuthChild::getIsDel, 1)); // 子账号数量 // .eq(QyzxAuthChild::getOrgCode, orgCode).ne(QyzxAuthChild::getIsDel, 1)); // 子账号数量
if (count >= max) // if (count >= max)
return ResultUtil.error("子账号数量达到上限"); // return ResultUtil.error("子账号数量达到上限");
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda() // YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.eq(YgglMainEmp::getEmpNum, childEmpNum).eq(YgglMainEmp::getOrgCode, orgCode)); // .eq(YgglMainEmp::getEmpNum, childEmpNum).eq(YgglMainEmp::getOrgCode, orgCode));
if (ygglMainEmp == null) // if (ygglMainEmp == null)
return ResultUtil.error("该确认该员工是否存在"); // return ResultUtil.error("该确认该员工是否存在");
//
Integer jobStatus = ygglMainEmp.getJobStatus(); // Integer jobStatus = ygglMainEmp.getJobStatus();
if (jobStatus == 2 || jobStatus == 3) // if (jobStatus == 2 || jobStatus == 3)
return ResultUtil.error("该员工已离职或离职中"); // return ResultUtil.error("该员工已离职或离职中");
//
QyzxAuthChild oldAuthChild = QyzxAuthChild.builder().build().selectOne(new QueryWrapper<QyzxAuthChild>() // QyzxAuthChild oldAuthChild = QyzxAuthChild.builder().build().selectOne(new QueryWrapper<QyzxAuthChild>()
.lambda().eq(QyzxAuthChild::getOrgCode, orgCode).eq(QyzxAuthChild::getEmpNum, childEmpNum)); // .lambda().eq(QyzxAuthChild::getOrgCode, orgCode).eq(QyzxAuthChild::getEmpNum, childEmpNum));
//
if (mainEmpNum == childEmpNum) // if (mainEmpNum == childEmpNum)
return ResultUtil.error("添加失败,该账号是主账号"); // return ResultUtil.error("添加失败,该账号是主账号");
if (oldAuthChild != null && oldAuthChild.getIsDel() == 0) // if (oldAuthChild != null && oldAuthChild.getIsDel() == 0)
return ResultUtil.error("添加失败,该账号已是企业子账号"); // return ResultUtil.error("添加失败,该账号已是企业子账号");
else if (oldAuthChild != null && oldAuthChild.getIsDel() == 1) { // else if (oldAuthChild != null && oldAuthChild.getIsDel() == 1) {
oldAuthChild.setIsDel(0); // oldAuthChild.setIsDel(0);
oldAuthChild.setModifiedTime(new Date()); // oldAuthChild.setModifiedTime(new Date());
oldAuthChild.setModifiedUser(empNum); // oldAuthChild.setModifiedUser(empNum);
oldAuthChild.updateById(); // oldAuthChild.updateById();
//
ygglMainEmp.setIsManager(2); // ygglMainEmp.setIsManager(2);
ygglMainEmp.updateById(); // ygglMainEmp.updateById();
return ResultUtil.data(oldAuthChild, "添加企业子账号成功"); // return ResultUtil.data(oldAuthChild, "添加企业子账号成功");
} // }
QyzxAuthChild qyzxAuthChild = new QyzxAuthChild(); // QyzxAuthChild qyzxAuthChild = new QyzxAuthChild();
qyzxAuthChild.setCreatedUser(empNum); // qyzxAuthChild.setCreatedUser(empNum);
qyzxAuthChild.setCreatedTime(new Date()); // qyzxAuthChild.setCreatedTime(new Date());
qyzxAuthChild.setEmpNum(childEmpNum); // qyzxAuthChild.setEmpNum(childEmpNum);
qyzxAuthChild.setOrgCode(orgCode); // qyzxAuthChild.setOrgCode(orgCode);
qyzxAuthChild.setIsDel(0); // qyzxAuthChild.setIsDel(0);
// qyzxAuthChild.setIsOpen(1); //// qyzxAuthChild.setIsOpen(1);
qyzxAuthChild.insert(); // qyzxAuthChild.insert();
//
ygglMainEmp.setIsManager(2); // ygglMainEmp.setIsManager(2);
ygglMainEmp.updateById(); // ygglMainEmp.updateById();
return ResultUtil.data(qyzxAuthChild, "添加企业子账号成功"); // return ResultUtil.data(qyzxAuthChild, "添加企业子账号成功");
} // }
//
@Transactional // @Transactional
@DeleteMapping(value = "/delChildAccount/{childEmpNum}") // @DeleteMapping(value = "/delChildAccount/{childEmpNum}")
@ApiOperation(value = "删除子账号", httpMethod = "DELETE", notes = "接口发布说明") // @ApiOperation(value = "删除子账号", httpMethod = "DELETE", notes = "接口发布说明")
@Log(title = "删除-子账号", businessType = BusinessType.DELETE) // @Log(title = "删除-子账号", businessType = BusinessType.DELETE)
public Result<String> delChildAccount(@CurrentUser UserBean userBean, @PathVariable Integer childEmpNum) { // public Result<String> delChildAccount(@CurrentUser UserBean userBean, @PathVariable Integer childEmpNum) {
Integer empNum = userBean.getEmpNum(); // Integer empNum = userBean.getEmpNum();
QyzxAuthAccount qyzxAuthAccount = QyzxAuthAccount.builder().build().selectOne( // QyzxAuthAccount qyzxAuthAccount = QyzxAuthAccount.builder().build().selectOne(
new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, userBean.getOrgCode())); // new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, userBean.getOrgCode()));
Integer mainEmpNum = qyzxAuthAccount.getEmpNum(); // Integer mainEmpNum = qyzxAuthAccount.getEmpNum();
if (!empNum.equals(mainEmpNum)) // if (!empNum.equals(mainEmpNum))
return ResultUtil.error("没有操作权限"); // return ResultUtil.error("没有操作权限");
if (mainEmpNum.equals(childEmpNum)) // if (mainEmpNum.equals(childEmpNum))
return ResultUtil.error("企业主账号不能被删除"); // return ResultUtil.error("企业主账号不能被删除");
boolean result = QyzxAuthChild.builder().isDel(1).build().update( // boolean result = QyzxAuthChild.builder().isDel(1).build().update(
new QueryWrapper<QyzxAuthChild>().lambda().eq(QyzxAuthChild::getOrgCode, userBean.getOrgCode())); // new QueryWrapper<QyzxAuthChild>().lambda().eq(QyzxAuthChild::getOrgCode, userBean.getOrgCode()));
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda() // YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.eq(YgglMainEmp::getEmpNum, childEmpNum).eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())); // .eq(YgglMainEmp::getEmpNum, childEmpNum).eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()));
ygglMainEmp.setIsManager(0); // ygglMainEmp.setIsManager(0);
if (result && ygglMainEmp.updateById()) // if (result && ygglMainEmp.updateById())
return ResultUtil.success("删除成功"); // return ResultUtil.success("删除成功");
return ResultUtil.error("删除失败"); // return ResultUtil.error("删除失败");
} // }
//
@PostMapping(value = "/modifyMaxChild") // @PostMapping(value = "/modifyMaxChild")
@ApiOperation(value = "修改子账号最大数量", httpMethod = "POST", notes = "接口发布说明") // @ApiOperation(value = "修改子账号最大数量", httpMethod = "POST", notes = "接口发布说明")
@Log(title = "修改-子账号最大数量", businessType = BusinessType.UPDATE) // @Log(title = "修改-子账号最大数量", businessType = BusinessType.UPDATE)
public Result<QyzxAuthChild> modifyMaxChild(@CurrentUser UserBean userBean, @RequestParam Integer maxNum) { // public Result<QyzxAuthChild> modifyMaxChild(@CurrentUser UserBean userBean, @RequestParam Integer maxNum) {
if (QyzxAuthAccount.builder().maxChildAccount(maxNum).build().update( // if (QyzxAuthAccount.builder().maxChildAccount(maxNum).build().update(
new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, userBean.getOrgCode()))) // new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, userBean.getOrgCode())))
return ResultUtil.success("修改成功"); // return ResultUtil.success("修改成功");
return ResultUtil.error("修改失败"); // return ResultUtil.error("修改失败");
} // }
//
@GetMapping(value = "/getAll") // @GetMapping(value = "/getAll")
@ApiOperation(value = "获取全部账号信息", httpMethod = "GET", notes = "接口发布说明") // @ApiOperation(value = "获取全部账号信息", httpMethod = "GET", notes = "接口发布说明")
public Result<List<Object>> getAll(@CurrentUser UserBean userBean) { // public Result<List<Object>> getAll(@CurrentUser UserBean userBean) {
List<Object> list = new ArrayList<Object>(); // List<Object> list = new ArrayList<Object>();
//
Map<String, Object> map = new HashedMap<String, Object>(); // Map<String, Object> map = new HashedMap<String, Object>();
QyzxAuthAccount qyzxAuthAccount = QyzxAuthAccount.builder().build().selectOne( // QyzxAuthAccount qyzxAuthAccount = QyzxAuthAccount.builder().build().selectOne(
new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, userBean.getOrgCode())); // 主账号 // new QueryWrapper<QyzxAuthAccount>().lambda().eq(QyzxAuthAccount::getOrgCode, userBean.getOrgCode())); // 主账号
map.put("mainAccount", qyzxAuthAccount); // map.put("mainAccount", qyzxAuthAccount);
//
List<QyzxAuthChild> childs = QyzxAuthChild.builder().build().selectList(new QueryWrapper<QyzxAuthChild>() // List<QyzxAuthChild> childs = QyzxAuthChild.builder().build().selectList(new QueryWrapper<QyzxAuthChild>()
.lambda().eq(QyzxAuthChild::getOrgCode, userBean.getOrgCode()).ne(QyzxAuthChild::getIsDel, 1)); // 子账号 // .lambda().eq(QyzxAuthChild::getOrgCode, userBean.getOrgCode()).ne(QyzxAuthChild::getIsDel, 1)); // 子账号
System.err.println(childs); // System.err.println(childs);
List<YgglMainEmp> list2 = new ArrayList<YgglMainEmp>(); // List<YgglMainEmp> list2 = new ArrayList<YgglMainEmp>();
for (QyzxAuthChild qyzxAuthChild : childs) { // for (QyzxAuthChild qyzxAuthChild : childs) {
Integer empNum = qyzxAuthChild.getEmpNum(); // Integer empNum = qyzxAuthChild.getEmpNum();
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne( // YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(
new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()) // new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
.eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getHeadUrl, YgglMainEmp::getName, // .eq(YgglMainEmp::getEmpNum, empNum).select(YgglMainEmp::getHeadUrl, YgglMainEmp::getName,
YgglMainEmp::getPhone, YgglMainEmp::getEmpNum)); // 子账号员工信息 // YgglMainEmp::getPhone, YgglMainEmp::getEmpNum)); // 子账号员工信息
list2.add(ygglMainEmp); // list2.add(ygglMainEmp);
} // }
map.put("childAccount", list2); // map.put("childAccount", list2);
list.add(map); // list.add(map);
//
return ResultUtil.data(list, "查询成功"); // return ResultUtil.data(list, "查询成功");
//
} // }
//
@GetMapping(value = "/getYgAuth") // @GetMapping(value = "/getYgAuth")
@ApiOperation(value = "获取全部权限信息", httpMethod = "GET", notes = "接口发布说明") // @ApiOperation(value = "获取全部权限信息", httpMethod = "GET", notes = "接口发布说明")
public Result<List<YgglMainEmp>> getYgAuth(@CurrentUser UserBean userBean) { // public Result<List<YgglMainEmp>> getYgAuth(@CurrentUser UserBean userBean) {
YgglMainEmp main = YgglMainEmp.builder().build() // YgglMainEmp main = YgglMainEmp.builder().build()
.selectOne(new LambdaQueryWrapper<YgglMainEmp>().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()) // .selectOne(new LambdaQueryWrapper<YgglMainEmp>().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
.eq(YgglMainEmp::getIsManager, 1).select(YgglMainEmp::getName, YgglMainEmp::getPhone, // .eq(YgglMainEmp::getIsManager, 1).select(YgglMainEmp::getName, YgglMainEmp::getPhone,
YgglMainEmp::getEmpNum, YgglMainEmp::getIsManager)); // YgglMainEmp::getEmpNum, YgglMainEmp::getIsManager));
//
List<YgglMainEmp> child = YgglMainEmp.builder().build() // List<YgglMainEmp> child = YgglMainEmp.builder().build()
.selectList(new LambdaQueryWrapper<YgglMainEmp>().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()) // .selectList(new LambdaQueryWrapper<YgglMainEmp>().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
.eq(YgglMainEmp::getIsManager, 2).select(YgglMainEmp::getName, YgglMainEmp::getPhone, // .eq(YgglMainEmp::getIsManager, 2).select(YgglMainEmp::getName, YgglMainEmp::getPhone,
YgglMainEmp::getEmpNum, YgglMainEmp::getIsManager)); // YgglMainEmp::getEmpNum, YgglMainEmp::getIsManager));
child.add(main); // child.add(main);
//
Collections.sort(child, Comparator.comparing(YgglMainEmp::getIsManager)); // Collections.sort(child, Comparator.comparing(YgglMainEmp::getIsManager));
return ResultUtil.data(child, "查询成功"); // return ResultUtil.data(child, "查询成功");
} // }
//
} //}
...@@ -7,20 +7,20 @@ ...@@ -7,20 +7,20 @@
*/ */
package cn.timer.api.dao.qyzx.auth; package cn.timer.api.dao.qyzx.auth;
import org.springframework.stereotype.Repository; //import org.springframework.stereotype.Repository;
//
import com.baomidou.mybatisplus.core.mapper.BaseMapper; //import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//
import cn.timer.api.bean.qyzx.auth.QyzxAuthAccount; //import cn.timer.api.bean.qyzx.auth.QyzxAuthAccount;
//
/** ///**
* <p>Title: QyzxAuthChildMapper.java</p> //* <p>Title: QyzxAuthChildMapper.java</p>
* <p>Description: </p> //* <p>Description: </p>
* @author dsc //* @author dsc
* @date 2020年5月19日 //* @date 2020年5月19日
* @version 1.0 //* @version 1.0
*/ //*/
@Repository //@Repository
public interface QyzxAuthAccountMapper extends BaseMapper<QyzxAuthAccount>{ //public interface QyzxAuthAccountMapper extends BaseMapper<QyzxAuthAccount>{
//
} //}
...@@ -7,20 +7,20 @@ ...@@ -7,20 +7,20 @@
*/ */
package cn.timer.api.dao.qyzx.auth; package cn.timer.api.dao.qyzx.auth;
import org.springframework.stereotype.Repository; //import org.springframework.stereotype.Repository;
//
import com.baomidou.mybatisplus.core.mapper.BaseMapper; //import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//
import cn.timer.api.bean.qyzx.auth.QyzxAuthChild; //import cn.timer.api.bean.qyzx.auth.QyzxAuthChild;
//
/** ///**
* <p>Title: QyzxAuthChildMapper.java</p> //* <p>Title: QyzxAuthChildMapper.java</p>
* <p>Description: </p> //* <p>Description: </p>
* @author dsc //* @author dsc
* @date 2020年5月19日 //* @date 2020年5月19日
* @version 1.0 //* @version 1.0
*/ //*/
@Repository //@Repository
public interface QyzxAuthChildMapper extends BaseMapper<QyzxAuthChild>{ //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