Commit 471b0702 by 邓实川

企业中心账号权限功能

parent 3bf1dc71
......@@ -26,46 +26,54 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* <p>Title: QyzxAuthAccount.java</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月19日
* @version 1.0
*/
* <p>
* Title: QyzxAuthAccount.java
* </p>
* <p>
* Description:
* </p>
*
* @author dsc
* @date 2020年5月19日
* @version 1.0
*/
@Entity
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name="qyzx_auth_account")
@Table(name = "qyzx_auth_account")
@ApiModel("权限账号表")
public class QyzxAuthAccount extends Model<QyzxAuthAccount>{
public class QyzxAuthAccount extends Model<QyzxAuthAccount> {
private static final long serialVersionUID = -7906463769401403202L;
@Id
@GeneratedValue
@TableId (type = IdType.AUTO)
@ApiModelProperty(value="主键",example="1")
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "主键", example = "1")
private Integer id;
@ApiModelProperty(value="员工id",example="9688")
@ApiModelProperty(value = "员工id", example = "9688")
private Integer empNum;
@ApiModelProperty(value="企业id",example="117")
@ApiModelProperty(value = "企业id", example = "117")
private Integer orgCode;
@ApiModelProperty(value="头像url",example="ossUrl")
@ApiModelProperty(value = "头像url", example = "ossUrl")
private String headUrl;
@ApiModelProperty(value="姓名",example="tz")
@ApiModelProperty(value = "姓名", example = "tz")
private String name;
@ApiModelProperty(value="主账号手机",example="18711519125")
@ApiModelProperty(value = "主账号手机", example = "18711519125")
private String accountPhone;
@ApiModelProperty(value="创建时间",example="2020-05-20")
@ApiModelProperty(value = "子账号最大数量", example = "10")
private Integer maxChildAccount;
@ApiModelProperty(value = "创建时间", example = "2020-05-20")
private Date createdTime;
}
/**
* <p>Title: QyzxAuthChild.java</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月19日
* @version 1.0
*/
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
* </p>
* <p>
* Description:
* </p>
*
* @author dsc
* @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;
}
......@@ -187,6 +187,9 @@ public class YgglMainEmp extends Model<YgglMainEmp> {
@ApiModelProperty(value="手机APPid ",example="appopenid手机app")
private String appopenid;
@ApiModelProperty(value="是否企业中心管理员 ",example="0-否 1-主账号 2-子账号")
private Integer isManager;
@Transient
@TableField(exist = false)
private String workTime;//工龄
......
......@@ -31,6 +31,7 @@ import cn.timer.api.bean.qyzx.QyzxEmpEntAsso;
import cn.timer.api.bean.qyzx.QyzxEmpLogin;
import cn.timer.api.bean.qyzx.QyzxEntInfoM;
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.yggl.YgglMainEmp;
import cn.timer.api.bean.zzgl.ZzglAuth;
......@@ -64,6 +65,9 @@ public class LoginController {
@Value("${config-8timer.register-company-max-num}")
public Integer max;
@Value("${config-8timer.register-childAccount-max-num}")
public Integer maxChildAccount;
@Value("${config-8timer.Aliyun.PROJECT_NAME}")
private String PROJECT_NAME;
......@@ -458,9 +462,9 @@ public class LoginController {
}
// 企业信息
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().name(name).registerTime(DateUtil.date()).phone(phone).operName(username)
.endTime(DateUtil.offsetDay(new Date(), offset)).level(CommonEnum.LEVEL_PROBATION.getType())
.build();
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().name(name).registerTime(DateUtil.date()).phone(phone)
.operName(username).endTime(DateUtil.offsetDay(new Date(), offset))
.level(CommonEnum.LEVEL_PROBATION.getType()).build();
boolean b1 = qyzxEntInfoM.insert();
if (!b1) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
......@@ -485,7 +489,7 @@ public class LoginController {
}
}
boolean b4 = YgglMainEmp.builder().orgCode(qyzxEntInfoM.getId()).empNum(login.getId()).rzTime(new Date())
boolean b4 = YgglMainEmp.builder().orgCode(qyzxEntInfoM.getId()).empNum(login.getId()).rzTime(new Date()).isManager(1)
.name(username).jobStatus(1).build().insert();
if (!b4) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
......@@ -503,6 +507,11 @@ public class LoginController {
SpmkService.createCustomApproval(qyzxEntInfoM.getId());
QyzxAuthAccount.builder().createdTime(new Date()).maxChildAccount(maxChildAccount).name(username).accountPhone(phone).empNum(login.getId())
.orgCode(qyzxEntInfoM.getId()).build().insert(); // TODO 主账号权限表
return ResultUtil.success("注册企业成功");
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
......
......@@ -7,42 +7,167 @@
*/
package cn.timer.api.controller.qyzx;
import java.util.ArrayList;
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 cn.timer.api.bean.qyzx.businessService.QyzxRemainingQuantity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月19日
* @version 1.0
*/
* <p>
* Title: QyzxAuthController.java
* </p>
* <p>
* Description:
* </p>
*
* @author dsc
* @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 = "接口发布说明")
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 = "接口发布说明")
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 = "接口发布说明")
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<Void> getAll(@CurrentUser UserBean userBean) {
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.add(map);
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<String, Object> map2 = new HashedMap<String, Object>();
map2.put("childAccount", list2);
list.add(map2);
return null;
return ResultUtil.data(list, "查询成功");
}
}
/**
* <p>Title: QyzxAuthChildMapper.java</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月19日
* @version 1.0
*/
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>{
}
/**
* <p>Title: QyzxAuthChildMapper.java</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月19日
* @version 1.0
*/
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>{
}
......@@ -66,4 +66,7 @@ public class QysDto implements Serializable{
@ApiModelProperty(value = "性别", example = "女")
private String sex;
@ApiModelProperty(value = "是否企业中心账号", example = "0-否 1-主账号 2-子账号")
private Integer isManager;
}
......@@ -151,7 +151,8 @@ logging:
config-8timer:
register-free-time: 90 #系统赠送时间
register-company-max-num: 100
register-company-max-num: 100 #默认最大公司数量
register-childAccount-max-num: 10 #默认最大子账号数量
Aliyun: # 阿里云
PROJECT_NAME: 8小时人事管家
REGION_ID: cn-shenzhen
......
......@@ -128,6 +128,7 @@ logging:
config-8timer:
register-free-time: 90 #系统赠送时间
register-company-max-num: 100
register-childAccount-max-num: 10
Aliyun: # 阿里云
PROJECT_NAME: 8小时人事管家
REGION_ID: cn-shenzhen
......
......@@ -128,6 +128,7 @@ logging:
config-8timer:
register-free-time: 90 #系统赠送时间
register-company-max-num: 100
register-childAccount-max-num: 10
Aliyun: # 阿里云
PROJECT_NAME: 8小时人事管家
REGION_ID: cn-shenzhen
......
......@@ -38,10 +38,11 @@
<result column="bmgw_id" property="bmgwId" />
<result column="job_num" property="jobNum" />
<result column="sex" property="sex" />
<result column="is_manager" property="isManager" />
</resultMap>
<select id="getQys" resultMap="qysdto">
select b.id,b.name,b.credit_code,b.codes,b.is_on_stock,b.logo_url,b.register_time,b.end_time,b.size,b.level,a.user_type,b.auth_type,a.status
,c.name empname,c.english_name,c.bmgw_id,c.job_num,c.sex
,c.name empname,c.english_name,c.bmgw_id,c.job_num,c.sex,c.is_manager
from qyzx_emp_ent_asso a
left join qyzx_ent_info_m b on a.org_code = b.id
left join yggl_main_emp c on a.emp_num = c.emp_num and a.org_code = c.org_code
......
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