# Conflicts: # nakadai/src/main/java/com/huoran/nakadai/controller/SupplierClassificationController.javamain
commit
b9c74832e3
31 changed files with 511 additions and 57 deletions
@ -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("删除失败"); |
||||
} |
||||
} |
||||
|
@ -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; |
||||
|
||||
|
||||
} |
@ -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> |
@ -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 { |
||||
|
||||
} |
@ -0,0 +1,106 @@ |
||||
package com.huoran.nakadai.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.huoran.api.UserClient; |
||||
import com.huoran.common.response.R; |
||||
import com.huoran.common.utils.TokenUtils; |
||||
import com.huoran.nakadai.entity.SupplierClassification; |
||||
import com.huoran.nakadai.entity.req.SupplierClassificationReq; |
||||
import com.huoran.nakadai.service.SupplierClassificationService; |
||||
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.util.ObjectUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* @描述:供应商分类信息控制类 |
||||
* @作者: Rong |
||||
* @日期: 2023-12-27 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/supplierClassification") |
||||
@Api(value = "供应商分类信息:SupplierClassificationController", tags = "供应商分类信息") |
||||
public class SupplierClassificationController { |
||||
|
||||
@Autowired |
||||
public SupplierClassificationService service; |
||||
|
||||
@Autowired |
||||
private UserClient userClient; |
||||
|
||||
|
||||
@PostMapping("/treeStructureList") |
||||
@ApiOperation(value = "树结构列表", response = SupplierClassification.class) |
||||
public R treeStructureList() { |
||||
/*QueryWrapper<SupplierClassification> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.eq("parent_id", supplierClassification.getParentId());*/ |
||||
List<SupplierClassification> list = service.list(null); |
||||
|
||||
|
||||
return R.ok().put("list", buildTree(list)); |
||||
} |
||||
|
||||
public List<SupplierClassification> buildTree(List<SupplierClassification> list) { |
||||
List<SupplierClassification> treeList = new ArrayList<SupplierClassification>(); |
||||
List<SupplierClassification> children; |
||||
|
||||
for (SupplierClassification address : list) { |
||||
if (address.getParentId() == 0) { |
||||
treeList.add(address); |
||||
} |
||||
children = new ArrayList<SupplierClassification>(); |
||||
for (SupplierClassification node : list) { |
||||
if (node.getParentId() == address.getId()) { |
||||
children.add(node); |
||||
} |
||||
} |
||||
address.setChildren(children); |
||||
} |
||||
|
||||
return treeList; |
||||
} |
||||
|
||||
|
||||
@PostMapping("/findById") |
||||
@ApiOperation(value = "查询详情", response = SupplierClassification.class) |
||||
public R findById(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { |
||||
SupplierClassification supplierClassification = service.getById(id); |
||||
return R.ok().put("data", supplierClassification); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/save") |
||||
@ApiOperation(value = "新增", response = SupplierClassification.class) |
||||
public R save(@RequestBody @ApiParam(name = "供应商分类信息对象", value = "传入json格式", required = true) SupplierClassification supplierClassification, HttpServletRequest request) { |
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
Integer schoolId = userClient.getSchoolIdByAccountId(accountId); |
||||
supplierClassification.setAccountId(Integer.valueOf(accountId)); |
||||
boolean addState = service.save(supplierClassification); |
||||
return addState ? R.ok() : R.error("新增失败"); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/update") |
||||
@ApiOperation(value = "修改", response = SupplierClassification.class) |
||||
public R update(@RequestBody @ApiParam(name = "供应商分类信息对象", value = "传入json格式", required = true) SupplierClassification supplierClassification, HttpServletRequest request) { |
||||
String accountId = TokenUtils.getIdByJwtToken(request); |
||||
Integer schoolId = userClient.getSchoolIdByAccountId(accountId); |
||||
supplierClassification.setAccountId(Integer.valueOf(accountId)); |
||||
boolean updateState = service.updateById(supplierClassification); |
||||
return updateState ? R.ok() : R.error("编辑失败"); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/batchDeletion") |
||||
@ApiOperation(value = "批量删除", response = SupplierClassification.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("删除失败"); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,35 @@ |
||||
package com.huoran.nakadai.entity.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* <p> |
||||
* 幼教产业团队账号与分类中间表 |
||||
* </p> |
||||
* |
||||
* @author chen |
||||
* @since 2023-12-12 |
||||
*/ |
||||
@Data |
||||
public class TeamClassificationVO { |
||||
|
||||
|
||||
@ApiModelProperty(value = "团队id") |
||||
private Integer teamId; |
||||
|
||||
@ApiModelProperty(value = "账户id") |
||||
private Integer accountId; |
||||
|
||||
@ApiModelProperty(value = "供应商分类id") |
||||
private Integer supplierClassificationId; |
||||
|
||||
@ApiModelProperty(value = "供应商分类名称") |
||||
private String supplierClassificationName; |
||||
|
||||
@ApiModelProperty(value = "供应商分类配置id") |
||||
private Integer classificationConfigId; |
||||
|
||||
|
||||
|
||||
} |
Loading…
Reference in new issue