package com.tuoheng.api.controller; | |||||
import com.tuoheng.api.entity.domain.IdentityApply; | |||||
import com.tuoheng.api.entity.request.IdentityQuery; | |||||
import com.tuoheng.api.service.IIdentityService; | |||||
import com.tuoheng.common.utils.JsonResult; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.*; | |||||
@RestController | |||||
@RequestMapping("/identity") | |||||
public class IdentityController { | |||||
@Autowired | |||||
private IIdentityService identityService; | |||||
/** | |||||
* 获取身份列表 | |||||
* | |||||
* @param identityQuery 查询条件 | |||||
* @return | |||||
*/ | |||||
@GetMapping("/getList") | |||||
public JsonResult getList(IdentityQuery identityQuery) { | |||||
return identityService.getListInfo(identityQuery); | |||||
} | |||||
/** | |||||
* 申请身份-提交 | |||||
* | |||||
* @param identityApply | |||||
* @return | |||||
*/ | |||||
@PostMapping("/submit") | |||||
public JsonResult submit(@RequestBody IdentityApply identityApply){ | |||||
return identityService.submit(identityApply); | |||||
} | |||||
} |
package com.tuoheng.api.controller; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
/** | |||||
* 我的 前端控制器 | |||||
* | |||||
* @author WangHaoran | |||||
* @since 2023-04-21 | |||||
*/ | |||||
@RestController | |||||
@RequestMapping("/my") | |||||
public class MyController { | |||||
} |
package com.tuoheng.api.entity.domain; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import com.tuoheng.common.common.BaseEntity; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.experimental.Accessors; | |||||
/** | |||||
* 身份申请表 | |||||
* | |||||
* @author WangHaoran | |||||
* @since 2023-04-24 | |||||
*/ | |||||
@Data | |||||
@EqualsAndHashCode(callSuper = true) | |||||
@Accessors(chain = true) | |||||
@TableName("th_identity_apply") | |||||
public class IdentityApply extends BaseEntity { | |||||
/** | |||||
* 租户ID | |||||
*/ | |||||
private Integer tenantId; | |||||
/** | |||||
* 申请身份ID | |||||
*/ | |||||
private Integer applyIdentityId; | |||||
/** | |||||
* 申请身份名称 | |||||
*/ | |||||
private String applyIdentityName; | |||||
/** | |||||
* 申请姓名 | |||||
*/ | |||||
private String applyName; | |||||
/** | |||||
* 申请电话 | |||||
*/ | |||||
private String applyPhone; | |||||
/** | |||||
* 申请人opendi | |||||
*/ | |||||
private String applyOpenid; | |||||
/** | |||||
* 申请人用户昵称 | |||||
*/ | |||||
private String applyNickname; | |||||
/** | |||||
* 申请理由 | |||||
*/ | |||||
private String applyRemark; | |||||
/** | |||||
* 状态:1待审核 2审核通过 3审核不通过 | |||||
*/ | |||||
private Integer status; | |||||
} |
package com.tuoheng.api.entity.request; | |||||
import lombok.Data; | |||||
@Data | |||||
public class IdentityQuery { | |||||
/** | |||||
* 租户ID | |||||
*/ | |||||
private Integer tenantId; | |||||
} |
package com.tuoheng.api.mapper; | |||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
import com.tuoheng.api.entity.domain.IdentityApply; | |||||
public interface IdentityApplyMapper extends BaseMapper<IdentityApply> { | |||||
} |
package com.tuoheng.api.service; | |||||
import com.tuoheng.api.entity.domain.Identity; | |||||
import com.tuoheng.api.entity.domain.IdentityApply; | |||||
import com.tuoheng.api.entity.request.IdentityQuery; | |||||
import com.tuoheng.common.common.IBaseService; | |||||
import com.tuoheng.common.utils.JsonResult; | |||||
/** | |||||
* 身份表 服务类 | |||||
* | |||||
* @author WangHaoran | |||||
* @since 2023-04-21 | |||||
*/ | |||||
public interface IIdentityService extends IBaseService<Identity> { | |||||
JsonResult getListInfo(IdentityQuery identityQuery); | |||||
JsonResult submit(IdentityApply identityApply); | |||||
} |
package com.tuoheng.api.service.impl; | |||||
import cn.hutool.core.util.ObjectUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.tuoheng.api.entity.domain.Identity; | |||||
import com.tuoheng.api.entity.domain.IdentityApply; | |||||
import com.tuoheng.api.entity.domain.WestreamUser; | |||||
import com.tuoheng.api.entity.request.IdentityQuery; | |||||
import com.tuoheng.api.mapper.IdentityApplyMapper; | |||||
import com.tuoheng.api.mapper.IdentityMapper; | |||||
import com.tuoheng.api.mapper.WestreamUserMapper; | |||||
import com.tuoheng.api.service.IIdentityService; | |||||
import com.tuoheng.common.common.BaseServiceImpl; | |||||
import com.tuoheng.common.utils.JsonResult; | |||||
import com.tuoheng.common.utils.StringUtils; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.List; | |||||
/** | |||||
* 身份表 服务实现类 | |||||
* | |||||
* @author WangHaoran | |||||
* @since 2023-04-21 | |||||
*/ | |||||
@Service | |||||
public class IdentityServiceImpl extends BaseServiceImpl<IdentityMapper, Identity> implements IIdentityService { | |||||
@Autowired | |||||
private IdentityMapper identityMapper; | |||||
@Autowired | |||||
private IdentityApplyMapper identityApplyMapper; | |||||
@Autowired | |||||
private WestreamUserMapper westreamUserMapper; | |||||
@Override | |||||
public JsonResult getListInfo(IdentityQuery identityQuery) { | |||||
if(null == identityQuery.getTenantId()){ | |||||
return JsonResult.error("租户ID为空!"); | |||||
} | |||||
List<Identity> identityList = identityMapper.selectList(new LambdaQueryWrapper<Identity>() | |||||
.eq(Identity::getTenantId, identityQuery.getTenantId())); | |||||
return JsonResult.success(identityList); | |||||
} | |||||
@Override | |||||
public JsonResult submit(IdentityApply identityApply) { | |||||
if(null == identityApply.getTenantId() || StringUtils.isEmpty(identityApply.getApplyOpenid())){ | |||||
return JsonResult.error("登录人信息为空!"); | |||||
} | |||||
//查询是否有申请中的流程,有则不允许申请 | |||||
Integer count = identityApplyMapper.selectCount(new LambdaQueryWrapper<IdentityApply>() | |||||
.eq(IdentityApply::getTenantId, identityApply.getTenantId()) | |||||
.eq(IdentityApply::getApplyOpenid, identityApply.getApplyOpenid()) | |||||
.eq(IdentityApply::getStatus, 1) | |||||
.eq(IdentityApply::getMark, 1)); | |||||
if(count>0){ | |||||
return JsonResult.error("已有申请中的流程!"); | |||||
} | |||||
//查询用户昵称 | |||||
WestreamUser westreamUser = westreamUserMapper.selectOne(new LambdaQueryWrapper<WestreamUser>() | |||||
.eq(WestreamUser::getTenantId, identityApply.getTenantId()) | |||||
.eq(WestreamUser::getOpenid, identityApply.getApplyOpenid()) | |||||
.eq(WestreamUser::getMark, 1)); | |||||
if(ObjectUtil.isNotNull(westreamUser)){ | |||||
identityApply.setApplyNickname(westreamUser.getNickname()); | |||||
} | |||||
identityApplyMapper.insert(identityApply); | |||||
return JsonResult.success(); | |||||
} | |||||
} |