作者 王兆博

客户端的协议

package com.example.client.controller;
import cn.bronet.admin.common.core.domain.AjaxResult;
import com.example.client.domain.vo.CSetAgreementVo;
import com.example.client.service.AgreementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.xml.ws.Service;
/**
* Created with IDEA
* author:WangZhaoBo
* Date:2021/9/17
* Time:16:15
*/
@RestController
@Api(tags = "用户协议")
@RequestMapping("/get")
public class AgreementController {
@Autowired
AgreementService agreementService;
@ApiOperation("获取用户协议")
@GetMapping("/agreementVo")
public AjaxResult getAgreementVo(){
return agreementService.agreementService();
}
}
... ...
... ... @@ -39,5 +39,11 @@ public class UerConytoller {
return userService.binding(myAuthentication);
}
@ApiOperation("添加身份信息")
@PostMapping("/addIdentity")
public AjaxResult addIdentity(@Validated @RequestBody MyAuthentication cUserBo) {
return userService.addIdentity(cUserBo);
}
}
... ...
... ... @@ -15,6 +15,9 @@ import javax.validation.constraints.NotNull;
@Data
public class MyAuthentication {
@NotNull(message = "身份类型不能为空")
@ApiModelProperty("身份选择 1-教师 2-学生 3 家长绑定")
private Identity identityType;
... ... @@ -31,6 +34,10 @@ public class MyAuthentication {
@ApiModelProperty("身份证号")
private String identityCard;
@ApiModelProperty("家长姓名")
private String parentName;
/**
* 用户手机号
*/
... ...
package com.example.client.domain.vo;
import cn.bronet.admin.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 协议视图对象 c_set_agreement
*
* @author ruoyi
* @date 2021-09-17
*/
@Data
@ApiModel("协议视图对象")
public class CSetAgreementVo {
private static final long serialVersionUID = 1L;
/**
* $pkColumn.columnComment
*/
@ApiModelProperty("$pkColumn.columnComment")
private Integer id;
/**
* 协议
*/
@Excel(name = "协议")
@ApiModelProperty("协议")
private String agreement;
/**
* 隐私政策
*/
@Excel(name = "隐私政策")
@ApiModelProperty("隐私政策")
private String policy;
/**
* 版本
*/
@Excel(name = "版本")
@ApiModelProperty("版本")
private String versions;
/**
* 帮助
*/
@Excel(name = "帮助")
@ApiModelProperty("帮助")
private String assistance;
/**
* 创建时间
*/
@Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("创建时间")
private Date creatorTime;
/**
* 创建人
*/
@Excel(name = "创建人" , width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("创建人")
private Date userId;
}
... ...
... ... @@ -46,7 +46,8 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
"/swagger-ui.html/**",
"/doc.html/**",
"/mx/doc.html/**",
"/webjars/**"
"/webjars/**",
"/get/agreementVo"
).permitAll()
// 其他请求都需要认证后才能访问
... ...
package com.example.client.service;
import cn.bronet.admin.common.core.domain.AjaxResult;
/**
* Created with IDEA
* author:WangZhaoBo
* Date:2021/9/17
* Time:16:18
*/
public interface AgreementService {
AjaxResult agreementService();
}
... ...
... ... @@ -103,4 +103,11 @@ public interface UserService extends IServicePlus<CUser, CUserVo> {
* @param myAuthentication
*/
AjaxResult binding(MyAuthentication myAuthentication);
/**
* 添加身份信息
* @param cUserBo
* @return
*/
AjaxResult addIdentity(MyAuthentication cUserBo);
}
... ...
package com.example.client.service.impl;
import cn.bronet.admin.common.core.domain.AjaxResult;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.client.domain.CSetAgreement;
import com.example.client.mapper.CSetAgreementMapper;
import com.example.client.service.AgreementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created with IDEA
* author:WangZhaoBo
* Date:2021/9/17
* Time:16:18
*/
@Service
public class AgreementServiceImpl implements AgreementService {
@Autowired
private CSetAgreementMapper cSetAgreementMapper;
@Override
public AjaxResult agreementService() {
return AjaxResult.success(cSetAgreementMapper.selectList(Wrappers.lambdaQuery(CSetAgreement.class)));
}
}
... ...
... ... @@ -193,6 +193,7 @@ public class CUserServiceImpl extends ServicePlusImpl<CUserMapper, CUser, CUserV
return AjaxResult.success(true);
}
//家长绑定
if (myAuthentication.getIdentityType().equals(Identity.PATRIARCH)) {
return familyService.bindingFamily(myAuthentication,userId);
... ... @@ -201,6 +202,15 @@ public class CUserServiceImpl extends ServicePlusImpl<CUserMapper, CUser, CUserV
return AjaxResult.error("身份类型不存在");
}
@Override
public AjaxResult addIdentity(MyAuthentication cUserBo) {
Long userId = UserContext.currentUserId();
//添加用户身份
aad(cUserBo ,userId );
return AjaxResult.success(true);
}
/**
* 添加用户信息
*
... ...
... ... @@ -47,6 +47,11 @@ public class FamilyServiceImpl extends ServicePlusImpl<CFamilyRelationStudentMap
@Override
public AjaxResult bindingFamily(MyAuthentication myAuthentication ,Long userId) {
if(myAuthentication.getParentName() ==null){
return AjaxResult.error("父母名字必填");
}
//查看是否绑定过孩子
List<CPersonalInformation> cPersonalInformations = cPersonalInformationMapper.selectList(Wrappers.lambdaQuery(CPersonalInformation.class)
.eq(CPersonalInformation::getIdentityCard, myAuthentication.getIdentityCard()).eq(CPersonalInformation::getName, myAuthentication.getName())
.eq(CPersonalInformation::getPhonenumber,myAuthentication.getUserPhonenumber()));
... ... @@ -64,8 +69,11 @@ public class FamilyServiceImpl extends ServicePlusImpl<CFamilyRelationStudentMap
CFamilyRelationStudent cFamilyRelationStudent = new CFamilyRelationStudent();
cFamilyRelationStudent.setUserId(userId);
cFamilyRelationStudent.setSubclassId(cPersonalInformations.get(0).getUserId());
cFamilyRelationStudent.setCreatorTime(LocalDateTime.now());
cFamilyRelationStudent.setCreatorTime(LocalDateTime.now()).setName(myAuthentication.getParentName());
getBaseMapper().insert(cFamilyRelationStudent);
//修改当前绑定孩子
CUser cUser = new CUser();
cUser.setUserId(userId);
... ...