parent
ab59e0069f
commit
d4054e37c9
21 changed files with 266 additions and 506 deletions
@ -1,40 +0,0 @@ |
||||
package com.teaching.backend.controller.know; |
||||
|
||||
import com.teaching.backend.model.dto.know.KnowQueryRequest; |
||||
import com.teaching.backend.model.dto.know.KnowRequest; |
||||
import com.teaching.backend.model.dto.know.KnowupdateRequest; |
||||
import com.teaching.backend.model.entity.know.Know; |
||||
import com.teaching.backend.service.know.KnowService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-06-21-10:26 |
||||
* @Description: |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/api/know") |
||||
public class KnowController { |
||||
|
||||
@Autowired |
||||
private KnowService knowService; |
||||
@PostMapping("/add") |
||||
public Boolean add(@RequestBody KnowRequest knowAddRequest) { |
||||
return knowService.add(knowAddRequest); |
||||
} |
||||
@PostMapping("/update") |
||||
public Boolean update(@RequestBody KnowupdateRequest knowAddRequest){ |
||||
return knowService.update(knowAddRequest); |
||||
} |
||||
@PostMapping("/delete") |
||||
public Integer deleteKnow(@RequestBody List<Integer> ids){ |
||||
return knowService.deleteKnow(ids); |
||||
} |
||||
@PostMapping("/query") |
||||
public List<Know> query(@RequestBody KnowQueryRequest knowQueryRequest){ |
||||
return knowService.query(knowQueryRequest); |
||||
} |
||||
} |
@ -1,42 +0,0 @@ |
||||
package com.teaching.backend.controller.know; |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.model.entity.know.Know; |
||||
import com.teaching.backend.model.entity.know.KnowRelationship; |
||||
import com.teaching.backend.service.know.IKnowRelationshipService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-06-20 |
||||
*/ |
||||
@Api(tags = "知识点章节关系") |
||||
@RestController |
||||
@RequestMapping("/know-relationship") |
||||
public class KnowRelationshipController { |
||||
|
||||
@Autowired |
||||
private IKnowRelationshipService knowRelationshipService; |
||||
@ApiOperation("添加课程知识点关系") |
||||
@PostMapping() |
||||
public BaseResponse<Boolean> add(@RequestBody KnowRelationship knowRelationship){ |
||||
boolean save = knowRelationshipService.save(knowRelationship); |
||||
return ResultUtils.success(save); |
||||
} |
||||
@GetMapping() |
||||
public BaseResponse<List<KnowRelationship>> getAll(){ |
||||
List<KnowRelationship> list = knowRelationshipService.list(); |
||||
return ResultUtils.success(list); |
||||
} |
||||
} |
@ -1,10 +0,0 @@ |
||||
package com.teaching.backend.mapper.know; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.teaching.backend.model.entity.know.Know; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
@Mapper |
||||
public interface KnowMapper extends BaseMapper<Know> { |
||||
|
||||
} |
@ -1,18 +0,0 @@ |
||||
package com.teaching.backend.mapper.know; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.teaching.backend.model.entity.know.KnowRelationship; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* <p> |
||||
* Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-06-20 |
||||
*/ |
||||
@Mapper |
||||
public interface KnowRelationshipMapper extends BaseMapper<KnowRelationship> { |
||||
|
||||
} |
@ -1,19 +0,0 @@ |
||||
package com.teaching.backend.model.dto.know; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 知识点请求 |
||||
*/ |
||||
@Data |
||||
public class KnowQueryRequest implements Serializable { |
||||
|
||||
/** |
||||
* 知识点名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
} |
@ -1,48 +0,0 @@ |
||||
package com.teaching.backend.model.dto.know; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 知识点请求 |
||||
*/ |
||||
@Data |
||||
public class KnowRequest implements Serializable { |
||||
|
||||
|
||||
/** |
||||
* 知识点名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 简介 |
||||
*/ |
||||
private String info; |
||||
|
||||
/** |
||||
* 知识点内容 |
||||
*/ |
||||
private String content; |
||||
|
||||
/** |
||||
* 知识点图片 |
||||
*/ |
||||
private String img; |
||||
|
||||
/** |
||||
* 知识点学时 |
||||
*/ |
||||
private BigDecimal hour; |
||||
|
||||
|
||||
|
||||
/** |
||||
* 资源id 运用json |
||||
*/ |
||||
private String resourceid; |
||||
|
||||
|
||||
} |
@ -1,54 +0,0 @@ |
||||
package com.teaching.backend.model.dto.know; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 知识点请求 |
||||
*/ |
||||
@Data |
||||
public class KnowupdateRequest implements Serializable { |
||||
|
||||
|
||||
/** |
||||
* 知识点id |
||||
*/ |
||||
private Integer id; |
||||
|
||||
|
||||
/** |
||||
* 知识点名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 简介 |
||||
*/ |
||||
private String info; |
||||
|
||||
/** |
||||
* 知识点内容 |
||||
*/ |
||||
private String content; |
||||
|
||||
/** |
||||
* 知识点图片 |
||||
*/ |
||||
private String img; |
||||
|
||||
/** |
||||
* 知识点学时 |
||||
*/ |
||||
private BigDecimal hour; |
||||
|
||||
|
||||
|
||||
/** |
||||
* 资源id 运用json |
||||
*/ |
||||
private String resourceid; |
||||
|
||||
|
||||
} |
@ -0,0 +1,168 @@ |
||||
package com.teaching.backend.model.entity.courses; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-07-07-21:21 |
||||
* @Description: |
||||
*/ |
||||
|
||||
import java.util.Scanner; |
||||
|
||||
class Num { |
||||
public int Zero = 0; |
||||
|
||||
public int One = 0; |
||||
|
||||
public int getZero() { |
||||
return Zero; |
||||
} |
||||
|
||||
public void setZero(int zero) { |
||||
Zero = zero; |
||||
} |
||||
|
||||
public int getOne() { |
||||
return One; |
||||
} |
||||
|
||||
public void setOne(int one) { |
||||
One = one; |
||||
} |
||||
} |
||||
|
||||
// 注意类名必须为 Main, 不要有任何 package xxx 信息
|
||||
public class Main { |
||||
public static void main(String[] args) { |
||||
Scanner in = new Scanner(System.in); |
||||
int n = in.nextInt(); |
||||
String[] arr = new String[n]; |
||||
int counts = 0; |
||||
Num num = new Num(); |
||||
for (int i = 0; i < n; i++) { |
||||
arr[i] = in.next(); |
||||
} |
||||
|
||||
int p = 1, q = 1; |
||||
while (p < n) { |
||||
if (arr[0].charAt(0) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
for (int i = 0; i <= p; i++) { |
||||
if (arr[i].charAt(p) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
if (arr[p].charAt(i) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
} |
||||
if (arr[p].charAt(p) == '1') { |
||||
num.One -= 1; |
||||
} else { |
||||
num.Zero -= 1; |
||||
} |
||||
if(num.Zero == num.One){ |
||||
counts++; |
||||
} |
||||
num.One = 0; |
||||
num.Zero = 0; |
||||
|
||||
if (arr[0].charAt(n-1) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
for (int i = 0; i <= p; i++) { |
||||
if (arr[i].charAt(n-1-p) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
if (arr[p].charAt(n-i-1) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
} |
||||
if (arr[p].charAt(n-p-1) == '1') { |
||||
num.One -= 1; |
||||
} else { |
||||
num.Zero -= 1; |
||||
} |
||||
if(num.Zero == num.One){ |
||||
counts++; |
||||
} |
||||
//左下
|
||||
num.One = 0; |
||||
num.Zero = 0; |
||||
|
||||
if (arr[n-1].charAt(0) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
for (int i = 0; i <= p; i++) { |
||||
if (arr[n-1-i].charAt(p) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
if (arr[n-p-1].charAt(i) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
} |
||||
if (arr[n-p-1].charAt(p) == '1') { |
||||
num.One -= 1; |
||||
} else { |
||||
num.Zero -= 1; |
||||
} |
||||
if(num.Zero == num.One){ |
||||
counts++; |
||||
} |
||||
|
||||
//右下
|
||||
num.One = 0; |
||||
num.Zero = 0; |
||||
|
||||
if (arr[n-1].charAt(n-1) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
for (int i = 0; i <= p; i++) { |
||||
if (arr[n-1-i].charAt(n-p-1) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
if (arr[n-p-1].charAt(n-1-i) == '1') { |
||||
num.One += 1; |
||||
} else { |
||||
num.Zero += 1; |
||||
} |
||||
} |
||||
if (arr[n-p-1].charAt(n-1-p) == '1') { |
||||
num.One -= 1; |
||||
} else { |
||||
num.Zero -= 1; |
||||
} |
||||
if(num.Zero == num.One){ |
||||
counts++; |
||||
} |
||||
|
||||
p++; |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
} |
||||
|
@ -1,66 +0,0 @@ |
||||
package com.teaching.backend.model.entity.know; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.Api; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.NoArgsConstructor; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
|
||||
import java.io.Serializable; |
||||
import java.math.BigDecimal; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@Accessors(chain = true) |
||||
@TableName("know") |
||||
public class Know implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* id |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 知识点名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 简介 |
||||
*/ |
||||
private String info; |
||||
|
||||
/** |
||||
* 知识点内容 |
||||
*/ |
||||
private String content; |
||||
|
||||
/** |
||||
* 知识点图片 |
||||
*/ |
||||
private String img; |
||||
|
||||
/** |
||||
* 知识点学时 |
||||
*/ |
||||
private BigDecimal hour; |
||||
|
||||
|
||||
|
||||
/** |
||||
* 资源id 运用json |
||||
*/ |
||||
private String resourceid; |
||||
|
||||
|
||||
} |
||||
|
@ -1,46 +0,0 @@ |
||||
package com.teaching.backend.model.entity.know; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* <p> |
||||
* |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-06-20 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@Accessors(chain = true) |
||||
@TableName("know_relationship") |
||||
@ApiModel(value="KnowRelationship对象", description="") |
||||
public class KnowRelationship implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
|
||||
@ApiModelProperty(value = "章节id") |
||||
@TableField("chapterId") |
||||
private String chapterId; |
||||
|
||||
@ApiModelProperty(value = "课程id") |
||||
@TableField("courseId") |
||||
private String courseId; |
||||
|
||||
@ApiModelProperty(value = "知识点id") |
||||
@TableField("knowId") |
||||
private int knowId; |
||||
|
||||
|
||||
} |
@ -1,21 +0,0 @@ |
||||
package com.teaching.backend.service.impl.know; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.teaching.backend.mapper.know.KnowRelationshipMapper; |
||||
import com.teaching.backend.model.entity.know.KnowRelationship; |
||||
import com.teaching.backend.service.know.IKnowRelationshipService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-06-20 |
||||
*/ |
||||
@Service |
||||
public class KnowRelationshipServiceImpl extends ServiceImpl<KnowRelationshipMapper, KnowRelationship> implements IKnowRelationshipService { |
||||
|
||||
} |
@ -1,50 +0,0 @@ |
||||
package com.teaching.backend.service.impl.know; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.teaching.backend.mapper.know.KnowMapper; |
||||
import com.teaching.backend.model.dto.know.KnowQueryRequest; |
||||
import com.teaching.backend.model.dto.know.KnowRequest; |
||||
import com.teaching.backend.model.dto.know.KnowupdateRequest; |
||||
import com.teaching.backend.model.entity.know.Know; |
||||
import com.teaching.backend.service.know.KnowService; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Service |
||||
public class KnowServiceimpl extends ServiceImpl<KnowMapper,Know> implements KnowService { |
||||
@Autowired |
||||
private KnowMapper knowMapper; |
||||
@Override |
||||
public Boolean add(KnowRequest knowAddRequest) { |
||||
Know know = new Know(); |
||||
BeanUtils.copyProperties(knowAddRequest,know); |
||||
return save(know); |
||||
} |
||||
|
||||
@Override |
||||
public Boolean update(KnowupdateRequest knowAddRequest) { |
||||
Know know = new Know(); |
||||
BeanUtils.copyProperties(knowAddRequest,know); |
||||
return (updateById(know)); |
||||
} |
||||
|
||||
@Override |
||||
public Integer deleteKnow(List<Integer> ids) { |
||||
Integer result = knowMapper.deleteBatchIds(ids); |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public List<Know> query(KnowQueryRequest knowQueryRequest) { |
||||
String name = knowQueryRequest.getName(); |
||||
QueryWrapper<Know> knowQueryWrapper = new QueryWrapper<>(); |
||||
knowQueryWrapper.eq("name",name); |
||||
List<Know> knows = knowMapper.selectList(knowQueryWrapper); |
||||
return knows; |
||||
} |
||||
|
||||
} |
@ -1,16 +0,0 @@ |
||||
package com.teaching.backend.service.know; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.teaching.backend.model.entity.know.KnowRelationship; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务类 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-06-20 |
||||
*/ |
||||
public interface IKnowRelationshipService extends IService<KnowRelationship> { |
||||
} |
@ -1,23 +0,0 @@ |
||||
package com.teaching.backend.service.know; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.teaching.backend.model.dto.favour.knowFavour.KnowFavourAddRequest; |
||||
|
||||
import com.teaching.backend.model.dto.know.KnowQueryRequest; |
||||
import com.teaching.backend.model.dto.know.KnowRequest; |
||||
import com.teaching.backend.model.dto.know.KnowupdateRequest; |
||||
import com.teaching.backend.model.entity.know.Know; |
||||
|
||||
import java.util.List; |
||||
|
||||
|
||||
public interface KnowService extends IService<Know> { |
||||
public Boolean add(KnowRequest knowAddRequest); |
||||
|
||||
public Boolean update(KnowupdateRequest knowAddRequest); |
||||
|
||||
public Integer deleteKnow(List<Integer> ids); |
||||
|
||||
public List<Know> query(KnowQueryRequest knowQueryRequest); |
||||
} |
||||
|
@ -0,0 +1,38 @@ |
||||
package com.teaching.backend.utils; |
||||
|
||||
import org.springframework.beans.BeanWrapper; |
||||
import org.springframework.beans.BeanWrapperImpl; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.HashSet; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-06-23-12:45 |
||||
* @Description: |
||||
*/ |
||||
public class getNullPropertyNamesUtil { |
||||
|
||||
public static String[] getNullPropertyNames (Object source) { |
||||
final BeanWrapper src = new BeanWrapperImpl(source); |
||||
java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors(); |
||||
|
||||
Set<String> emptyNames = new HashSet<String>(); |
||||
for(java.beans.PropertyDescriptor pd : pds) { |
||||
Class<?> propertyType = src.getPropertyType(pd.getName()); |
||||
Object srcValue = src.getPropertyValue(pd.getName()); |
||||
// if ("Integer".equals(propertyType.getName()) || "Long".equals(propertyType.getName())){
|
||||
// Integer value = (Integer) srcValue;
|
||||
// if (value == 0) emptyNames.add(pd.getName());
|
||||
// }
|
||||
if ("BigDecimal".equals(propertyType.getName())){ |
||||
BigDecimal value =(BigDecimal)srcValue; |
||||
if (value == null || (BigDecimal.ZERO).equals(0)) emptyNames.add(pd.getName()); |
||||
} |
||||
if (srcValue == null || srcValue == "") emptyNames.add(pd.getName()); |
||||
} |
||||
String[] result = new String[emptyNames.size()]; |
||||
return emptyNames.toArray(result); |
||||
} |
||||
} |
Loading…
Reference in new issue