Browse Source

20201103v1.0测试

tiaosheng
zy_Java 5 years ago
parent
commit
f8c4430a51
  1. 34
      mt/src/main/java/com/ccsens/mt/api/FileController.java
  2. 32
      mt/src/main/java/com/ccsens/mt/bean/dto/CompeteDto.java
  3. 1
      mt/src/main/java/com/ccsens/mt/bean/dto/ProvinceCompeteDto.java
  4. 20
      mt/src/main/java/com/ccsens/mt/bean/vo/ProvinceCompeteVo.java
  5. 2
      mt/src/main/java/com/ccsens/mt/persist/dao/CompeteCompanyDao.java
  6. 55
      mt/src/main/java/com/ccsens/mt/service/FileService.java
  7. 3
      mt/src/main/java/com/ccsens/mt/service/IFileService.java
  8. 160
      mt/src/main/java/com/ccsens/mt/service/ProvinceService.java
  9. 19
      mt/src/main/resources/mapper_dao/CompeteCompanyDao.xml
  10. 6
      mt/src/main/resources/mapper_dao/CompetePlayerDao.xml
  11. 7
      util/src/main/java/com/ccsens/util/CodeEnum.java
  12. 5
      util/src/main/java/com/ccsens/util/WebConstant.java
  13. 4
      util/src/test/java/com/ccsens/util/OtherTest.java

34
mt/src/main/java/com/ccsens/mt/api/FileController.java

@ -1,29 +1,28 @@
package com.ccsens.mt.api;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.cloudutil.feign.TallFeignClient;
import com.ccsens.mt.bean.dto.CompeteDto;
import com.ccsens.mt.bean.po.CommonFile;
import com.ccsens.mt.bean.vo.FileVo;
import com.ccsens.mt.service.IFileService;
import com.ccsens.mt.util.Constant;
import com.ccsens.util.*;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.util.exception.BaseException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
@ -149,4 +148,25 @@ public class FileController {
// }
return JsonResponse.newInstance().ok(vo);
}
@ApiOperation(value = "上传图片证明文件(不大于2M)")
@ApiImplicitParams({
})
@RequestMapping(value = "/upload/photoBase64", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<FileVo.Upload> uploadPhoneBase64(HttpServletRequest request, @ApiParam @Validated @RequestBody CompeteDto.FileBase64 params) throws Exception {
// log.info("文件上传:{}", params);
String authHeader = request.getHeader(WebConstant.HEADER_KEY_TOKEN);
JsonResponse tokenRes = tallFeignClient.getUserIdByToken(authHeader);
log.info("{}查询userId返回:{}", authHeader, tokenRes);
if (tokenRes.getCode().intValue() != CodeEnum.SUCCESS.getCode().intValue()) {
return tokenRes;
}
JSONObject json = JSON.parseObject(JSON.toJSONString(tokenRes.getData()));
Long userId = json.getLong("id");
FileVo.Upload vo = fileService.uploadPhoneBase64(params.getFileBase64(),userId);
return JsonResponse.newInstance().ok(vo);
}
}

32
mt/src/main/java/com/ccsens/mt/bean/dto/CompeteDto.java

