diff --git a/inventory-dao/src/main/java/com/rzyc/bean/pojo/dto/AddEducationResourceDto.java b/inventory-dao/src/main/java/com/rzyc/bean/pojo/dto/AddEducationResourceDto.java new file mode 100644 index 0000000..c450aeb --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/bean/pojo/dto/AddEducationResourceDto.java @@ -0,0 +1,79 @@ +package com.rzyc.bean.pojo.dto; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.NotBlank; +import java.util.Date; + +/** + * @BelongsProject: inventory-api + * @BelongsPackage: com.rzyc.bean.pojo.dto + * @Author: SYZ + * @CreateTime: 2023-03-29 19:37 + * @Version: 1.0 + */ +public class AddEducationResourceDto { + + @ApiModelProperty(value = "主键",required = true) + @NotBlank(message = "主键id不能为空") + private String id; + + @ApiModelProperty(value = "行业id",required = true) + @NotBlank(message = "行业id 不能为空") + private String industryId; + + @ApiModelProperty(value = "上传人id",required = true) + @NotBlank(message = "上传人id 不能为空") + private String userId; + + @ApiModelProperty(value = "资料名") + @TableField("name") + private String name; + + @ApiModelProperty(value = "富文本") + @TableField("content") + private String content; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIndustryId() { + return industryId; + } + + public void setIndustryId(String industryId) { + this.industryId = industryId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} + diff --git a/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/dto/AddEducationStudyDto.java b/inventory-dao/src/main/java/com/rzyc/bean/pojo/dto/AddEducationStudyDto.java similarity index 92% rename from inventory-dao/src/main/java/com/rzyc/bean/educationStudy/dto/AddEducationStudyDto.java rename to inventory-dao/src/main/java/com/rzyc/bean/pojo/dto/AddEducationStudyDto.java index e26c4ce..c614e00 100644 --- a/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/dto/AddEducationStudyDto.java +++ b/inventory-dao/src/main/java/com/rzyc/bean/pojo/dto/AddEducationStudyDto.java @@ -1,11 +1,8 @@ -package com.rzyc.bean.educationStudy.dto; +package com.rzyc.bean.pojo.dto; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; import javax.validation.constraints.NotBlank; -import java.util.Date; /** * @BelongsProject: inventory-api diff --git a/inventory-dao/src/main/java/com/rzyc/bean/pojo/vo/EducationResourceVo.java b/inventory-dao/src/main/java/com/rzyc/bean/pojo/vo/EducationResourceVo.java new file mode 100644 index 0000000..dac2013 --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/bean/pojo/vo/EducationResourceVo.java @@ -0,0 +1,83 @@ +package com.rzyc.bean.pojo.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Date; + +/** + * @BelongsProject: inventory-api + * @BelongsPackage: com.rzyc.bean.pojo.vo + * @Author: SYZ + * @CreateTime: 2023-03-29 20:07 + * @Version: 1.0 + */ +public class EducationResourceVo { + @ApiModelProperty(value = "主键") + private String id; + + @ApiModelProperty(value = "行业id") + private String industryId; + + @ApiModelProperty(value = "上传人id") + private String userId; + + @ApiModelProperty(value = "资料名") + private String name; + + @ApiModelProperty(value = "富文本") + private String content; + + @ApiModelProperty(value = "创建时间") + private String createTime; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIndustryId() { + return industryId; + } + + public void setIndustryId(String industryId) { + this.industryId = industryId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } +} + diff --git a/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/EducationStudyListVo.java b/inventory-dao/src/main/java/com/rzyc/bean/pojo/vo/EducationStudyListVo.java similarity index 97% rename from inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/EducationStudyListVo.java rename to inventory-dao/src/main/java/com/rzyc/bean/pojo/vo/EducationStudyListVo.java index d026fa7..cdc9e31 100644 --- a/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/EducationStudyListVo.java +++ b/inventory-dao/src/main/java/com/rzyc/bean/pojo/vo/EducationStudyListVo.java @@ -1,11 +1,9 @@ -package com.rzyc.bean.educationStudy.vo; +package com.rzyc.bean.pojo.vo; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; -import java.util.Date; - /** * @BelongsProject: inventory-api * @BelongsPackage: com.rzyc.bean.educationStudy.vo diff --git a/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/ListPageVo.java b/inventory-dao/src/main/java/com/rzyc/bean/pojo/vo/ListPageVo.java similarity index 96% rename from inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/ListPageVo.java rename to inventory-dao/src/main/java/com/rzyc/bean/pojo/vo/ListPageVo.java index 5d0b808..86a6bd0 100644 --- a/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/ListPageVo.java +++ b/inventory-dao/src/main/java/com/rzyc/bean/pojo/vo/ListPageVo.java @@ -1,4 +1,4 @@ -package com.rzyc.bean.educationStudy.vo; +package com.rzyc.bean.pojo.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/inventory-dao/src/main/java/com/rzyc/mapper/EducationResourceMapper.java b/inventory-dao/src/main/java/com/rzyc/mapper/EducationResourceMapper.java new file mode 100644 index 0000000..edbdfa0 --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/mapper/EducationResourceMapper.java @@ -0,0 +1,25 @@ +package com.rzyc.mapper; + +import com.rzyc.bean.pojo.vo.EducationResourceVo; +import com.rzyc.model.EducationResource; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author + * @since 2023-03-29 + */ +@Repository +public interface EducationResourceMapper extends BaseMapper { + + List selectEducationResourceList(@Param("queryWord") String queryWord, + @Param("industryId") String industryId); + +} diff --git a/inventory-dao/src/main/java/com/rzyc/mapper/EducationStudyMapper.java b/inventory-dao/src/main/java/com/rzyc/mapper/EducationStudyMapper.java index 73969cf..458f224 100644 --- a/inventory-dao/src/main/java/com/rzyc/mapper/EducationStudyMapper.java +++ b/inventory-dao/src/main/java/com/rzyc/mapper/EducationStudyMapper.java @@ -1,12 +1,11 @@ package com.rzyc.mapper; -import com.rzyc.bean.educationStudy.vo.EducationStudyListVo; +import com.rzyc.bean.pojo.vo.EducationStudyListVo; import com.rzyc.model.EducationStudy; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; -import javax.annotation.Resource; import java.util.List; /** @@ -22,6 +21,7 @@ public interface EducationStudyMapper extends BaseMapper { List selectEducationStudyList(@Param("startTime") String startTime, @Param("endTime") String endTime, + @Param("enterpriseId") String enterpriseId, @Param("queryWord") String queryWord); } diff --git a/inventory-dao/src/main/java/com/rzyc/model/EducationResource.java b/inventory-dao/src/main/java/com/rzyc/model/EducationResource.java new file mode 100644 index 0000000..9c1bed1 --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/model/EducationResource.java @@ -0,0 +1,115 @@ +package com.rzyc.model; + +import com.baomidou.mybatisplus.annotation.TableName; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + *

+ * + *

+ * + * @author + * @since 2023-03-29 + */ +@TableName("education_resource") +@ApiModel(value="EducationResource对象", description="") +public class EducationResource implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId("id") + private String id; + + @ApiModelProperty(value = "行业id") + @TableField("industry_id") + private String industryId; + + @ApiModelProperty(value = "上传人id") + @TableField("user_id") + private String userId; + + @ApiModelProperty(value = "资料名") + @TableField("name") + private String name; + + @ApiModelProperty(value = "富文本") + @TableField("content") + private String content; + + @ApiModelProperty(value = "创建时间") + @TableField("create_time") + private Date createTime; + + @ApiModelProperty(value = "最后修改时间") + @TableField("modify_time") + private Date modifyTime; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + public String getIndustryId() { + return industryId; + } + + public void setIndustryId(String industryId) { + this.industryId = industryId; + } + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + public Date getModifyTime() { + return modifyTime; + } + + public void setModifyTime(Date modifyTime) { + this.modifyTime = modifyTime; + } + + @Override + public String toString() { + return "EducationResource{" + + "id=" + id + + ", industryId=" + industryId + + ", userId=" + userId + + ", name=" + name + + ", content=" + content + + ", createTime=" + createTime + + ", modifyTime=" + modifyTime + + "}"; + } +} diff --git a/inventory-dao/src/main/resources/mapper/EducationResourceMapper.xml b/inventory-dao/src/main/resources/mapper/EducationResourceMapper.xml new file mode 100644 index 0000000..09ad859 --- /dev/null +++ b/inventory-dao/src/main/resources/mapper/EducationResourceMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + id + , industry_id, user_id, name, content, create_time, modify_time + + + + diff --git a/inventory-dao/src/main/resources/mapper/EducationStudyMapper.xml b/inventory-dao/src/main/resources/mapper/EducationStudyMapper.xml index eaa5053..abc94a9 100644 --- a/inventory-dao/src/main/resources/mapper/EducationStudyMapper.xml +++ b/inventory-dao/src/main/resources/mapper/EducationStudyMapper.xml @@ -5,27 +5,31 @@ - - - - - - - - + + + + + + + + id, enterprise_id, title, content, user_id, study_date, study_unit, create_time - SELECT id,enterprise_id,title,content,user_id,DATE_FORMAT(study_date,'%Y-%m-%d')'study_date',study_unit FROM `education_study` - WHERE study_date = ]]> #{startTime} and study_date #{endTime} + WHERE enterprise_id = #{enterpriseId} and title like concat('%',#{queryWord},'%') + + and study_date =]]> #{startTime} + and study_date #{endTime} + Order By create_time DESC diff --git a/inventory-ent/src/main/java/com/rzyc/advice/ExceptionAdvice.java b/inventory-ent/src/main/java/com/rzyc/advice/ExceptionAdvice.java index ed269c3..7d6c1f4 100644 --- a/inventory-ent/src/main/java/com/rzyc/advice/ExceptionAdvice.java +++ b/inventory-ent/src/main/java/com/rzyc/advice/ExceptionAdvice.java @@ -118,7 +118,7 @@ public class ExceptionAdvice { logger.info("MethodArgumentNotValidException message -> "+e.getMessage()); SingleResult result = new SingleResult<>(); result.setCode(Code.EX_PARAM.getCode()); - result.setMessage(e.getMessage()); + result.setMessage(e.getBindingResult().getFieldError().getDefaultMessage()); return result; } diff --git a/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java b/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java index 6f81d54..279ae6f 100644 --- a/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java +++ b/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java @@ -576,6 +576,10 @@ public class BaseController { @Autowired protected EducationStudyMapper educationStudyMapper; + //培训资料 + @Autowired + protected EducationResourceMapper educationResourceMapper; + /*高敏感场所*/ protected String HIGH_SENSITIVE_PLACES = "502b1ff4-bd01-11eb-9d3c-00163e0c1c62"; diff --git a/inventory-ent/src/main/java/com/rzyc/controller/EducationStudyController.java b/inventory-ent/src/main/java/com/rzyc/controller/EducationStudyController.java index 7f1a0d8..33caa89 100644 --- a/inventory-ent/src/main/java/com/rzyc/controller/EducationStudyController.java +++ b/inventory-ent/src/main/java/com/rzyc/controller/EducationStudyController.java @@ -1,26 +1,35 @@ package com.rzyc.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.common.utils.DateUtils; import com.common.utils.StringUtils; import com.common.utils.model.Code; import com.common.utils.model.SingleResult; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; -import com.rzyc.bean.educationStudy.dto.AddEducationStudyDto; -import com.rzyc.bean.educationStudy.vo.EducationStudyListVo; -import com.rzyc.bean.educationStudy.vo.ListPageVo; +import com.rzyc.bean.pojo.dto.AddEducationResourceDto; +import com.rzyc.bean.pojo.dto.AddEducationStudyDto; +import com.rzyc.bean.pojo.vo.EducationResourceVo; +import com.rzyc.bean.pojo.vo.EducationStudyListVo; +import com.rzyc.bean.pojo.vo.ListPageVo; import com.rzyc.bean.task.dto.PageDto; +import com.rzyc.model.EducationResource; import com.rzyc.model.EducationStudy; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; + import javax.validation.Valid; import javax.validation.constraints.NotBlank; +import java.lang.reflect.InvocationTargetException; import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; /** * @BelongsProject: inventory-api @@ -38,20 +47,29 @@ import java.util.Date; public class EducationStudyController extends BaseController { /** - * 检查记录详细 - */ - @ApiOperation(value = "获取列表") + * @description:获取培训学习列表 + * @author: SYZ + * @date: 2023/3/29 20:09 + * @param: [dto, year, enterpriseId] + * @return: com.common.utils.model.SingleResult> + **/ + @ApiOperation(value = "获取培训学习列表") @ApiImplicitParams({ - @ApiImplicitParam(name = "year",value = "年份",dataType = "int",paramType = "query",required = true) + @ApiImplicitParam(name = "year", value = "年份", dataType = "int", paramType = "query"), + @ApiImplicitParam(name = "enterpriseId", value = "企业id", dataType = "string", paramType = "query", required = true) }) @GetMapping("/getList") @ResponseBody - public SingleResult> getList(@Valid PageDto dto, int year) throws Exception{ - SingleResult> result = new SingleResult<>(); - String startDate = DateUtils.parseDate2String(DateUtils.getFirstDayOfMonth(year,1), "yyyy-MM-dd HH:mm:ss"); - String endDate = DateUtils.parseDate2String(DateUtils.getLastDayOfMonth(year,12), "yyyy-MM-dd HH:mm:ss"); + public SingleResult> getList(@Valid PageDto dto, Integer year, String enterpriseId) throws Exception { + SingleResult> result = new SingleResult<>(); + String startDate = ""; + String endDate = ""; + if (null != year) { + startDate = DateUtils.parseDate2String(DateUtils.getFirstDayOfMonth(year, 1), "yyyy-MM-dd HH:mm:ss"); + endDate = DateUtils.parseDate2String(DateUtils.getLastDayOfMonth(year, 12), "yyyy-MM-dd HH:mm:ss"); + } PageHelper.startPage(dto.getPage(), dto.getPageSize()); - Page list = (Page) educationStudyMapper.selectEducationStudyList(startDate, endDate, dto.getCondition()); + Page list = (Page) educationStudyMapper.selectEducationStudyList(startDate, endDate, enterpriseId, dto.getCondition()); ListPageVo pageVo = new ListPageVo<>(); pageVo.setRows(list); pageVo.setTotal(list.getTotal()); @@ -61,34 +79,59 @@ public class EducationStudyController extends BaseController { return result; } - @ApiOperation(value = "添加") + /** + * @description:添加培训学习 + * @author: SYZ + * @date: 2023/3/29 20:09 + * @param: [dto] + * @return: com.common.utils.model.SingleResult + **/ + @ApiOperation(value = "添加培训学习") @PostMapping("/addOne") @ResponseBody public SingleResult addOne(@Valid AddEducationStudyDto dto) { SingleResult result = new SingleResult<>(); + Integer count = educationStudyMapper.selectCount( + new QueryWrapper().select("1").eq("id", dto.getId()) + ); EducationStudy educationStudy = new EducationStudy(); educationStudy.setId(dto.getId()); educationStudy.setEnterpriseId(dto.getEnterpriseId()); educationStudy.setTitle(StringUtils.isBlank(dto.getTitle()) ? "" : dto.getTitle()); educationStudy.setContent(StringUtils.isBlank(dto.getContent()) ? "" : dto.getContent()); educationStudy.setUserId(StringUtils.isBlank(dto.getUserId()) ? "" : dto.getUserId()); - educationStudy.setStudyDate(DateUtils.parseString2Date(dto.getStudyDate(),"yyyy-MM-dd")); + educationStudy.setStudyDate(DateUtils.parseString2Date(dto.getStudyDate(), "yyyy-MM-dd")); educationStudy.setStudyUnit(StringUtils.isBlank(dto.getStudyUnit()) ? "" : dto.getStudyUnit()); educationStudy.setCreateTime(new Date()); - int insertRow = educationStudyMapper.insert(educationStudy); - return (0 == insertRow) ? result.setCodeMessageChain(Code.ERROR.getCode(), "失败") : result.setCodeMessageChain(Code.ERROR.getCode(), "成功"); - + if (0 == count){ + int insertRow = educationStudyMapper.insert(educationStudy); + return (0 == insertRow) ? result.setCodeMessageChain(Code.ERROR.getCode(), "失败") : result.setCodeMessageChain(Code.SUCCESS.getCode(), "成功"); + }else{ + int updateRow = educationStudyMapper.updateById(educationStudy); + return (0 == updateRow) ? result.setCodeMessageChain(Code.ERROR.getCode(), "失败") : result.setCodeMessageChain(Code.SUCCESS.getCode(), "成功"); + } } - @ApiOperation(value = "删除") + /** + * @description:删除培训学习 + * @author: SYZ + * @date: 2023/3/29 20:09 + * @param: [id] + * @return: com.common.utils.model.SingleResult + **/ + @ApiOperation(value = "删除培训学习") @GetMapping("/delOne") @ApiImplicitParam(name = "id", value = "主键id", dataType = "string", paramType = "query", required = true) @ResponseBody public SingleResult delOne(@NotBlank(message = "id不能为空") String id) { SingleResult result = new SingleResult<>(); int delRow = educationStudyMapper.deleteById(id); - return (0 == delRow) ? result.setCodeMessageChain(Code.ERROR.getCode(), "失败") : result.setCodeMessageChain(Code.ERROR.getCode(), "成功"); + return (0 == delRow) ? result.setCodeMessageChain(Code.ERROR.getCode(), "失败") : result.setCodeMessageChain(Code.SUCCESS.getCode(), "成功"); } + + + + } diff --git a/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java b/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java index 6983ce4..3ac0fae 100644 --- a/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java +++ b/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java @@ -48,6 +48,14 @@ import java.util.*; */ public class BaseController { + //培训学习 + @Autowired + protected EducationStudyMapper educationStudyMapper; + + //培训资料 + @Autowired + protected EducationResourceMapper educationResourceMapper; + /*用户*/ @Autowired protected SysUserMapper sysUserMapper; diff --git a/inventory-gov/src/main/java/com/rzyc/controller/IndustryListController.java b/inventory-gov/src/main/java/com/rzyc/controller/IndustryListController.java index 13a7515..0361fca 100644 --- a/inventory-gov/src/main/java/com/rzyc/controller/IndustryListController.java +++ b/inventory-gov/src/main/java/com/rzyc/controller/IndustryListController.java @@ -1,13 +1,19 @@ package com.rzyc.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.common.utils.DateUtils; import com.common.utils.RandomNumber; import com.common.utils.StringUtils; import com.common.utils.model.*; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import com.rzyc.bean.pojo.dto.AddEducationResourceDto; +import com.rzyc.bean.pojo.vo.EducationResourceVo; +import com.rzyc.bean.pojo.vo.ListPageVo; +import com.rzyc.bean.task.dto.PageDto; import com.rzyc.enums.PostListType; +import com.rzyc.model.EducationResource; import com.rzyc.model.InPost; import com.rzyc.model.InPostItem; import com.rzyc.model.InPostList; @@ -18,6 +24,8 @@ import com.rzyc.model.ent.InListItem; import com.rzyc.service.PcBusinessService; import com.rzyc.service.SaveIndustryPostThread; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import javax.validation.constraints.NotBlank; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; @@ -367,7 +376,79 @@ public class IndustryListController extends BaseController{ + /** + * @description:获取培训资料列表 + * @author: SYZ + * @date: 2023/3/29 20:18 + * @param: [dto] + * @return: com.common.utils.model.SingleResult> + **/ + @ApiOperation(value = "获取培训资料列表") + @ApiImplicitParams({ + @ApiImplicitParam(name = "industryId",value = "行业id",dataType = "string",paramType = "query",required = true) + }) + @GetMapping("/getEducationResourceList") + @ResponseBody + public SingleResult> getEducationResourceList(@Valid PageDto dto,String industryId){ + SingleResult> result = new SingleResult<>(); + PageHelper.startPage(dto.getPage(), dto.getPageSize()); + Page page = (Page) educationResourceMapper.selectEducationResourceList(dto.getCondition(),industryId); + ListPageVo pageVo = new ListPageVo<>(); + pageVo.setRows(page); + pageVo.setTotal(page.getTotal()); + pageVo.setPage(page.getPageNum()); + pageVo.setPageSize(page.getPageSize()); + result.setData(pageVo); + return result; + } + /** + * @description:添加培训资料 + * @author: SYZ + * @date: 2023/3/29 20:07 + * @param: [dto] + * @return: com.common.utils.model.SingleResult + **/ + @ApiOperation(value = "添加培训资料") + @PostMapping("/addEducationResourceOne") + @ResponseBody + public SingleResult addEducationResourceOne(@RequestBody @Valid AddEducationResourceDto dto){ + SingleResult result = new SingleResult<>(); + Integer count = educationResourceMapper.selectCount( + new QueryWrapper().select("1").eq("id", dto.getId()) + ); + EducationResource educationResource = new EducationResource(); + BeanUtils.copyProperties(dto,educationResource); + educationResource.setName(StringUtils.isBlank(dto.getName()) ? "" : dto.getName()); + educationResource.setContent(StringUtils.isBlank(dto.getContent()) ? "" : dto.getContent()); + if (0 == count){ + educationResource.setCreateTime(new Date()); + educationResource.setModifyTime(new Date()); + int insertRow = educationResourceMapper.insert(educationResource); + return 0 == insertRow ? result.setCodeMessageChain(Code.ERROR.getCode(), "失败") : result.setCodeMessageChain(Code.SUCCESS.getCode(), "成功"); + }else { + educationResource.setModifyTime(new Date()); + int updateRow = educationResourceMapper.updateById(educationResource); + return 0 == updateRow ? result.setCodeMessageChain(Code.ERROR.getCode(), "修改失败") : result.setCodeMessageChain(Code.SUCCESS.getCode(), "修改成功"); + } + } + + /** + * @description:删除培训资料 + * @author: SYZ + * @date: 2023/3/29 20:06 + * @param: [id] + * @return: com.common.utils.model.SingleResult + **/ + @ApiOperation(value = "删除培训资料") + @GetMapping("/delEducationResourceOne") + @ApiImplicitParam(name = "id", value = "主键id", dataType = "string", paramType = "query", required = true) + @ResponseBody + public SingleResult delEducationResourceOne(@NotBlank(message = "id不能为空") String id){ + SingleResult result = new SingleResult<>(); + int delRow = educationResourceMapper.deleteById(id); + return (0 == delRow) ? result.setCodeMessageChain(Code.ERROR.getCode(), "失败") : result.setCodeMessageChain(Code.SUCCESS.getCode(), "成功"); + }