diff --git a/laws-modules/src/main/java/com/jero/modules/laws/library/controller/LawsAnswerLibraryController.java b/laws-modules/src/main/java/com/jero/modules/laws/library/controller/LawsAnswerLibraryController.java index bd065573..8a5af216 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/library/controller/LawsAnswerLibraryController.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/library/controller/LawsAnswerLibraryController.java @@ -36,141 +36,4 @@ public class LawsAnswerLibraryController extends JeroController> queryPageList(LawsAnswerLibrary lawsAnswerLibrary, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - IPage pageList = lawsAnswerLibraryService.queryPage(lawsAnswerLibrary, pageNo, pageSize, req); - return Result.OK(pageList); - } - - /** - * 列表查询 - * - * @param lawsAnswerLibrary - * @param req - * @return - */ - @AutoLog(value = "问答库-回答-列表查询") - @ApiOperation(value="问答库-回答-列表查询", notes="问答库-回答-列表查询") - @GetMapping(value = "/list") - public Result> queryList(LawsAnswerLibrary lawsAnswerLibrary, HttpServletRequest req) { - List list = lawsAnswerLibraryService.queryList(lawsAnswerLibrary, req); - return Result.OK(list); - } - - /** - * 添加 - * - * @param lawsAnswerLibrary - * @return - */ - @AutoLog(value = "问答库-回答-添加") - @ApiOperation(value="问答库-回答-添加", notes="问答库-回答-添加") - @PostMapping(value = "/add") - public Result add(@Validated @RequestBody LawsAnswerLibrary lawsAnswerLibrary) { - lawsAnswerLibraryService.add(lawsAnswerLibrary); - return Result.OK("操作成功!"); - } - - /** - * 编辑 - * - * @param lawsAnswerLibrary - * @return - */ - @AutoLog(value = "问答库-回答-编辑") - @ApiOperation(value="问答库-回答-编辑", notes="问答库-回答-编辑") - @PostMapping(value = "/edit") - public Result edit(@Validated @RequestBody LawsAnswerLibrary lawsAnswerLibrary) { - lawsAnswerLibraryService.editById(lawsAnswerLibrary); - return Result.OK("操作成功!"); - } - - /** - * 通过id删除 - * - * @param map - * @return - */ - @AutoLog(value = "问答库-回答-通过id删除") - @ApiOperation(value="问答库-回答-通过id删除", notes="问答库-回答-通过id删除") - @PostMapping(value = "/delete") - public Result delete(@RequestBody Map map) { - if(!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))){ - return Result.error("请选择数据!"); - } - lawsAnswerLibraryService.deleteById(map.get("id")); - return Result.OK("删除成功!"); - } - - /** - * 批量删除 - * - * @param map - * @return - */ - @AutoLog(value = "问答库-回答-批量删除") - @ApiOperation(value="问答库-回答-批量删除", notes="问答库-回答-批量删除") - @PostMapping(value = "/deleteBatch") - public Result deleteBatch(@RequestBody Map map) { - if(!map.containsKey("ids") || StringUtils.isEmpty(map.get("ids"))){ - return Result.error("请选择数据!"); - } - this.lawsAnswerLibraryService.deleteByIds(Arrays.asList(map.get("ids").split(","))); - return Result.OK("批量删除成功!"); - } - - /** - * 通过id查询 - * - * @param id - * @return - */ - @AutoLog(value = "问答库-回答-通过id查询") - @ApiOperation(value="问答库-回答-通过id查询", notes="问答库-回答-通过id查询") - @GetMapping(value = "/queryById") - public Result queryById(@RequestParam(name="id",required=true) String id) { - LawsAnswerLibrary lawsAnswerLibrary = lawsAnswerLibraryService.queryById(id); - if(lawsAnswerLibrary==null) { - return Result.error("未找到对应数据"); - } - return Result.OK(lawsAnswerLibrary); - } - - /** - * 导出excel - * - * @param request - * @param lawsAnswerLibrary - */ - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, LawsAnswerLibrary lawsAnswerLibrary) { - return super.exportXls(request, lawsAnswerLibrary, LawsAnswerLibrary.class, "问答库-回答"); - } - - /** - * 通过excel导入数据 - * - * @param request - * @param response - * @return - */ - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, LawsAnswerLibrary.class); - } - } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/library/controller/LawsProblemLibraryController.java b/laws-modules/src/main/java/com/jero/modules/laws/library/controller/LawsProblemLibraryController.java index f407a8b0..6886478d 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/library/controller/LawsProblemLibraryController.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/library/controller/LawsProblemLibraryController.java @@ -6,6 +6,9 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.jero.common.api.vo.Result; +import com.jero.common.util.MessageUtils; +import com.jero.modules.laws.common.constant.ResultCommon; +import com.jero.modules.laws.library.entity.LawsAnswerLibrary; import com.jero.modules.laws.library.entity.LawsProblemLibrary; import com.jero.modules.laws.library.service.ILawsProblemLibraryService; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -28,7 +31,7 @@ import org.apache.poi.ss.formula.functions.T; * @Date: 2023-09-28 * @Version: V1.0 */ -@Api(tags="问答库-问题") +@Api(tags="问答库") @RestController @RequestMapping("/laws/library/lawsProblemLibrary") @Slf4j @@ -36,141 +39,95 @@ public class LawsProblemLibraryController extends JeroController> queryPageList(LawsProblemLibrary lawsProblemLibrary, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - IPage pageList = lawsProblemLibraryService.queryPage(lawsProblemLibrary, pageNo, pageSize, req); - return Result.OK(pageList); - } + @AutoLog(value = "问答库-分页列表查询") + @ApiOperation(value="问答库-分页列表查询", notes="问答库-问题-分页列表查询") + @GetMapping(value = "/page") + public Result> queryPageList(LawsProblemLibrary lawsProblemLibrary, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + IPage pageList = lawsProblemLibraryService.queryPage(lawsProblemLibrary, pageNo, pageSize, req); + return Result.OK(pageList); + } - /** - * 列表查询 - * - * @param lawsProblemLibrary - * @param req - * @return - */ - @AutoLog(value = "问答库-问题-列表查询") - @ApiOperation(value="问答库-问题-列表查询", notes="问答库-问题-列表查询") - @GetMapping(value = "/list") - public Result> queryList(LawsProblemLibrary lawsProblemLibrary, HttpServletRequest req) { - List list = lawsProblemLibraryService.queryList(lawsProblemLibrary, req); - return Result.OK(list); - } + @AutoLog(value = "问答库-提出问题") + @ApiOperation(value="问答库-提出问题", notes="问答库-提出问题") + @PostMapping(value = "/addProblem") + public Result addProblem(@Validated @RequestBody LawsProblemLibrary lawsProblemLibrary) { + lawsProblemLibraryService.addProblem(lawsProblemLibrary); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); + } - /** - * 添加 - * - * @param lawsProblemLibrary - * @return - */ - @AutoLog(value = "问答库-问题-添加") - @ApiOperation(value="问答库-问题-添加", notes="问答库-问题-添加") - @PostMapping(value = "/add") - public Result add(@Validated @RequestBody LawsProblemLibrary lawsProblemLibrary) { - lawsProblemLibraryService.add(lawsProblemLibrary); - return Result.OK("操作成功!"); - } + @AutoLog(value = "国内标准-提出问题") + @ApiOperation(value="国内标准-提出问题", notes="国内标准-提出问题") + @PostMapping(value = "/addProblem/GB") + public Result addProblemGB(@Validated @RequestBody LawsProblemLibrary lawsProblemLibrary) { + lawsProblemLibrary.setType("1"); + lawsProblemLibraryService.addProblem(lawsProblemLibrary); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); + } - /** - * 编辑 - * - * @param lawsProblemLibrary - * @return - */ - @AutoLog(value = "问答库-问题-编辑") - @ApiOperation(value="问答库-问题-编辑", notes="问答库-问题-编辑") - @PostMapping(value = "/edit") - public Result edit(@Validated @RequestBody LawsProblemLibrary lawsProblemLibrary) { - lawsProblemLibraryService.editById(lawsProblemLibrary); - return Result.OK("操作成功!"); - } + @AutoLog(value = "海外标准-提出问题") + @ApiOperation(value="海外标准-提出问题", notes="海外标准-提出问题") + @PostMapping(value = "/addProblem/FB") + public Result addProblemFB(@Validated @RequestBody LawsProblemLibrary lawsProblemLibrary) { + lawsProblemLibrary.setType("2"); + lawsProblemLibraryService.addProblem(lawsProblemLibrary); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); + } - /** - * 通过id删除 - * - * @param map - * @return - */ - @AutoLog(value = "问答库-问题-通过id删除") - @ApiOperation(value="问答库-问题-通过id删除", notes="问答库-问题-通过id删除") - @PostMapping(value = "/delete") - public Result delete(@RequestBody Map map) { - if(!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))){ - return Result.error("请选择数据!"); - } - lawsProblemLibraryService.deleteById(map.get("id")); - return Result.OK("删除成功!"); - } + @AutoLog(value = "企业标准-提出问题") + @ApiOperation(value="企业标准-提出问题", notes="企业标准-提出问题") + @PostMapping(value = "/addProblem/QB") + public Result addProblemQB(@Validated @RequestBody LawsProblemLibrary lawsProblemLibrary) { + lawsProblemLibrary.setType("3"); + lawsProblemLibraryService.addProblem(lawsProblemLibrary); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); + } - /** - * 批量删除 - * - * @param map - * @return - */ - @AutoLog(value = "问答库-问题-批量删除") - @ApiOperation(value="问答库-问题-批量删除", notes="问答库-问题-批量删除") - @PostMapping(value = "/deleteBatch") - public Result deleteBatch(@RequestBody Map map) { - if(!map.containsKey("ids") || StringUtils.isEmpty(map.get("ids"))){ - return Result.error("请选择数据!"); - } - this.lawsProblemLibraryService.deleteByIds(Arrays.asList(map.get("ids").split(","))); - return Result.OK("批量删除成功!"); - } + @AutoLog(value = "问答库-回答问题") + @ApiOperation(value="问答库-回答问题", notes="问答库-回答问题") + @PostMapping(value = "/addAnswer") + public Result addAnswer(@Validated @RequestBody LawsAnswerLibrary lawsAnswerLibrary) { + lawsProblemLibraryService.addAnswer(lawsAnswerLibrary); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); + } - /** - * 通过id查询 - * - * @param id - * @return - */ - @AutoLog(value = "问答库-问题-通过id查询") - @ApiOperation(value="问答库-问题-通过id查询", notes="问答库-问题-通过id查询") - @GetMapping(value = "/queryById") - public Result queryById(@RequestParam(name="id",required=true) String id) { - LawsProblemLibrary lawsProblemLibrary = lawsProblemLibraryService.queryById(id); - if(lawsProblemLibrary==null) { - return Result.error("未找到对应数据"); - } - return Result.OK(lawsProblemLibrary); - } + @AutoLog(value = "问答库-通过id查询") + @ApiOperation(value="问答库-通过id查询", notes="问答库-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name="id") String id) { + LawsProblemLibrary lawsProblemLibrary = lawsProblemLibraryService.queryById(id); + return Result.OK(lawsProblemLibrary); + } - /** - * 导出excel - * - * @param request - * @param lawsProblemLibrary - */ - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, LawsProblemLibrary lawsProblemLibrary) { - return super.exportXls(request, lawsProblemLibrary, LawsProblemLibrary.class, "问答库-问题"); - } + @AutoLog(value = "问答库-通过id删除问题") + @ApiOperation(value="问答库-通过id删除问题", notes="问答库-通过id删除问题") + @PostMapping(value = "/deleteProblem") + public Result deleteProblem(@RequestBody Map map) { + if(!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))){ + return Result.error(MessageUtils.getMessage(ResultCommon.SELECT_DATA)); + } + lawsProblemLibraryService.deleteProblem(map.get("id")); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); + } - /** - * 通过excel导入数据 - * - * @param request - * @param response - * @return - */ - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, LawsProblemLibrary.class); - } + @AutoLog(value = "问答库-通过id删除回答") + @ApiOperation(value="问答库-通过id删除回答", notes="问答库-通过id删除回答") + @PostMapping(value = "/deleteAnswer") + public Result deleteAnswer(@RequestBody Map map) { + if(!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))){ + return Result.error(MessageUtils.getMessage(ResultCommon.SELECT_DATA)); + } + lawsProblemLibraryService.deleteAnswer(map.get("id")); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); + } + @AutoLog(value = "问答库-是否置顶") + @ApiOperation(value="问答库-是否置顶", notes="问答库-是否置顶") + @GetMapping(value = "/isTop") + public Result isTop(@RequestParam(name="id") String id) { + lawsProblemLibraryService.isTop(id); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); + } } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/library/entity/LawsAnswerLibrary.java b/laws-modules/src/main/java/com/jero/modules/laws/library/entity/LawsAnswerLibrary.java index 519c8767..45f9b7d1 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/library/entity/LawsAnswerLibrary.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/library/entity/LawsAnswerLibrary.java @@ -45,6 +45,7 @@ public class LawsAnswerLibrary implements Serializable { /**所属部门*/ @Excel(name = "所属部门", width = 15) @ApiModelProperty(value = "所属部门") + @Dict(dictTable = "sys_depart", dicCode = "org_code", dicText = "depart_name") private java.lang.String orgCode; /**问题id*/ @Excel(name = "问题id", width = 15) @@ -61,5 +62,6 @@ public class LawsAnswerLibrary implements Serializable { /**回答人id*/ @Excel(name = "回答人id", width = 15) @ApiModelProperty(value = "回答人id") + @Dict(dictTable = "sys_user", dicCode = "id", dicText = "name_work_no") private java.lang.String userId; } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/library/entity/LawsProblemLibrary.java b/laws-modules/src/main/java/com/jero/modules/laws/library/entity/LawsProblemLibrary.java index ca234d93..474d6d65 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/library/entity/LawsProblemLibrary.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/library/entity/LawsProblemLibrary.java @@ -4,7 +4,10 @@ import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.util.Date; import java.math.BigDecimal; +import java.util.List; + 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 lombok.Data; @@ -56,6 +59,7 @@ public class LawsProblemLibrary implements Serializable { /**所属部门*/ @Excel(name = "所属部门", width = 15) @ApiModelProperty(value = "所属部门") + @Dict(dictTable = "sys_depart", dicCode = "org_code", dicText = "depart_name") private java.lang.String orgCode; /**0表示未删除,1表示删除*/ @Excel(name = "0表示未删除,1表示删除", width = 15) @@ -64,6 +68,7 @@ public class LawsProblemLibrary implements Serializable { /**分类(国内1、海外2、企业3、其他4)*/ @Excel(name = "分类(国内1、海外2、企业3、其他4)", width = 15) @ApiModelProperty(value = "分类(国内1、海外2、企业3、其他4)") + @Dict(dicCode = "problem_library_type") private java.lang.String type; /**标准id*/ @Excel(name = "标准id", width = 15) @@ -100,5 +105,15 @@ public class LawsProblemLibrary implements Serializable { /**发帖人id*/ @Excel(name = "发帖人id", width = 15) @ApiModelProperty(value = "发帖人id") + @Dict(dictTable = "sys_user", dicCode = "id", dicText = "name_work_no") private java.lang.String userId; + + /**回答列表*/ + @ApiModelProperty(value = "回答列表") + @TableField(exist = false) + private List answerList; + /**回答数*/ + @ApiModelProperty(value = "回答数") + @TableField(exist = false) + private Integer answerCount; } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/library/service/ILawsAnswerLibraryService.java b/laws-modules/src/main/java/com/jero/modules/laws/library/service/ILawsAnswerLibraryService.java index cf4795b8..346c01aa 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/library/service/ILawsAnswerLibraryService.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/library/service/ILawsAnswerLibraryService.java @@ -14,63 +14,4 @@ import java.util.List; */ public interface ILawsAnswerLibraryService extends IService { - /** - * 分页查询 - * - * @param lawsAnswerLibrary - * @param pageNo - * @param pageSize - * @param req - * @return - */ - IPage queryPage(LawsAnswerLibrary lawsAnswerLibrary, Integer pageNo, Integer pageSize, HttpServletRequest req); - - /** - * 列表查询 - * - * @param lawsAnswerLibrary - * @param req - * @return - */ - List queryList(LawsAnswerLibrary lawsAnswerLibrary, HttpServletRequest req); - - /** - * 保存 - * - * @param lawsAnswerLibrary - * @return - */ - void add(LawsAnswerLibrary lawsAnswerLibrary); - - /** - * 更新 - * - * @param lawsAnswerLibrary - * @return - */ - void editById(LawsAnswerLibrary lawsAnswerLibrary); - - /** - * 通过id删除 - * - * @param id - * @return - */ - void deleteById(String id); - - /** - * 批量删除 - * - * @param ids - * @return - */ - void deleteByIds(List ids); - - /** - * 通过id查询 - * - * @param id - * @return - */ - LawsAnswerLibrary queryById(String id); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/library/service/ILawsProblemLibraryService.java b/laws-modules/src/main/java/com/jero/modules/laws/library/service/ILawsProblemLibraryService.java index 8c6dcfca..ac2a7551 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/library/service/ILawsProblemLibraryService.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/library/service/ILawsProblemLibraryService.java @@ -1,5 +1,6 @@ package com.jero.modules.laws.library.service; +import com.jero.modules.laws.library.entity.LawsAnswerLibrary; import com.jero.modules.laws.library.entity.LawsProblemLibrary; import com.baomidou.mybatisplus.extension.service.IService; import javax.servlet.http.HttpServletRequest; @@ -14,63 +15,52 @@ import java.util.List; */ public interface ILawsProblemLibraryService extends IService { - /** - * 分页查询 - * - * @param lawsProblemLibrary - * @param pageNo - * @param pageSize - * @param req - * @return - */ - IPage queryPage(LawsProblemLibrary lawsProblemLibrary, Integer pageNo, Integer pageSize, HttpServletRequest req); - - /** - * 列表查询 - * - * @param lawsProblemLibrary - * @param req - * @return - */ - List queryList(LawsProblemLibrary lawsProblemLibrary, HttpServletRequest req); + /** + * @Author: liao + * @Date: 2023/9/28 13:44 + * @Description: 分页查询 + **/ + IPage queryPage(LawsProblemLibrary lawsProblemLibrary, Integer pageNo, Integer pageSize, HttpServletRequest req); /** - * 保存 - * - * @param lawsProblemLibrary - * @return - */ - void add(LawsProblemLibrary lawsProblemLibrary); + * @Author: liao + * @Date: 2023/9/28 11:47 + * @Description: 添加问题 + **/ + void addProblem(LawsProblemLibrary lawsProblemLibrary); /** - * 更新 - * - * @param lawsProblemLibrary - * @return - */ - void editById(LawsProblemLibrary lawsProblemLibrary); + * @Author: liao + * @Date: 2023/9/28 13:51 + * @Description: 回答问题 + **/ + void addAnswer(LawsAnswerLibrary lawsAnswerLibrary); /** - * 通过id删除 - * - * @param id - * @return - */ - void deleteById(String id); + * @Author: liao + * @Date: 2023/9/28 13:48 + * @Description: 通过id查询 + **/ + LawsProblemLibrary queryById(String id); /** - * 批量删除 - * - * @param ids - * @return - */ - void deleteByIds(List ids); + * @Author: liao + * @Date: 2023/9/28 13:44 + * @Description: 根据id删除问题 + **/ + void deleteProblem(String id); /** - * 通过id查询 - * - * @param id - * @return - */ - LawsProblemLibrary queryById(String id); + * @Author: liao + * @Date: 2023/9/28 14:18 + * @Description: 通过id删除回答 + **/ + void deleteAnswer(String id); + + /** + * @Author: liao + * @Date: 2023/9/28 14:21 + * @Description: 是否置顶 + **/ + void isTop(String id); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/library/service/impl/LawsAnswerLibraryServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/library/service/impl/LawsAnswerLibraryServiceImpl.java index 3c38a797..5056ec7b 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/library/service/impl/LawsAnswerLibraryServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/library/service/impl/LawsAnswerLibraryServiceImpl.java @@ -26,90 +26,4 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @Transactional(rollbackFor = JeroBootException.class) public class LawsAnswerLibraryServiceImpl extends ServiceImpl implements ILawsAnswerLibraryService { - - /** - * 分页查询 - * - * @param lawsAnswerLibrary - * @param pageNo - * @param pageSize - * @param req - * @return - */ - @Override - public IPage queryPage(LawsAnswerLibrary lawsAnswerLibrary, Integer pageNo, Integer pageSize, - HttpServletRequest req) { - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(lawsAnswerLibrary, req.getParameterMap()); - Page page = new Page<>(pageNo, pageSize); - return page(page, queryWrapper); - } - - /** - * 列表查询 - * - * @param lawsAnswerLibrary - * @param req - * @return - */ - @Override - public List queryList(LawsAnswerLibrary lawsAnswerLibrary, HttpServletRequest req) { - return list(QueryGenerator.initQueryWrapper(lawsAnswerLibrary, req.getParameterMap())); - } - - /** - * 保存 - * - * @param lawsAnswerLibrary - * @return - */ - @Override - public void add(LawsAnswerLibrary lawsAnswerLibrary) { - Date now = new Date(); - lawsAnswerLibrary.setCreateTime(now); - save(lawsAnswerLibrary); - } - - /** - * 更新 - * - * @param lawsAnswerLibrary - * @return - */ - @Override - public void editById(LawsAnswerLibrary lawsAnswerLibrary) { - saveOrUpdate(lawsAnswerLibrary); - } - - /** - * 通过id删除 - * - * @param id - * @return - */ - @Override - public void deleteById(String id) { - removeById(id); - } - - /** - * 批量删除 - * - * @param ids - * @return - */ - @Override - public void deleteByIds(List ids) { - removeByIds(ids); - } - - /** - * 通过id查询 - * - * @param id - * @return - */ - @Override - public LawsAnswerLibrary queryById(String id) { - return getById(id); - } } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/library/service/impl/LawsProblemLibraryServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/library/service/impl/LawsProblemLibraryServiceImpl.java index a8f42e3f..46ae9be8 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/library/service/impl/LawsProblemLibraryServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/library/service/impl/LawsProblemLibraryServiceImpl.java @@ -1,14 +1,29 @@ package com.jero.modules.laws.library.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.jero.common.api.vo.Result; +import com.jero.common.system.vo.LoginUser; +import com.jero.common.util.MessageUtils; +import com.jero.modules.laws.common.constant.ResultCommon; +import com.jero.modules.laws.common.service.ILawsCommonService; +import com.jero.modules.laws.common.vo.ManyStandardSelectionBox; +import com.jero.modules.laws.library.entity.LawsAnswerLibrary; import com.jero.modules.laws.library.entity.LawsProblemLibrary; import com.jero.modules.laws.library.mapper.LawsProblemLibraryMapper; +import com.jero.modules.laws.library.service.ILawsAnswerLibraryService; import com.jero.modules.laws.library.service.ILawsProblemLibraryService; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jero.common.exception.JeroBootException; import java.util.List; import java.util.Date; +import java.util.Objects; + import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.jero.common.system.query.QueryGenerator; import javax.servlet.http.HttpServletRequest; @@ -26,93 +41,134 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @Transactional(rollbackFor = JeroBootException.class) public class LawsProblemLibraryServiceImpl extends ServiceImpl implements ILawsProblemLibraryService { + @Autowired + private ILawsCommonService lawsCommonService; + @Autowired + private ILawsAnswerLibraryService lawsAnswerLibraryService; - /** - * 分页查询 - * - * @param lawsProblemLibrary - * @param pageNo - * @param pageSize - * @param req - * @return - */ @Override public IPage queryPage(LawsProblemLibrary lawsProblemLibrary, Integer pageNo, Integer pageSize, - HttpServletRequest req) { + HttpServletRequest req) { QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(lawsProblemLibrary, req.getParameterMap()); Page page = new Page<>(pageNo, pageSize); return page(page, queryWrapper); } /** - * 列表查询 - * - * @param lawsProblemLibrary - * @param req - * @return - */ + * @Author: liao + * @Date: 2023/9/28 11:48 + * @Description: 添加问题 + **/ @Override - public List queryList(LawsProblemLibrary lawsProblemLibrary, HttpServletRequest req) { - return list(QueryGenerator.initQueryWrapper(lawsProblemLibrary, req.getParameterMap())); - } + public void addProblem(LawsProblemLibrary lawsProblemLibrary) { + LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + if (StringUtils.isBlank(lawsProblemLibrary.getTitle())) { + throw new JeroBootException(ResultCommon.EMPTY_COMMON, "title"); + } + if (StringUtils.isBlank(lawsProblemLibrary.getStandardNumber())) { + throw new JeroBootException(ResultCommon.EMPTY_COMMON, "standardNumber"); + } + if (StringUtils.isBlank(lawsProblemLibrary.getProblemDescription())) { + throw new JeroBootException(ResultCommon.EMPTY_COMMON, "problemDescription"); + } + // 如果是国内、海外、企业 + if (!"4".equals(lawsProblemLibrary.getType())) { + ManyStandardSelectionBox singleStandard = lawsCommonService.getSingleStandard(lawsProblemLibrary.getStandardNumber(), null); + lawsProblemLibrary.setStandardId(singleStandard.getId()); + lawsProblemLibrary.setStandardName(singleStandard.getStandardName()); + } + lawsProblemLibrary.setUserId(loginUser.getId()); + lawsProblemLibrary.setOrgCode(loginUser.getOrgCode()); + lawsProblemLibrary.setIsAnswer(0); - /** - * 保存 - * - * @param lawsProblemLibrary - * @return - */ - @Override - public void add(LawsProblemLibrary lawsProblemLibrary) { - Date now = new Date(); - lawsProblemLibrary.setCreateTime(now); - lawsProblemLibrary.setUpdateTime(now); save(lawsProblemLibrary); } - /** - * 更新 - * - * @param lawsProblemLibrary - * @return - */ - @Override - public void editById(LawsProblemLibrary lawsProblemLibrary) { - Date now = new Date(); - lawsProblemLibrary.setUpdateTime(now); - saveOrUpdate(lawsProblemLibrary); + /** + * @Author: liao + * @Date: 2023/9/28 13:51 + * @Description: 回答问题 + **/ + @Override + public void addAnswer(LawsAnswerLibrary lawsAnswerLibrary) { + LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + if (StringUtils.isBlank(lawsAnswerLibrary.getProblemId())) { + throw new JeroBootException(ResultCommon.EMPTY_COMMON, "problemId"); + } + + lawsAnswerLibrary.setUserId(loginUser.getId()); + lawsAnswerLibrary.setOrgCode(loginUser.getOrgCode()); + lawsAnswerLibrary.setIsTop(0); + lawsAnswerLibrary.setCreateTime(new Date()); + + lawsAnswerLibraryService.save(lawsAnswerLibrary); + + // 更新问题的回答状态 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(LawsProblemLibrary::getIsAnswer, 1); + updateWrapper.eq(LawsProblemLibrary::getId, lawsAnswerLibrary.getProblemId()); + update(updateWrapper); } - /** - * 通过id删除 - * - * @param id - * @return - */ - @Override - public void deleteById(String id) { + /** + * @Author: liao + * @Date: 2023/9/28 13:48 + * @Description: 通过id查询 + **/ + @Override + public LawsProblemLibrary queryById(String id) { + LawsProblemLibrary lawsProblemLibrary = getById(id); + if(Objects.isNull(lawsProblemLibrary)) { + throw new JeroBootException(ResultCommon.NO_CORRESPONDING_DATA_FOUND); + } + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(LawsAnswerLibrary::getProblemId, id); + queryWrapper.orderByDesc(LawsAnswerLibrary::getIsTop).orderByDesc(LawsAnswerLibrary::getCreateTime); + List answerList = lawsAnswerLibraryService.list(queryWrapper); + + lawsProblemLibrary.setAnswerList(answerList); + lawsProblemLibrary.setAnswerCount(answerList.size()); + + return lawsProblemLibrary; + } + + /** + * @Author: liao + * @Date: 2023/9/28 13:48 + * @Description: 根据id删除问题 + **/ + @Override + public void deleteProblem(String id) { removeById(id); } - /** - * 批量删除 - * - * @param ids - * @return - */ - @Override - public void deleteByIds(List ids) { - removeByIds(ids); + /** + * @Author: liao + * @Date: 2023/9/28 14:18 + * @Description: 通过id删除回答 + **/ + @Override + public void deleteAnswer(String id) { + lawsAnswerLibraryService.removeById(id); } - /** - * 通过id查询 - * - * @param id - * @return - */ - @Override - public LawsProblemLibrary queryById(String id) { - return getById(id); + /** + * @Author: liao + * @Date: 2023/9/28 14:21 + * @Description: 是否置顶 + **/ + @Override + public void isTop(String id) { + LawsAnswerLibrary lawsAnswerLibrary = lawsAnswerLibraryService.getById(id); + if(Objects.isNull(lawsAnswerLibrary)) { + throw new JeroBootException(ResultCommon.NO_CORRESPONDING_DATA_FOUND); + } + if (0 == lawsAnswerLibrary.getIsTop()) { + lawsAnswerLibrary.setIsTop(1); + } else { + lawsAnswerLibrary.setIsTop(0); + } + lawsAnswerLibraryService.updateById(lawsAnswerLibrary); } }