@ -5,8 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NonNull;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.*;
import java.util.List;
/**
@ -230,26 +229,33 @@ public class CompeteDto {
private String family;
}
@Data
@ApiModel("当前用户参赛单位基本信息")
@ApiModel("添加或修改单位信息")
public static class CompeteCompany{
@NotNull
@ApiModelProperty("大赛id")
private Long competeTimeId;
@ApiModelProperty("参赛单位id")
private Long companyId;
// @NotEmpty(message = "请输入单位名称")
@Size(min =0,max = 20,message = "单位名称过长")
@ApiModelProperty("单位名称")
private String companyName;
@NotEmpty(message = "姓名不能为空")
@Size(min =0,max = 6 ,message = "联系人姓名过长")
@ApiModelProperty("主要联系人姓名")
private String contactsName ;
private String contactsName;
@NotEmpty(message = "联系方式不能为空")
@Pattern(regexp="^[1]([3-9])[0-9]{9}$",message="请输入正确的手机号")
@ApiModelProperty("联系方式")
private String contactsPhone ;
@ApiModelProperty("教练的人数")
private int coachNum ;
private int coachNum;
@ApiModelProperty("领队的人数")
private int guideNum ;
private int guideNum;
@ApiModelProperty("参赛人员的人数")
private int playerNum;
@ApiModelProperty("是否同意安全责任书 0否 1是 只有同意才能报名")
private Byte authorization;
private byte authorization;
}
// @Data
@ -278,7 +284,7 @@ public class CompeteDto {
@Data
@ApiModel("领队id")
public static class LeaderId{
@NonNull
@NotNull
@ApiModelProperty("教练或领队的id")
private Long coachId;
@ -286,9 +292,17 @@ public class CompeteDto {
@Data
@ApiModel("项目id和组别id")
public static class DelPlayer{
@NonNull
@NotNull
@ApiModelProperty("选手id")
private Long playerId;
}
@Data
@ApiModel("文件base64")
public static class FileBase64{
@ApiModelProperty("")
private String fileBase64;
}
}

1
mt/src/main/java/com/ccsens/mt/bean/dto/ProvinceCompeteDto.java

@ -16,6 +16,7 @@ public class ProvinceCompeteDto {
@Data
@ApiModel("参赛单位id")
public static class CompanyIdVo{
@NotNull(message = "参赛单位错误")
@ApiModelProperty("参赛单位id")
private Long companyId;
}

20
mt/src/main/java/com/ccsens/mt/bean/vo/ProvinceCompeteVo.java

@ -159,16 +159,28 @@ public class ProvinceCompeteVo {
private int gender;
@ApiModelProperty("身份证号")
private String idCard;
@ApiModelProperty("身份证正面照片 或户口本照片id")
private Long idCardFrontId;
@ApiModelProperty("身份证正面照片 或户口本照片 (浏览路径)")
private String idCardFront ;
@ApiModelProperty("身份证反面照片ID")
private Long idCardBackId;
@ApiModelProperty("身份证反面照片(浏览路径)")
private String idCardBack;
@ApiModelProperty("一寸证件照id")
private Long idPhoneId;
@ApiModelProperty("一寸证件照(浏览路径)")
private String idPhone;
@ApiModelProperty("学籍证明id")
private Long studentRecordId;
@ApiModelProperty("学籍证明(浏览路径)")
private String studentRecord;
@ApiModelProperty("体检证明id")
private Long healthRecordId;
@ApiModelProperty("体检证明(浏览路径)")
private String healthRecord;
@ApiModelProperty("保险证明id")
private Long insuranceRecordId;
@ApiModelProperty("保险证明(浏览路径)")
private String insuranceRecord;
}
@ -191,9 +203,13 @@ public class ProvinceCompeteVo {
private String phone;
@ApiModelProperty("身份证号")
private String idCard;
@ApiModelProperty("证件照id")
private Long idPhotoId;
@ApiModelProperty("证件照(浏览路径)")
private Long idPhoto;
private String idPhoto;
@ApiModelProperty("教练证id")
private Long coachCertificateId;
@ApiModelProperty("教练证(浏览路径)")
private Long coachCertificate;
private String coachCertificate;
}
}

2
mt/src/main/java/com/ccsens/mt/persist/dao/CompeteCompanyDao.java

@ -68,7 +68,7 @@ public interface CompeteCompanyDao extends CompeteCompanyMapper {
* @param companyId 单位id
* @return 返回单位参加的项目的数量
*/
int getJoinProjectNum(@Param("competeTimeId")Long companyId);
int getJoinProjectNum(@Param("companyId")Long companyId);
/**
* 查找单位在某项目下的某个组别的参赛数量个人项目

55
mt/src/main/java/com/ccsens/mt/service/FileService.java

@ -1,8 +1,13 @@
package com.ccsens.mt.service;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.mt.bean.po.CommonFile;
@ -19,9 +24,13 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.Part;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
/**
* @description: 文件操作
@ -103,4 +112,50 @@ public class FileService implements IFileService {
}
return vo;
}
@Override
public FileVo.Upload uploadPhoneBase64(String fileBas64, Long userId) throws Exception {
FileVo.Upload vo = new FileVo.Upload();
if(ObjectUtil.isNotNull(fileBas64)) {
log.info("-------------解析base64");
//获取后缀 data:image/png;base64,xxxxxx
String suffix = fileBas64.substring(fileBas64.indexOf("/")+1, fileBas64.indexOf(";"));
String dir = PropUtil.path + Constant.File.UPLOAD_URL + File.separator;
Random random = new Random();
String randomStr = String.valueOf(System.currentTimeMillis()) + random.nextInt(100) + "." + suffix;
String fileName = DateUtil.today() + "/" + randomStr;
File file = new File(dir + fileName);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
// 截取base64,后面的字符串
String base64flag = "base64,";
int index = fileBas64.indexOf(base64flag);
String str = index < 0 ? fileBas64 : fileBas64.substring(index + base64flag.length());
byte[] decode = Base64.decode(str);
FileOutputStream out = new FileOutputStream(file);
out.write(decode);
out.close();
if (file.length() > 2097152) {
throw new BaseException(CodeEnum.PHOTO_FILE_EXCEED_2M);
}
String name = file.getName();
CommonFile fileDo = new CommonFile();
fileDo.setId(snowflake.nextId());
fileDo.setFileName(name);
fileDo.setLocation(dir + fileName);
fileDo.setUserId(userId);
fileDo.setVisitLocation(PropUtil.imgDomain + Constant.File.UPLOAD_URL + File.separator + fileName);
commonFileMapper.insertSelective(fileDo);
log.info("保存文件:{}", fileDo);
vo.setId(fileDo.getId());
vo.setName(fileDo.getFileName());
vo.setVisitUrl(fileDo.getVisitLocation());
}
return vo;
}
}

3
mt/src/main/java/com/ccsens/mt/service/IFileService.java

@ -5,6 +5,7 @@ import com.ccsens.mt.bean.vo.FileVo;
import com.ccsens.util.NotSupportedFileTypeException;
import javax.servlet.http.Part;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
@ -37,4 +38,6 @@ public interface IFileService {
* @return
*/
FileVo.Upload uploadPhone(Part file,Long userId) throws IOException, NotSupportedFileTypeException;
FileVo.Upload uploadPhoneBase64(String file, Long userId) throws FileNotFoundException, Exception;
}

