diff --git a/mt/src/main/java/com/ccsens/mt/api/CompeteController.java b/mt/src/main/java/com/ccsens/mt/api/CompeteController.java index 9e6f45cb..06c55498 100644 --- a/mt/src/main/java/com/ccsens/mt/api/CompeteController.java +++ b/mt/src/main/java/com/ccsens/mt/api/CompeteController.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.io.IOException; import java.util.List; /** @@ -88,7 +89,7 @@ public class CompeteController { @MustLogin @ApiOperation(value = "提交选择的比赛项目", notes = "") @RequestMapping(value = "/save/project", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) - public JsonResponse saveCompeteProject(@ApiParam @Validated @RequestBody QueryDto params) { + public JsonResponse saveCompeteProject(@ApiParam @Validated @RequestBody QueryDto params) throws IOException { log.info("提交选择的比赛项目:{}",params); CompeteVo.CompetePlayerInfo competePlayerInfo = competeService.saveCompeteProject(params); return JsonResponse.newInstance().ok(competePlayerInfo); diff --git a/mt/src/main/java/com/ccsens/mt/bean/po/CompetePlayer.java b/mt/src/main/java/com/ccsens/mt/bean/po/CompetePlayer.java index 24b27dc6..a35b7935 100644 --- a/mt/src/main/java/com/ccsens/mt/bean/po/CompetePlayer.java +++ b/mt/src/main/java/com/ccsens/mt/bean/po/CompetePlayer.java @@ -24,7 +24,7 @@ public class CompetePlayer implements Serializable { private Long competeGroupId; - private String companyName; + private Long companyId; private Byte authorization; @@ -116,12 +116,12 @@ public class CompetePlayer implements Serializable { this.competeGroupId = competeGroupId; } - public String getCompanyName() { - return companyName; + public Long getCompanyId() { + return companyId; } - public void setCompanyName(String companyName) { - this.companyName = companyName == null ? null : companyName.trim(); + public void setCompanyId(Long companyId) { + this.companyId = companyId; } public Byte getAuthorization() { @@ -172,7 +172,7 @@ public class CompetePlayer implements Serializable { sb.append(", idCardBack=").append(idCardBack); sb.append(", proveImg=").append(proveImg); sb.append(", competeGroupId=").append(competeGroupId); - sb.append(", companyName=").append(companyName); + sb.append(", companyId=").append(companyId); sb.append(", authorization=").append(authorization); sb.append(", createdAt=").append(createdAt); sb.append(", updatedAt=").append(updatedAt); diff --git a/mt/src/main/java/com/ccsens/mt/bean/po/CompetePlayerExample.java b/mt/src/main/java/com/ccsens/mt/bean/po/CompetePlayerExample.java index 4ea07bd4..96552c90 100644 --- a/mt/src/main/java/com/ccsens/mt/bean/po/CompetePlayerExample.java +++ b/mt/src/main/java/com/ccsens/mt/bean/po/CompetePlayerExample.java @@ -765,73 +765,63 @@ public class CompetePlayerExample { return (Criteria) this; } - public Criteria andCompanyNameIsNull() { - addCriterion("company_name is null"); + public Criteria andCompanyIdIsNull() { + addCriterion("company_id is null"); return (Criteria) this; } - public Criteria andCompanyNameIsNotNull() { - addCriterion("company_name is not null"); + public Criteria andCompanyIdIsNotNull() { + addCriterion("company_id is not null"); return (Criteria) this; } - public Criteria andCompanyNameEqualTo(String value) { - addCriterion("company_name =", value, "companyName"); + public Criteria andCompanyIdEqualTo(Long value) { + addCriterion("company_id =", value, "companyId"); return (Criteria) this; } - public Criteria andCompanyNameNotEqualTo(String value) { - addCriterion("company_name <>", value, "companyName"); + public Criteria andCompanyIdNotEqualTo(Long value) { + addCriterion("company_id <>", value, "companyId"); return (Criteria) this; } - public Criteria andCompanyNameGreaterThan(String value) { - addCriterion("company_name >", value, "companyName"); + public Criteria andCompanyIdGreaterThan(Long value) { + addCriterion("company_id >", value, "companyId"); return (Criteria) this; } - public Criteria andCompanyNameGreaterThanOrEqualTo(String value) { - addCriterion("company_name >=", value, "companyName"); + public Criteria andCompanyIdGreaterThanOrEqualTo(Long value) { + addCriterion("company_id >=", value, "companyId"); return (Criteria) this; } - public Criteria andCompanyNameLessThan(String value) { - addCriterion("company_name <", value, "companyName"); + public Criteria andCompanyIdLessThan(Long value) { + addCriterion("company_id <", value, "companyId"); return (Criteria) this; } - public Criteria andCompanyNameLessThanOrEqualTo(String value) { - addCriterion("company_name <=", value, "companyName"); + public Criteria andCompanyIdLessThanOrEqualTo(Long value) { + addCriterion("company_id <=", value, "companyId"); return (Criteria) this; } - public Criteria andCompanyNameLike(String value) { - addCriterion("company_name like", value, "companyName"); + public Criteria andCompanyIdIn(List values) { + addCriterion("company_id in", values, "companyId"); return (Criteria) this; } - public Criteria andCompanyNameNotLike(String value) { - addCriterion("company_name not like", value, "companyName"); + public Criteria andCompanyIdNotIn(List values) { + addCriterion("company_id not in", values, "companyId"); return (Criteria) this; } - public Criteria andCompanyNameIn(List values) { - addCriterion("company_name in", values, "companyName"); + public Criteria andCompanyIdBetween(Long value1, Long value2) { + addCriterion("company_id between", value1, value2, "companyId"); return (Criteria) this; } - public Criteria andCompanyNameNotIn(List values) { - addCriterion("company_name not in", values, "companyName"); - return (Criteria) this; - } - - public Criteria andCompanyNameBetween(String value1, String value2) { - addCriterion("company_name between", value1, value2, "companyName"); - return (Criteria) this; - } - - public Criteria andCompanyNameNotBetween(String value1, String value2) { - addCriterion("company_name not between", value1, value2, "companyName"); + public Criteria andCompanyIdNotBetween(Long value1, Long value2) { + addCriterion("company_id not between", value1, value2, "companyId"); return (Criteria) this; } diff --git a/mt/src/main/java/com/ccsens/mt/bean/po/CompeteProjectPlayer.java b/mt/src/main/java/com/ccsens/mt/bean/po/CompeteProjectPlayer.java index e055aa72..e62d764d 100644 --- a/mt/src/main/java/com/ccsens/mt/bean/po/CompeteProjectPlayer.java +++ b/mt/src/main/java/com/ccsens/mt/bean/po/CompeteProjectPlayer.java @@ -8,7 +8,7 @@ public class CompeteProjectPlayer implements Serializable { private Long playerId; - private Long porjectId; + private Long projectId; private Long competeTimeId; @@ -40,12 +40,12 @@ public class CompeteProjectPlayer implements Serializable { this.playerId = playerId; } - public Long getPorjectId() { - return porjectId; + public Long getProjectId() { + return projectId; } - public void setPorjectId(Long porjectId) { - this.porjectId = porjectId; + public void setProjectId(Long projectId) { + this.projectId = projectId; } public Long getCompeteTimeId() { @@ -104,7 +104,7 @@ public class CompeteProjectPlayer implements Serializable { sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); sb.append(", playerId=").append(playerId); - sb.append(", porjectId=").append(porjectId); + sb.append(", projectId=").append(projectId); sb.append(", competeTimeId=").append(competeTimeId); sb.append(", genderGroup=").append(genderGroup); sb.append(", certificate=").append(certificate); diff --git a/mt/src/main/java/com/ccsens/mt/bean/po/CompeteProjectPlayerExample.java b/mt/src/main/java/com/ccsens/mt/bean/po/CompeteProjectPlayerExample.java index 25542cec..8ab4278d 100644 --- a/mt/src/main/java/com/ccsens/mt/bean/po/CompeteProjectPlayerExample.java +++ b/mt/src/main/java/com/ccsens/mt/bean/po/CompeteProjectPlayerExample.java @@ -225,63 +225,63 @@ public class CompeteProjectPlayerExample { return (Criteria) this; } - public Criteria andPorjectIdIsNull() { - addCriterion("porject_id is null"); + public Criteria andProjectIdIsNull() { + addCriterion("project_id is null"); return (Criteria) this; } - public Criteria andPorjectIdIsNotNull() { - addCriterion("porject_id is not null"); + public Criteria andProjectIdIsNotNull() { + addCriterion("project_id is not null"); return (Criteria) this; } - public Criteria andPorjectIdEqualTo(Long value) { - addCriterion("porject_id =", value, "porjectId"); + public Criteria andProjectIdEqualTo(Long value) { + addCriterion("project_id =", value, "projectId"); return (Criteria) this; } - public Criteria andPorjectIdNotEqualTo(Long value) { - addCriterion("porject_id <>", value, "porjectId"); + public Criteria andProjectIdNotEqualTo(Long value) { + addCriterion("project_id <>", value, "projectId"); return (Criteria) this; } - public Criteria andPorjectIdGreaterThan(Long value) { - addCriterion("porject_id >", value, "porjectId"); + public Criteria andProjectIdGreaterThan(Long value) { + addCriterion("project_id >", value, "projectId"); return (Criteria) this; } - public Criteria andPorjectIdGreaterThanOrEqualTo(Long value) { - addCriterion("porject_id >=", value, "porjectId"); + public Criteria andProjectIdGreaterThanOrEqualTo(Long value) { + addCriterion("project_id >=", value, "projectId"); return (Criteria) this; } - public Criteria andPorjectIdLessThan(Long value) { - addCriterion("porject_id <", value, "porjectId"); + public Criteria andProjectIdLessThan(Long value) { + addCriterion("project_id <", value, "projectId"); return (Criteria) this; } - public Criteria andPorjectIdLessThanOrEqualTo(Long value) { - addCriterion("porject_id <=", value, "porjectId"); + public Criteria andProjectIdLessThanOrEqualTo(Long value) { + addCriterion("project_id <=", value, "projectId"); return (Criteria) this; } - public Criteria andPorjectIdIn(List values) { - addCriterion("porject_id in", values, "porjectId"); + public Criteria andProjectIdIn(List values) { + addCriterion("project_id in", values, "projectId"); return (Criteria) this; } - public Criteria andPorjectIdNotIn(List values) { - addCriterion("porject_id not in", values, "porjectId"); + public Criteria andProjectIdNotIn(List values) { + addCriterion("project_id not in", values, "projectId"); return (Criteria) this; } - public Criteria andPorjectIdBetween(Long value1, Long value2) { - addCriterion("porject_id between", value1, value2, "porjectId"); + public Criteria andProjectIdBetween(Long value1, Long value2) { + addCriterion("project_id between", value1, value2, "projectId"); return (Criteria) this; } - public Criteria andPorjectIdNotBetween(Long value1, Long value2) { - addCriterion("porject_id not between", value1, value2, "porjectId"); + public Criteria andProjectIdNotBetween(Long value1, Long value2) { + addCriterion("project_id not between", value1, value2, "projectId"); return (Criteria) this; } diff --git a/mt/src/main/java/com/ccsens/mt/service/CompeteService.java b/mt/src/main/java/com/ccsens/mt/service/CompeteService.java index aeb3d104..92560800 100644 --- a/mt/src/main/java/com/ccsens/mt/service/CompeteService.java +++ b/mt/src/main/java/com/ccsens/mt/service/CompeteService.java @@ -13,6 +13,9 @@ import com.ccsens.util.CodeEnum; import com.ccsens.mt.persist.dao.CompeteTimeDao; import com.ccsens.util.PropUtil; import com.ccsens.util.QrCodeUtil; +import com.ccsens.mt.persist.mapper.CompeteCompanyMapper; +import com.ccsens.mt.util.Constant; +import com.ccsens.util.RedisUtil; import com.ccsens.util.bean.dto.QueryDto; import com.ccsens.util.exception.BaseException; import lombok.extern.slf4j.Slf4j; @@ -22,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.IOException; +import java.util.ArrayList; import java.util.List; /** @@ -35,6 +39,8 @@ public class CompeteService implements ICompeteService{ private CompeteTimeDao competeTimeDao; @Resource private CompeteCompanyMapper competeCompanyMapper; + @Resource + private RedisUtil redisUtil; @Resource private CompeteTeamDao competeTeamDao; @@ -75,8 +81,21 @@ public class CompeteService implements ICompeteService{ */ @Override public List queryCompeteCompany(QueryDto params) { - - return null; + CompeteDto.CompeteTypeAndKey competeTypeAndKey = params.getParam(); + String key = competeTypeAndKey.getType() + Constant.Redis.COMPETE_COMPANY; + Object list = redisUtil.lGet(key,0,-1); + List competeCompanyList = (List) list; + List companyList = new ArrayList<>(); + System.out.println(competeCompanyList); + competeCompanyList.forEach(competeCompany -> { + if(competeCompany.getName().contains(competeTypeAndKey.getKey())){ + CompeteVo.CompeteCompany company = new CompeteVo.CompeteCompany(); + company.setGroupId(competeCompany.getId()); + company.setGroupName(competeCompany.getName()); + companyList.add(company); + } + }); + return companyList; } /** @@ -90,10 +109,8 @@ public class CompeteService implements ICompeteService{ competeCompanyExample.createCriteria().andTypeEqualTo((byte) competeType.getType()); List competeCompanyList = competeCompanyMapper.selectByExample(competeCompanyExample); if(CollectionUtil.isNotEmpty(competeCompanyList)){ - competeCompanyList.forEach(competeCompany -> { - //将单位信息存入redis -// String companyKey = Constant. - }); + String key = competeType.getType() + Constant.Redis.COMPETE_COMPANY; + redisUtil.lSet(key,competeCompanyList,Constant.Redis.COMPETE_COMPANY_TIME); } } @@ -137,7 +154,7 @@ public class CompeteService implements ICompeteService{ CompeteProjectPlayer projectPlayer = new CompeteProjectPlayer(); projectPlayer.setId(snowflake.nextId()); projectPlayer.setPlayerId(player.getId()); - projectPlayer.setPorjectId(project.getId()); + projectPlayer.setProjectId(project.getId()); projectPlayer.setCompeteTimeId(params.getParam().getCompeteTimeId()); projectPlayer.setGenderGroup(player.getGender()); projectPlayer.setCertificate(params.getParam().getCertificate()); @@ -299,12 +316,12 @@ public class CompeteService implements ICompeteService{ // 同单位同组别 // 1.与队长同单位且同组别 if (pageLeader) { - if (!player.getCompanyName().equals(creator.getCompanyName())) { - log.info("单位不一样:{},{}",player.getCompanyName(), creator.getCompanyName()); + if (!player.getCompanyId().equals(creator.getCompanyId())) { + log.info("单位不一样:{},{}",player.getCompanyId(), creator.getCompanyId()); throw new BaseException(CodeEnum.TEAM_COMPANY_NOT_SAME); } if (player.getCompeteGroupId().longValue() != creator.getCompeteGroupId().longValue()) { - log.info("组别不一样:{},{}",player.getCompanyName(), creator.getCompanyName()); + log.info("组别不一样:{},{}",player.getCompanyId(), creator.getCompanyId()); throw new BaseException(CodeEnum.TEAM_GROUP_NOT_SAME); } } @@ -317,8 +334,8 @@ public class CompeteService implements ICompeteService{ // 同单位不限组别 // 1.用户与队长同单位 if (pageLeader) { - if (!player.getCompanyName().equals(creator.getCompanyName())) { - log.info("单位不一样:{},{}", player.getCompanyName(), creator.getCompanyName()); + if (!player.getCompanyId().equals(creator.getCompanyId())) { + log.info("单位不一样:{},{}", player.getCompanyId(), creator.getCompanyId()); throw new BaseException(CodeEnum.TEAM_COMPANY_NOT_SAME); } } diff --git a/mt/src/main/java/com/ccsens/mt/util/Constant.java b/mt/src/main/java/com/ccsens/mt/util/Constant.java index 50233a2a..51e556c8 100644 --- a/mt/src/main/java/com/ccsens/mt/util/Constant.java +++ b/mt/src/main/java/com/ccsens/mt/util/Constant.java @@ -24,7 +24,7 @@ public class Constant { //投票已结束 public final static int VOTE_START = 1; // 远程比赛参赛单位 - public final static String COMPETE_COMPANY = "_compete_company_"; + public final static String COMPETE_COMPANY = "_compete_company"; // 远程比赛参赛单位存在时间10天 public final static long COMPETE_COMPANY_TIME = 10 * 24 * 60 * 60; } diff --git a/mt/src/main/resources/mapper_raw/CompetePlayerMapper.xml b/mt/src/main/resources/mapper_raw/CompetePlayerMapper.xml index 23ea036b..52d11ab2 100644 --- a/mt/src/main/resources/mapper_raw/CompetePlayerMapper.xml +++ b/mt/src/main/resources/mapper_raw/CompetePlayerMapper.xml @@ -12,7 +12,7 @@ - + @@ -78,7 +78,7 @@ id, user_id, name, id_card, phone, gender, id_card_front, id_card_back, prove_img, - compete_group_id, company_name, authorization, created_at, updated_at, rec_status + compete_group_id, company_id, authorization, created_at, updated_at, rec_status @@ -105,11 +105,11 @@ - insert into t_compete_project_player (id, player_id, porject_id, + insert into t_compete_project_player (id, player_id, project_id, compete_time_id, gender_group, certificate, created_at, updated_at, rec_status ) - values (#{id,jdbcType=BIGINT}, #{playerId,jdbcType=BIGINT}, #{porjectId,jdbcType=BIGINT}, + values (#{id,jdbcType=BIGINT}, #{playerId,jdbcType=BIGINT}, #{projectId,jdbcType=BIGINT}, #{competeTimeId,jdbcType=BIGINT}, #{genderGroup,jdbcType=TINYINT}, #{certificate,jdbcType=TINYINT}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT} ) @@ -123,8 +123,8 @@ player_id, - - porject_id, + + project_id, compete_time_id, @@ -152,8 +152,8 @@ #{playerId,jdbcType=BIGINT}, - - #{porjectId,jdbcType=BIGINT}, + + #{projectId,jdbcType=BIGINT}, #{competeTimeId,jdbcType=BIGINT}, @@ -190,8 +190,8 @@ player_id = #{record.playerId,jdbcType=BIGINT}, - - porject_id = #{record.porjectId,jdbcType=BIGINT}, + + project_id = #{record.projectId,jdbcType=BIGINT}, compete_time_id = #{record.competeTimeId,jdbcType=BIGINT}, @@ -220,7 +220,7 @@ update t_compete_project_player set id = #{record.id,jdbcType=BIGINT}, player_id = #{record.playerId,jdbcType=BIGINT}, - porject_id = #{record.porjectId,jdbcType=BIGINT}, + project_id = #{record.projectId,jdbcType=BIGINT}, compete_time_id = #{record.competeTimeId,jdbcType=BIGINT}, gender_group = #{record.genderGroup,jdbcType=TINYINT}, certificate = #{record.certificate,jdbcType=TINYINT}, @@ -237,8 +237,8 @@ player_id = #{playerId,jdbcType=BIGINT}, - - porject_id = #{porjectId,jdbcType=BIGINT}, + + project_id = #{projectId,jdbcType=BIGINT}, compete_time_id = #{competeTimeId,jdbcType=BIGINT}, @@ -264,7 +264,7 @@ update t_compete_project_player set player_id = #{playerId,jdbcType=BIGINT}, - porject_id = #{porjectId,jdbcType=BIGINT}, + project_id = #{projectId,jdbcType=BIGINT}, compete_time_id = #{competeTimeId,jdbcType=BIGINT}, gender_group = #{genderGroup,jdbcType=TINYINT}, certificate = #{certificate,jdbcType=TINYINT},