活动增加分类

main
rong.liu 11 months ago
parent 3e05b6a517
commit 2cfb1e1327
  1. 70
      competition/src/main/java/com/huoran/competition/controller/CompetitionClassificationController.java
  2. 4
      competition/src/main/java/com/huoran/competition/controller/CompetitionController.java
  3. 7
      competition/src/main/java/com/huoran/competition/entity/Competition.java
  4. 43
      competition/src/main/java/com/huoran/competition/entity/CompetitionClassification.java
  5. 3
      competition/src/main/java/com/huoran/competition/entity/req/AfterLoginPageCompetitionListReq.java
  6. 7
      competition/src/main/java/com/huoran/competition/entity/vo/CompetitionVO.java
  7. 16
      competition/src/main/java/com/huoran/competition/mapper/CompetitionClassificationMapper.java
  8. 5
      competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionClassificationMapper.xml
  9. 19
      competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionMapper.xml
  10. 16
      competition/src/main/java/com/huoran/competition/service/CompetitionClassificationService.java
  11. 20
      competition/src/main/java/com/huoran/competition/service/impl/CompetitionClassificationServiceImpl.java
  12. 2
      competition/src/test/java/CodeGenerator.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<CompetitionClassification> 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<Integer> ids) {
boolean delState = service.removeByIds(ids);
return delState ? R.ok() : R.error("删除失败");
}
}

@ -51,6 +51,9 @@ public class CompetitionController {
@Autowired @Autowired
private UserClient userClient; private UserClient userClient;
@Autowired
public CompetitionClassificationService competitionClassificationService;
@Autowired @Autowired
private CompetitionService competitionService; 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) { public R getCompetition(@ApiParam(name = "competitionId", value = "活动ID", required = true) @RequestParam("competitionId") String competitionId, HttpServletRequest request) {
String accountId = TokenUtils.getIdByJwtToken(request); String accountId = TokenUtils.getIdByJwtToken(request);
Competition competition = competitionService.getById(competitionId); Competition competition = competitionService.getById(competitionId);
// 查询活动报名表 // 查询活动报名表
QueryWrapper<CompetitionRegistration> wrapper = new QueryWrapper<>(); QueryWrapper<CompetitionRegistration> wrapper = new QueryWrapper<>();
wrapper.eq("competition_id", competitionId); wrapper.eq("competition_id", competitionId);

@ -108,6 +108,9 @@ public class Competition implements Serializable {
@ApiModelProperty(value = "数量上限限制") @ApiModelProperty(value = "数量上限限制")
private Integer quantityLimit; private Integer quantityLimit;
@ApiModelProperty(value = "活动分类id")
private Integer classificationId;
@ApiModelProperty(value = "邀请码") @ApiModelProperty(value = "邀请码")
private String invitationCode; private String invitationCode;
@ -137,6 +140,8 @@ public class Competition implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private CompetitionRegistration competitionRegistration; private CompetitionRegistration competitionRegistration;
@ApiModelProperty(value = "活动分类名称")
@TableField(exist = false)
private String classificationName;
} }

@ -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;
}

@ -35,4 +35,7 @@ public class AfterLoginPageCompetitionListReq extends PageReq{
@ApiModelProperty(value = "读取的列表(0:首页活动/1.已报名活动)", example = "5") @ApiModelProperty(value = "读取的列表(0:首页活动/1.已报名活动)", example = "5")
private Integer listType; private Integer listType;
@ApiModelProperty(value = "活动分类id")
private Integer classificationId;
} }

@ -153,4 +153,11 @@ public class CompetitionVO implements Serializable {
@ApiModelProperty(value = "是否展示报名人员(0否,1是)") @ApiModelProperty(value = "是否展示报名人员(0否,1是)")
private String whetherToShowApplicants; private String whetherToShowApplicants;
@ApiModelProperty(value = "分类名称")
private String classificationName;
@ApiModelProperty(value = "活动分类id")
private Integer classificationId;
} }

@ -0,0 +1,16 @@
package com.huoran.competition.mapper;
import com.huoran.competition.entity.CompetitionClassification;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 活动分类 Mapper 接口
* </p>
*
* @author cheney
* @since 2023-12-27
*/
public interface CompetitionClassificationMapper extends BaseMapper<CompetitionClassification> {
}

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.huoran.competition.mapper.CompetitionClassificationMapper">
</mapper>

@ -696,16 +696,22 @@
( CASE create_source WHEN 0 THEN '平台创建' WHEN 1 THEN '组织创建' ELSE '无' END ) AS createSource, ( CASE create_source WHEN 0 THEN '平台创建' WHEN 1 THEN '组织创建' ELSE '无' END ) AS createSource,
IF 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, 1,
0 0
) AS whetherToSignUp ) AS whetherToSignUp,
cla.classification_name,
c.classification_id
FROM FROM
c_competition c c_competition c
INNER JOIN c_competition_classification cla ON c.classification_id = cla.id
WHERE WHERE
c.is_open = 0 c.is_open = 0
AND c.publish_status = 1 AND c.publish_status = 1
<if test=" req.classificationId!=null ">
and c.classification_id=#{req.classificationId}
</if>
<if test=" req.startTime!=null and req.endTime!=null "> <if test=" req.startTime!=null and req.endTime!=null ">
and create_time between #{req.startTime} and #{req.endTime} and create_time between #{req.startTime} and #{req.endTime}
@ -771,10 +777,13 @@
c.is_open, c.is_open,
create_source, create_source,
( CASE create_source WHEN 0 THEN '平台创建' WHEN 1 THEN '组织创建' ELSE '无' END ) AS createSource, ( 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 FROM
c_competition_registration r c_competition_registration r
INNER JOIN c_competition c ON c.id = r.competition_id INNER JOIN c_competition c ON c.id = r.competition_id
INNER JOIN c_competition_classification cla ON c.classification_id = cla.id
WHERE WHERE
r.account_id = #{req.accountId} r.account_id = #{req.accountId}
@ -783,6 +792,10 @@
WHERE WHERE
t.isDelCompetition IS NULL t.isDelCompetition IS NULL
<if test=" req.classificationId!=null ">
and t.classification_id =#{req.classificationId}
</if>
<if test=" req.startTime!=null and req.endTime!=null "> <if test=" req.startTime!=null and req.endTime!=null ">
and t.create_time between #{req.startTime} and #{req.endTime} and t.create_time between #{req.startTime} and #{req.endTime}
</if> </if>

@ -0,0 +1,16 @@
package com.huoran.competition.service;
import com.huoran.competition.entity.CompetitionClassification;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 活动分类 服务类
* </p>
*
* @author cheney
* @since 2023-12-27
*/
public interface CompetitionClassificationService extends IService<CompetitionClassification> {
}

@ -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;
/**
* <p>
* 活动分类 服务实现类
* </p>
*
* @author cheney
* @since 2023-12-27
*/
@Service
public class CompetitionClassificationServiceImpl extends ServiceImpl<CompetitionClassificationMapper, CompetitionClassification> implements CompetitionClassificationService {
}

@ -60,7 +60,7 @@ public class CodeGenerator {
// 5、策略配置 // 5、策略配置
StrategyConfig strategy = new StrategyConfig(); StrategyConfig strategy = new StrategyConfig();
strategy.setInclude("c_competition_user_del"); strategy.setInclude("c_competition_classification");
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
strategy.setTablePrefix("c_"); //生成实体时去掉表前缀 strategy.setTablePrefix("c_"); //生成实体时去掉表前缀

Loading…
Cancel
Save