160
mt/src/main/java/com/ccsens/mt/service/ProvinceService.java

@ -136,13 +136,13 @@ public class ProvinceService implements IProvinceService {
throw new BaseException(CodeEnum.WBS_REPEAT_MEMBER_PHONE);
}
//判断各种证件是否为空
if(ObjectUtil.isNull(param.getCompeteId())){ throw new BaseException(CodeEnum.PARAM_ERROR); }
if(ObjectUtil.isNull(param.getGroupId())){ throw new BaseException(CodeEnum.PARAM_ERROR); }
if(ObjectUtil.isNull(param.getIdCardFront())){ throw new BaseException(CodeEnum.PARAM_ERROR); }
if(ObjectUtil.isNull(param.getIdPhone())){ throw new BaseException(CodeEnum.PARAM_ERROR); }
if(ObjectUtil.isNull(param.getStudentRecord())){ throw new BaseException(CodeEnum.PARAM_ERROR); }
if(ObjectUtil.isNull(param.getHealthRecord())){ throw new BaseException(CodeEnum.PARAM_ERROR); }
if(ObjectUtil.isNull(param.getInsuranceRecord())){ throw new BaseException(CodeEnum.PARAM_ERROR); }
if(ObjectUtil.isNull(param.getCompeteId())){ throw new BaseException(CodeEnum.PHOTO_IS_EMPTY); }
if(ObjectUtil.isNull(param.getGroupId())){ throw new BaseException(CodeEnum.PHOTO_IS_EMPTY); }
if(ObjectUtil.isNull(param.getIdCardFront())){ throw new BaseException(CodeEnum.PHOTO_IS_EMPTY); }
if(ObjectUtil.isNull(param.getIdPhone())){ throw new BaseException(CodeEnum.PHOTO_IS_EMPTY); }
if(ObjectUtil.isNull(param.getStudentRecord())){ throw new BaseException(CodeEnum.PHOTO_IS_EMPTY); }
if(ObjectUtil.isNull(param.getHealthRecord())){ throw new BaseException(CodeEnum.PHOTO_IS_EMPTY); }
if(ObjectUtil.isNull(param.getInsuranceRecord())){ throw new BaseException(CodeEnum.PHOTO_IS_EMPTY); }
player.setIdCard(param.getIdCard());
player.setCompanyId(param.getCompeteId());
player.setCompeteGroupId(param.getGroupId());
@ -248,49 +248,53 @@ public class ProvinceService implements IProvinceService {
if (ObjectUtil.isNull(companyid)){
Long id = snowflake.nextId();
competeCompany.setId(id);
competeCompany.setCoachNum(param.getCoachNum());
if (ObjectUtil.isNull(param.getCompanyName())){
throw new BaseException(CodeEnum.PARAM_ERROR);
// competeCompany.setCoachNum(param.getCoachNum());
if (StrUtil.isEmpty(param.getCompanyName())){
throw new BaseException(CodeEnum.NAME_EMPTY);
}
competeCompany.setName(param.getCompanyName());
if (ObjectUtil.isNull(param.getContactsName())){
throw new BaseException(CodeEnum.PARAM_ERROR);
if (StrUtil.isEmpty(param.getContactsName())){
throw new BaseException(CodeEnum.NAME_EMPTY);
}
competeCompany.setContactsName(param.getContactsName());
if (ObjectUtil.isNull(param.getContactsPhone())){
throw new BaseException(CodeEnum.PARAM_ERROR);
if(StrUtil.isEmpty(param.getContactsPhone()) || !param.getContactsPhone().matches(WebConstant.REGEX_PHONE)){
throw new BaseException(CodeEnum.PHONE_ERR);
}
competeCompany.setContactsPhone(param.getContactsPhone());
competeCompany.setLeaderNum(param.getGuideNum());
competeCompany.setJoinNum(param.getPlayerNum());
competeCompany.setUserId(userId);
competeCompany.setCompeteTimeId(param.getCompeteTimeId());
// if (ObjectUtil.isNull(authorization)){
// throw new BaseException(CodeEnum.PARAM_ERROR);
// }
if(param.getAuthorization() != 1){
throw new BaseException(CodeEnum.AUTHORIZATION_AGREE);
}
competeCompany.setAuthorization(param.getAuthorization());
competeCompanyDao.insertSelective(competeCompany);
}else {
//不为空,根据单位id查出来修改 判断传进来的参数是否为空 为空则跳过 不为空则修改
competeCompany = competeCompanyDao.selectByPrimaryKey(companyid);
if (ObjectUtil.isNotNull(param.getCoachNum())){
competeCompany.setCoachNum(param.getCoachNum());
}
if (ObjectUtil.isNotNull(param.getCompanyName())) {
// if (ObjectUtil.isNotNull(param.getCoachNum())){
// competeCompany.setCoachNum(param.getCoachNum());
// }
if (StrUtil.isNotEmpty(param.getCompanyName())) {
competeCompany.setName(param.getCompanyName());
}
if (ObjectUtil.isNotNull(param.getContactsName())) {
if (StrUtil.isNotEmpty(param.getContactsName())) {
competeCompany.setContactsName(param.getContactsName());
}
if (ObjectUtil.isNotNull(param.getContactsPhone())) {
if (StrUtil.isNotEmpty(param.getContactsPhone())) {
if(!param.getContactsPhone().matches(WebConstant.REGEX_PHONE)){
throw new BaseException(CodeEnum.PHONE_ERR);
}
competeCompany.setContactsPhone(param.getContactsPhone());
}
if (ObjectUtil.isNotNull(param.getGuideNum())) {
competeCompany.setLeaderNum(param.getGuideNum());
}
if (ObjectUtil.isNotNull(param.getPlayerNum())) {
competeCompany.setJoinNum(param.getPlayerNum());
}
// if (ObjectUtil.isNotNull(param.getGuideNum())) {
// competeCompany.setLeaderNum(param.getGuideNum());
// }
// if (ObjectUtil.isNotNull(param.getPlayerNum())) {
// competeCompany.setJoinNum(param.getPlayerNum());
// }
competeCompanyDao.updateByPrimaryKeySelective(competeCompany);
// competeCompany1.setCompanyId(competeCompany.getId());
// competeCompany1.setCoachNum(competeCompany.getCoachNum());
@ -308,9 +312,9 @@ public class ProvinceService implements IProvinceService {
@Override
public ProvinceCompeteVo.CompeteCompanyHeadList queryCoach(ProvinceCompeteDto.CompanyIdVo param) {
Long company = param.getCompanyId();
if (ObjectUtil.isNull(company)){
throw new BaseException(CodeEnum.PARAM_ERROR);
}
// if (ObjectUtil.isNull(company)){
// throw new BaseException(CodeEnum.PARAM_ERROR);
// }
CompeteCoachExample competeCoachExample = new CompeteCoachExample();
competeCoachExample.createCriteria().andCompanyIdEqualTo(company);
List<CompeteCoach> competeCoachList = competeCoachMapper.selectByExample(competeCoachExample);
@ -386,9 +390,10 @@ public class ProvinceService implements IProvinceService {
CompeteCoachExample competeCoachExample = new CompeteCoachExample();
competeCoachExample.createCriteria().andIdEqualTo(id);
competeCoachMapper.updateByExample(competeCoach,competeCoachExample);
}else {
throw new BaseException(CodeEnum.PARAM_ERROR);
}
// else {
// throw new BaseException(CodeEnum.PARAM_ERROR);
// }
}
@ -423,38 +428,15 @@ public class ProvinceService implements IProvinceService {
// CompetePlayerExample competePlayerExample = new CompetePlayerExample();
// competePlayerExample.createCriteria().andIdEqualTo(playerId);
// competePlayerMapper.updateByExampleSelective(competePlayer,competePlayerExample);
}else {
throw new BaseException(CodeEnum.PARAM_ERROR);
}
// else {
// throw new BaseException(CodeEnum.PARAM_ERROR);
// }
}
@Override
public ProvinceCompeteVo.PlayerInfo getPlayerInfo(CompeteDto.DelPlayer param) {
//<<<<<<< HEAD
return competePlayerDao.getPlayerByPlayerId(param.getPlayerId());
//=======
////
// Long playerId = param.getPlayerId();
// CompetePlayer competePlayer = competePlayerMapper.selectByPrimaryKey(playerId);
// if (ObjectUtil.isNull(competePlayer)){
// throw new BaseException(CodeEnum.PARAM_ERROR);
// }
//// ProvinceCompeteVo.PlayerInfo playerInfo = new ProvinceCompeteVo.PlayerInfo();
//// playerInfo.setPlayerId(competePlayer.getId());
//// playerInfo.setCompeteId(competePlayer.getCompeteTimeId());
//// playerInfo.setGroupId(competePlayer.getCompeteGroupId());
//// playerInfo.setPlayerName(competePlayer.getName());
//// playerInfo.setGender(competePlayer.getGender());
//// playerInfo.setIdCard(competePlayer.getIdCard());
//// playerInfo.setIdCardFront(competePlayer.getIdCardFront());
//// playerInfo.setIdCardBack(competePlayer.getIdCardBack());
//// playerInfo.setIdPhone(competePlayer.getIdPhotoFile());
//// playerInfo.setStudentRecord(competePlayer.getStudentRecordFile());
//// playerInfo.setHealthRecord(competePlayer.getHealthRecordFile());
//// playerInfo.setInsuranceRecord(competePlayer.getInsuranceRecordFile());
//// return playerInfo;
// return competePlayerDao.getPlayerByPlayerId(playerId);
//>>>>>>> f1a5f1b5d162548202a10e15eaec41aacda91a21
}
@Override
@ -471,24 +453,24 @@ public class ProvinceService implements IProvinceService {
}
//手机号不能为空,且正确
if(StrUtil.isEmpty(param.getPhone()) || !param.getPhone().matches(WebConstant.REGEX_PHONE)){
throw new BaseException(CodeEnum.PARAM_ERROR);
throw new BaseException(CodeEnum.PHONE_ERR);
}
//身份证不能为空,且正确
if(StrUtil.isEmpty(param.getIdCard()) || !IdcardUtil.isValidCard(param.getIdCard())){
throw new BaseException(CodeEnum.PARAM_ERROR);
throw new BaseException(CodeEnum.ID_CARD_ERROR);
}
//证件照判断
if (ObjectUtil.isNull(param.getIdPhoto())){
throw new BaseException(CodeEnum.PARAM_ERROR);
if (param.getIdentity() == 1 && ObjectUtil.isNull(param.getIdPhoto())){
throw new BaseException(CodeEnum.PHOTO_IS_EMPTY);
}
CompeteCoach competeCoach1 = new CompeteCoach();
competeCoach1.setId(snowflake.nextId());
BeanUtil.copyProperties(param, competeCoach1);
competeCoachMapper.insertSelective(competeCoach1);
}else {
CompeteCoach competeCoach2 = new CompeteCoach();
BeanUtil.copyProperties(param, competeCoach2);
competeCoachMapper.updateByPrimaryKeySelective(competeCoach2);
CompeteCoach competeCoach = competeCoachMapper.selectByPrimaryKey(param.getCoachId());
BeanUtil.copyProperties(param, competeCoach);
competeCoachMapper.updateByPrimaryKeySelective(competeCoach);
}
}
@ -501,20 +483,20 @@ public class ProvinceService implements IProvinceService {
CompeteProject competeProject = competeProjectMapper.selectByPrimaryKey(param.getProjectId());
if(ObjectUtil.isNull(competeProject)){ throw new BaseException(CodeEnum.PARAM_ERROR); }
//检查参赛人数是否符合
// if(CollectionUtil.isEmpty(param.getPlayers())){ throw new BaseException(CodeEnum.PARAM_ERROR); }
int joinCount = 0;
for(ProvinceCompeteDto.JoinProjectPlayer joinProject : param.getPlayers()){
if(joinProject.getJoinProject() == 1){
joinCount++;
}
}
if(joinCount > competeProject.getMemberMax() ){
throw new BaseException(CodeEnum.TEAM_MEMBER_ERROR);
}
// //检查参赛人数是否符合
// int joinCount = 0;
// for(ProvinceCompeteDto.JoinProjectPlayer joinProject : param.getPlayers()){
// if(joinProject.getJoinProject() == 1){
// joinCount++;
// }
// }
//// if(joinCount > competeProject.getMemberMax() ){
//// throw new BaseException(CodeEnum.TEAM_MEMBER_ERROR);
//// }
//判断项目是个人还是团队,参加
if(competeProject.getTeam() == 0){
param.getPlayers().forEach(joinPlayer -> {
// param.getPlayers().forEach(joinPlayer -> {
for(ProvinceCompeteDto.JoinProjectPlayer joinPlayer : param.getPlayers()){
//检查此用户之前是否参加此项目
CompeteProjectPlayerExample example = new CompeteProjectPlayerExample();
example.createCriteria().andProjectIdEqualTo(competeProject.getId()).andPlayerIdEqualTo(joinPlayer.getPlayerId())
@ -554,7 +536,8 @@ public class ProvinceService implements IProvinceService {
projectPlayer.setGenderGroup(player.getGender());
projectPlayerMapper.insertSelective(projectPlayer);
}
});
// });
}
}else {
//查找当前公司是否已经报名此项目
CompeteTeam competeTeam;
@ -573,6 +556,23 @@ public class ProvinceService implements IProvinceService {
competeTeamDao.insertSelective(competeTeam);
}
//检查参赛人数是否符合
int joinCount = 0;
for(ProvinceCompeteDto.JoinProjectPlayer joinProject : param.getPlayers()){
if(joinProject.getJoinProject() == 1){
joinCount++;
}else {
joinCount--;
}
}
CompeteTeamMemberExample example = new CompeteTeamMemberExample();
example.createCriteria().andCompeteTeamIdEqualTo(competeTeam.getId());
long memberNum = teamMemberMapper.countByExample(example);
if(joinCount + memberNum > competeProject.getMemberMax() ){
throw new BaseException(CodeEnum.TEAM_MEMBER_ERROR);
}
for (int i = 0; i < param.getPlayers().size(); i++) {
ProvinceCompeteDto.JoinProjectPlayer joinProjectPlayer = param.getPlayers().get(i);
CompetePlayer player = competePlayerDao.selectByPrimaryKey(joinProjectPlayer.getPlayerId());

19
mt/src/main/resources/mapper_dao/CompeteCompanyDao.xml

@ -39,6 +39,7 @@
cc.compete_time_id = #{competeTimeId}
and cc.user_id = #{userId}
and cc.rec_status = 0
limit 1
</select>
<select id="queryPlayerByGroupId" resultMap="group_player">
@ -160,28 +161,34 @@
where user_id = #{userId}
and compete_time_id = #{competeTimeId}
and rec_status = 0
limit 1
</select>
<select id="getJoinProjectNum" resultType="java.lang.Integer">
SELECT
a1.num + a2.num as num
FROM
(SELECT
count(p.id) as num
count(distinct p.id) as num
FROM
t_compete_project p
LEFT JOIN t_compete_project_player pp on p.id = pp.project_id
LEFT JOIN t_compete_player pl on pp.player_id = pl.id
WHERE
pl.company_id = #{competeTimeId}) a1,
pl.company_id = #{companyId}
and pp.rec_status = 0
and pl.rec_status = 0) a1,
(SELECT
count(p.id) as num
count(distinct p.id) as num
FROM
t_compete_project p
LEFT JOIN t_compete_team t on p.id = t.project_id
LEFT JOIN t_compete_team_member m on t.id = m.compete_team_id
LEFT JOIN t_compete_player pl on m.player_id = pl.id
WHERE
pl.company_id = #{competeTimeId})a2
pl.company_id = #{companyId}
and t.rec_status = 0
and m.rec_status = 0
and pl.rec_status = 0)a2
</select>
<select id="getNumByCompanyAndGroup" resultType="java.lang.Integer">
SELECT
@ -191,7 +198,7 @@
WHERE
pp.project_id = #{projectId}
and p.company_id = #{companyId}
and p.compete_time_id = #{competeTimeId}
and pp.compete_time_id = #{competeTimeId}
and p.compete_group_id = #{groupId}
and pp.rec_status = 0
and p.rec_status = 0
@ -216,7 +223,9 @@
gender,
phone,
id_card,
(SELECT id FROM t_common_file WHERE id = id_photo) as idPhotoId,
(SELECT visit_location FROM t_common_file WHERE id = id_photo) as idPhoto,
(SELECT id FROM t_common_file WHERE id = coach_certificate) as coachCertificateId,
(SELECT visit_location FROM t_common_file WHERE id = coach_certificate) as coachCertificate
FROM
t_compete_coach

6
mt/src/main/resources/mapper_dao/CompetePlayerDao.xml

@ -171,11 +171,17 @@
id_card as idCard,
company_id as competeId,
compete_group_id as groupId,
(SELECT id FROM t_common_file WHERE id = id_card_front_file) as idCardFrontId,
(SELECT visit_location FROM t_common_file WHERE id = id_card_front_file) as idCardFront,
(SELECT id FROM t_common_file WHERE id = id_card_back_file) as idCardBackId,
(SELECT visit_location FROM t_common_file WHERE id = id_card_back_file) as idCardBack,
(SELECT id FROM t_common_file WHERE id = id_photo_file) as idPhoneId,
(SELECT visit_location FROM t_common_file WHERE id = id_photo_file) as idPhone,
(SELECT id FROM t_common_file WHERE id = student_record_file) as studentRecordId,
(SELECT visit_location FROM t_common_file WHERE id = student_record_file) as studentRecord,
(SELECT id FROM t_common_file WHERE id = health_record_file) as healthRecordId,
(SELECT visit_location FROM t_common_file WHERE id = health_record_file) as healthRecord,
(SELECT id FROM t_common_file WHERE id = insurance_record_file) as insuranceRecordId,
(SELECT visit_location FROM t_common_file WHERE id = insurance_record_file) as insuranceRecord
FROM
t_compete_player

7
util/src/main/java/com/ccsens/util/CodeEnum.java

@ -163,13 +163,16 @@ public enum CodeEnum {
URL_ERROR(133, "请求路径转换异常", true),
JOIN_PROJECT_NUM_FULL(134, "可参赛次数已满", true),
PHOTO_FILE_EXCEED_2M(135, "图片大小不能超过2M", true),
COACH_NUM_FULL(136,"该单位领队或教练人数已达上限",true)
COACH_NUM_FULL(136,"该单位领队或教练人数已达上限",true),
AUTHORIZATION_AGREE(137,"请阅读并同意比赛协议",true),
NAME_EMPTY(138,"名称不能为空",true),
PHOTO_IS_EMPTY(139,"证件不能为空",true),
;
public CodeEnum mtProjectMsg(String msg){
this.msg = msg+this.msg;
this.msg = msg+"可参赛次数已满";
return this;
}
public CodeEnum addMsg(String msg){

5
util/src/main/java/com/ccsens/util/WebConstant.java

@ -5,6 +5,8 @@ import cn.hutool.core.util.URLUtil;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.io.File;
public class WebConstant {
@ -17,7 +19,8 @@ public class WebConstant {
public static final byte STATUS_DELETE = 1;
public static final String IMG_TYPE = "bmp,jpg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp,jpeg";
/**手机号正则*/
public static final String REGEX_PHONE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
// public static final String REGEX_PHONE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,1-9]))\\d{8}$";
public static final String REGEX_PHONE = "^[1]([3-9])[0-9]{9}$";
/**属性名*/
public static class Field{

4
util/src/test/java/com/ccsens/util/OtherTest.java

@ -12,11 +12,11 @@ import javax.script.ScriptException;
public class OtherTest {
public static final String REGEX_PHONE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
public static final String REGEX_PHONE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,1-9]))\\d{8}$";
@Test
public void test2() throws ScriptException {
String str = "11100000000";
String str = "18200000000";
if (str.matches(REGEX_PHONE)) {
System.out.println("是手机号");
} else {

Loading…
Cancel
Save