parent
45f7e375bf
commit
4ee0e4423a
24 changed files with 178 additions and 29 deletions
@ -0,0 +1,40 @@ |
||||
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); |
||||
} |
||||
} |
@ -0,0 +1,19 @@ |
||||
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; |
||||
|
||||
} |
@ -0,0 +1,54 @@ |
||||
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; |
||||
|
||||
|
||||
} |
@ -1,23 +1,50 @@ |
||||
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.favour.knowFavour.KnowFavourAddRequest; |
||||
import com.teaching.backend.model.dto.know.KnowAddRequest; |
||||
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(KnowAddRequest knowAddRequest) { |
||||
public Boolean add(KnowRequest knowAddRequest) { |
||||
Know know = new Know(); |
||||
BeanUtils.copyProperties(knowAddRequest,know); |
||||
return (save(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; |
||||
} |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue