diff --git a/competition/src/main/java/com/huoran/competition/controller/CompetitionClassificationController.java b/competition/src/main/java/com/huoran/competition/controller/CompetitionClassificationController.java new file mode 100644 index 0000000..ff13ba8 --- /dev/null +++ b/competition/src/main/java/com/huoran/competition/controller/CompetitionClassificationController.java @@ -0,0 +1,70 @@ +package com.huoran.competition.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.huoran.api.UserClient; +import com.huoran.common.response.R; +import com.huoran.common.utils.TokenUtils; +import com.huoran.competition.entity.CompetitionClassification; +import com.huoran.competition.service.CompetitionClassificationService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * @描述:活动活动分类控制类 + * @作者: Rong + * @日期: 2023-12-27 + */ +@RestController +@RequestMapping("/competitionClassification") +@Api(value = "活动分类:CompetitionClassificationController", tags = "活动分类") +public class CompetitionClassificationController { + + @Autowired + public CompetitionClassificationService service; + + @Autowired + private UserClient userClient; + + @PostMapping("/categoryList") + @ApiOperation(value = "分类列表", response = CompetitionClassification.class) + public R categoryList() { + List list = service.list( null); + return R.ok().put("page",list); + } + + + @PostMapping("/save") + @ApiOperation(value = "自定义新增活动分类", response = CompetitionClassification.class) + public R save(@RequestBody @ApiParam(name = "活动活动分类对象", value = "传入json格式", required = true) CompetitionClassification competitionClassification, HttpServletRequest request) { + String accountId = TokenUtils.getIdByJwtToken(request); + competitionClassification.setAccountId(Integer.valueOf(accountId)); + boolean addState = service.save(competitionClassification); + return addState ? R.ok() : R.error("新增失败"); + } + + + @PostMapping("/update") + @ApiOperation(value = "修改活动分类", response = CompetitionClassification.class) + public R update(@RequestBody @ApiParam(name = "活动活动分类对象", value = "传入json格式", required = true) CompetitionClassification competitionClassification, HttpServletRequest request) { + String accountId = TokenUtils.getIdByJwtToken(request); + competitionClassification.setAccountId(Integer.valueOf(accountId)); + boolean updateState = service.updateById(competitionClassification); + return updateState ? R.ok() : R.error("编辑失败"); + } + + + @PostMapping("/batchDeletion") + @ApiOperation(value = "批量删除活动分类", response = CompetitionClassification.class) + public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestBody List ids) { + boolean delState = service.removeByIds(ids); + return delState ? R.ok() : R.error("删除失败"); + } +} + diff --git a/competition/src/main/java/com/huoran/competition/controller/CompetitionController.java b/competition/src/main/java/com/huoran/competition/controller/CompetitionController.java index cce2e03..783921e 100644 --- a/competition/src/main/java/com/huoran/competition/controller/CompetitionController.java +++ b/competition/src/main/java/com/huoran/competition/controller/CompetitionController.java @@ -51,6 +51,9 @@ public class CompetitionController { @Autowired private UserClient userClient; + + @Autowired + public CompetitionClassificationService competitionClassificationService; @Autowired private CompetitionService competitionService; @@ -150,6 +153,7 @@ public class CompetitionController { public R getCompetition(@ApiParam(name = "competitionId", value = "活动ID", required = true) @RequestParam("competitionId") String competitionId, HttpServletRequest request) { String accountId = TokenUtils.getIdByJwtToken(request); Competition competition = competitionService.getById(competitionId); + // 查询活动报名表 QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("competition_id", competitionId); diff --git a/competition/src/main/java/com/huoran/competition/entity/Competition.java b/competition/src/main/java/com/huoran/competition/entity/Competition.java index c9c2eb4..27489b7 100644 --- a/competition/src/main/java/com/huoran/competition/entity/Competition.java +++ b/competition/src/main/java/com/huoran/competition/entity/Competition.java @@ -108,6 +108,9 @@ public class Competition implements Serializable { @ApiModelProperty(value = "数量上限限制") private Integer quantityLimit; + @ApiModelProperty(value = "活动分类id") + private Integer classificationId; + @ApiModelProperty(value = "邀请码") private String invitationCode; @@ -137,6 +140,8 @@ public class Competition implements Serializable { @TableField(exist = false) private CompetitionRegistration competitionRegistration; - + @ApiModelProperty(value = "活动分类名称") + @TableField(exist = false) + private String classificationName; } diff --git a/competition/src/main/java/com/huoran/competition/entity/CompetitionClassification.java b/competition/src/main/java/com/huoran/competition/entity/CompetitionClassification.java new file mode 100644 index 0000000..c4dca54 --- /dev/null +++ b/competition/src/main/java/com/huoran/competition/entity/CompetitionClassification.java @@ -0,0 +1,43 @@ +package com.huoran.competition.entity; + +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @描述:活动分类 + * @作者: Rong + * @日期: 2023-12-27 + */ +@Data +@ApiModel(value = "活动分类") +@TableName("c_competition_classification") +public class CompetitionClassification implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + @ApiModelProperty(value = "活动分类主键") + private Integer id; + + @ApiModelProperty(value = "活动分类名称") + private String classificationName; + + @ApiModelProperty(value = "创建人") + private Integer accountId; + + + @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @ApiModelProperty(value = "更新时间") + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + +} \ No newline at end of file diff --git a/competition/src/main/java/com/huoran/competition/entity/req/AfterLoginPageCompetitionListReq.java b/competition/src/main/java/com/huoran/competition/entity/req/AfterLoginPageCompetitionListReq.java index f48250b..a8c28ca 100644 --- a/competition/src/main/java/com/huoran/competition/entity/req/AfterLoginPageCompetitionListReq.java +++ b/competition/src/main/java/com/huoran/competition/entity/req/AfterLoginPageCompetitionListReq.java @@ -35,4 +35,7 @@ public class AfterLoginPageCompetitionListReq extends PageReq{ @ApiModelProperty(value = "读取的列表(0:首页活动/1.已报名活动)", example = "5") private Integer listType; + + @ApiModelProperty(value = "活动分类id") + private Integer classificationId; } \ No newline at end of file diff --git a/competition/src/main/java/com/huoran/competition/entity/vo/CompetitionVO.java b/competition/src/main/java/com/huoran/competition/entity/vo/CompetitionVO.java index 9ecee45..3d2347a 100644 --- a/competition/src/main/java/com/huoran/competition/entity/vo/CompetitionVO.java +++ b/competition/src/main/java/com/huoran/competition/entity/vo/CompetitionVO.java @@ -153,4 +153,11 @@ public class CompetitionVO implements Serializable { @ApiModelProperty(value = "是否展示报名人员(0否,1是)") private String whetherToShowApplicants; + @ApiModelProperty(value = "分类名称") + private String classificationName; + + @ApiModelProperty(value = "活动分类id") + private Integer classificationId; + + } diff --git a/competition/src/main/java/com/huoran/competition/mapper/CompetitionClassificationMapper.java b/competition/src/main/java/com/huoran/competition/mapper/CompetitionClassificationMapper.java new file mode 100644 index 0000000..563687c --- /dev/null +++ b/competition/src/main/java/com/huoran/competition/mapper/CompetitionClassificationMapper.java @@ -0,0 +1,16 @@ +package com.huoran.competition.mapper; + +import com.huoran.competition.entity.CompetitionClassification; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 活动分类 Mapper 接口 + *

+ * + * @author cheney + * @since 2023-12-27 + */ +public interface CompetitionClassificationMapper extends BaseMapper { + +} diff --git a/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionClassificationMapper.xml b/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionClassificationMapper.xml new file mode 100644 index 0000000..996e00c --- /dev/null +++ b/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionClassificationMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionMapper.xml b/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionMapper.xml index 753caa7..d341c33 100644 --- a/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionMapper.xml +++ b/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionMapper.xml @@ -696,16 +696,22 @@ ( CASE create_source WHEN 0 THEN '平台创建' WHEN 1 THEN '组织创建' ELSE '无' END ) AS createSource, IF ( - ( SELECT r.id FROM c_competition_registration r WHERE r.competition_id = c.id AND r.account_id = #{req.accountId} ) IS NULL, + ( SELECT r.id FROM c_competition_registration r WHERE r.competition_id = c.id AND r.account_id = 4940 ) IS NULL, 1, 0 - ) AS whetherToSignUp + ) AS whetherToSignUp, + cla.classification_name, + c.classification_id FROM c_competition c + INNER JOIN c_competition_classification cla ON c.classification_id = cla.id WHERE c.is_open = 0 AND c.publish_status = 1 + + and c.classification_id=#{req.classificationId} + and create_time between #{req.startTime} and #{req.endTime} @@ -771,10 +777,13 @@ c.is_open, create_source, ( CASE create_source WHEN 0 THEN '平台创建' WHEN 1 THEN '组织创建' ELSE '无' END ) AS createSource, - ( SELECT d.id FROM c_competition_user_del d WHERE d.account_id = r.account_id AND d.competition_id = c.id ) AS isDelCompetition + ( SELECT d.id FROM c_competition_user_del d WHERE d.account_id = r.account_id AND d.competition_id = c.id ) AS isDelCompetition, + cla.classification_name, + c.classification_id FROM c_competition_registration r INNER JOIN c_competition c ON c.id = r.competition_id + INNER JOIN c_competition_classification cla ON c.classification_id = cla.id WHERE r.account_id = #{req.accountId} @@ -783,6 +792,10 @@ WHERE t.isDelCompetition IS NULL + + and t.classification_id =#{req.classificationId} + + and t.create_time between #{req.startTime} and #{req.endTime} diff --git a/competition/src/main/java/com/huoran/competition/service/CompetitionClassificationService.java b/competition/src/main/java/com/huoran/competition/service/CompetitionClassificationService.java new file mode 100644 index 0000000..de43b11 --- /dev/null +++ b/competition/src/main/java/com/huoran/competition/service/CompetitionClassificationService.java @@ -0,0 +1,16 @@ +package com.huoran.competition.service; + +import com.huoran.competition.entity.CompetitionClassification; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 活动分类 服务类 + *

+ * + * @author cheney + * @since 2023-12-27 + */ +public interface CompetitionClassificationService extends IService { + +} diff --git a/competition/src/main/java/com/huoran/competition/service/impl/CompetitionClassificationServiceImpl.java b/competition/src/main/java/com/huoran/competition/service/impl/CompetitionClassificationServiceImpl.java new file mode 100644 index 0000000..fe31107 --- /dev/null +++ b/competition/src/main/java/com/huoran/competition/service/impl/CompetitionClassificationServiceImpl.java @@ -0,0 +1,20 @@ +package com.huoran.competition.service.impl; + +import com.huoran.competition.entity.CompetitionClassification; +import com.huoran.competition.mapper.CompetitionClassificationMapper; +import com.huoran.competition.service.CompetitionClassificationService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 活动分类 服务实现类 + *

+ * + * @author cheney + * @since 2023-12-27 + */ +@Service +public class CompetitionClassificationServiceImpl extends ServiceImpl implements CompetitionClassificationService { + +} diff --git a/competition/src/test/java/CodeGenerator.java b/competition/src/test/java/CodeGenerator.java index cebfc46..a90c5cc 100644 --- a/competition/src/test/java/CodeGenerator.java +++ b/competition/src/test/java/CodeGenerator.java @@ -60,7 +60,7 @@ public class CodeGenerator { // 5、策略配置 StrategyConfig strategy = new StrategyConfig(); - strategy.setInclude("c_competition_user_del"); + strategy.setInclude("c_competition_classification"); strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 strategy.setTablePrefix("c_"); //生成实体时去掉表前缀