parent
485e05d0ee
commit
8220281da5
10 changed files with 165 additions and 29 deletions
@ -0,0 +1,51 @@ |
||||
package com.teaching.backend.controller.know; |
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ErrorCode; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.exception.BusinessException; |
||||
|
||||
import com.teaching.backend.model.dto.know.KnowAddRequest; |
||||
|
||||
import com.teaching.backend.service.know.KnowService; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-06-17-11:57 |
||||
* @Description: |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/konw") |
||||
public class KnowController { |
||||
|
||||
@Autowired |
||||
private KnowService knowService; |
||||
|
||||
|
||||
/** |
||||
* 知识点添加 |
||||
* |
||||
*/ |
||||
@PostMapping("/add") |
||||
// 加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
|
||||
public BaseResponse<Boolean> doFavour(@RequestBody KnowAddRequest knowAddRequest) { |
||||
// todo 字段判空 合法
|
||||
|
||||
// todo 字段是否存在
|
||||
|
||||
Boolean result = knowService.add(knowAddRequest); |
||||
|
||||
if(!result) { |
||||
throw new BusinessException(ErrorCode.SYSTEM_ERROR); |
||||
} |
||||
|
||||
return ResultUtils.success(result); |
||||
} |
||||
} |
@ -0,0 +1,48 @@ |
||||
package com.teaching.backend.model.dto.know; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 知识点请求 |
||||
*/ |
||||
@Data |
||||
public class KnowAddRequest implements Serializable { |
||||
|
||||
|
||||
/** |
||||
* 知识点名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 简介 |
||||
*/ |
||||
private String info; |
||||
|
||||
/** |
||||
* 知识点内容 |
||||
*/ |
||||
private String content; |
||||
|
||||
/** |
||||
* 知识点图片 |
||||
*/ |
||||
private String img; |
||||
|
||||
/** |
||||
* 知识点学时 |
||||
*/ |
||||
private BigDecimal hour; |
||||
|
||||
|
||||
|
||||
/** |
||||
* 资源id 运用json |
||||
*/ |
||||
private String resourceid; |
||||
|
||||
|
||||
} |
@ -1,12 +0,0 @@ |
||||
package com.teaching.backend.service.impl.know; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.teaching.backend.mapper.know.KnowMapper; |
||||
import com.teaching.backend.model.entity.know.Know; |
||||
import com.teaching.backend.service.know.IknowService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
@Service |
||||
public class IknowServiceimpl extends ServiceImpl<KnowMapper,Know> implements IknowService { |
||||
|
||||
} |
@ -0,0 +1,23 @@ |
||||
package com.teaching.backend.service.impl.know; |
||||
|
||||
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.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; |
||||
|
||||
@Service |
||||
public class KnowServiceimpl extends ServiceImpl<KnowMapper,Know> implements KnowService { |
||||
@Autowired |
||||
private KnowMapper knowMapper; |
||||
@Override |
||||
public Boolean add(KnowAddRequest knowAddRequest) { |
||||
Know know = new Know(); |
||||
BeanUtils.copyProperties(knowAddRequest,know); |
||||
return (save(know)); |
||||
} |
||||
} |
@ -1,10 +0,0 @@ |
||||
package com.teaching.backend.service.know; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.teaching.backend.model.entity.know.Know; |
||||
|
||||
|
||||
public interface IknowService extends IService<Know> { |
||||
|
||||
} |
||||
|
@ -0,0 +1,12 @@ |
||||
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.KnowAddRequest; |
||||
import com.teaching.backend.model.entity.know.Know; |
||||
|
||||
|
||||
public interface KnowService extends IService<Know> { |
||||
public Boolean add(KnowAddRequest knowAddRequest); |
||||
} |
||||
|
@ -0,0 +1,9 @@ |
||||
package com.teaching.backend.utils; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-06-17-23:15 |
||||
* @Description: |
||||
*/ |
||||
public class ParamOutAspect { |
||||
} |
Loading…
Reference in new issue