From ae488c77d093d859fe6df06f782a619e1bf718de Mon Sep 17 00:00:00 2001 From: longxiuwen <2691049525@qq.com> Date: Mon, 27 Mar 2023 14:11:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=95=99=E8=82=B2=E5=9F=B9?= =?UTF-8?q?=E8=AE=AD=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/AddEducationStudyDto.java | 100 ++++++++++++++ .../vo/EducationStudyListVo.java | 101 ++++++++++++++ .../bean/educationStudy/vo/ListPageVo.java | 54 ++++++++ .../com/rzyc/mapper/EducationStudyMapper.java | 27 ++++ .../java/com/rzyc/model/EducationStudy.java | 127 ++++++++++++++++++ .../resources/mapper/EducationStudyMapper.xml | 32 +++++ .../java/com/rzyc/config/CodeGenerator.java | 6 +- .../com/rzyc/controller/BaseController.java | 4 + .../controller/EducationStudyController.java | 94 +++++++++++++ .../main/java/com/common/utils/DateUtils.java | 48 +++++++ .../com/common/utils/model/SingleResult.java | 6 + 11 files changed, 596 insertions(+), 3 deletions(-) create mode 100644 inventory-dao/src/main/java/com/rzyc/bean/educationStudy/dto/AddEducationStudyDto.java create mode 100644 inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/EducationStudyListVo.java create mode 100644 inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/ListPageVo.java create mode 100644 inventory-dao/src/main/java/com/rzyc/mapper/EducationStudyMapper.java create mode 100644 inventory-dao/src/main/java/com/rzyc/model/EducationStudy.java create mode 100644 inventory-dao/src/main/resources/mapper/EducationStudyMapper.xml create mode 100644 inventory-ent/src/main/java/com/rzyc/controller/EducationStudyController.java diff --git a/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/dto/AddEducationStudyDto.java b/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/dto/AddEducationStudyDto.java new file mode 100644 index 0000000..e26c4ce --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/dto/AddEducationStudyDto.java @@ -0,0 +1,100 @@ +package com.rzyc.bean.educationStudy.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.educationStudy.dto + * @Author: SYZ + * @CreateTime: 2023-03-27 10:58 + * @Version: 1.0 + */ +public class AddEducationStudyDto { + + @ApiModelProperty(value = "主键",required = true) + @NotBlank(message = "不能为空") + private String id; + + @ApiModelProperty(value = "企业id",required = true) + @NotBlank(message = "不能为空") + private String enterpriseId; + + @ApiModelProperty(value = "摘要") + private String title; + + @ApiModelProperty(value = "内容") + private String content; + + @ApiModelProperty(value = "上传人id",required = true) + @NotBlank(message = "不能为空") + private String userId; + + @ApiModelProperty(value = "培训的学习时间") + private String studyDate; + + @ApiModelProperty(value = "培训的学习单位") + private String studyUnit; + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getEnterpriseId() { + return enterpriseId; + } + + public void setEnterpriseId(String enterpriseId) { + this.enterpriseId = enterpriseId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getStudyDate() { + return studyDate; + } + + public void setStudyDate(String studyDate) { + this.studyDate = studyDate; + } + + public String getStudyUnit() { + return studyUnit; + } + + public void setStudyUnit(String studyUnit) { + this.studyUnit = studyUnit; + } +} + diff --git a/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/EducationStudyListVo.java b/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/EducationStudyListVo.java new file mode 100644 index 0000000..d026fa7 --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/EducationStudyListVo.java @@ -0,0 +1,101 @@ +package com.rzyc.bean.educationStudy.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 + * @Author: SYZ + * @CreateTime: 2023-03-27 11:11 + * @Version: 1.0 + */ +public class EducationStudyListVo { + @ApiModelProperty(value = "主键") + @TableId("id") + private String id; + + @ApiModelProperty(value = "企业id") + @TableField("enterprise_id") + private String enterpriseId; + + @ApiModelProperty(value = "摘要") + @TableField("title") + private String title; + + @ApiModelProperty(value = "内容") + @TableField("content") + private String content; + + @ApiModelProperty(value = "上传人id") + @TableField("user_id") + private String userId; + + @ApiModelProperty(value = "培训的学习时间") + @TableField("study_date") + private String studyDate; + + @ApiModelProperty(value = "培训的学习单位") + @TableField("study_unit") + private String studyUnit; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getEnterpriseId() { + return enterpriseId; + } + + public void setEnterpriseId(String enterpriseId) { + this.enterpriseId = enterpriseId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getStudyDate() { + return studyDate; + } + + public void setStudyDate(String studyDate) { + this.studyDate = studyDate; + } + + public String getStudyUnit() { + return studyUnit; + } + + public void setStudyUnit(String studyUnit) { + this.studyUnit = studyUnit; + } +} + diff --git a/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/ListPageVo.java b/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/ListPageVo.java new file mode 100644 index 0000000..5d0b808 --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/bean/educationStudy/vo/ListPageVo.java @@ -0,0 +1,54 @@ +package com.rzyc.bean.educationStudy.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; + +@ApiModel("分页返回实体") +public class ListPageVo{ + @ApiModelProperty(value = "每页条数") + private Integer pageSize = 10;//每页显示多少条 + + @ApiModelProperty(value = "当前页码") + private Integer page = 1;//当前页 + + @ApiModelProperty(value = "总条数") + private Long total = 0L; + + @ApiModelProperty(value = "分页数据") + private List rows = new ArrayList(); + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public Long getTotal() { + return total; + } + + public void setTotal(Long total) { + this.total = total; + } + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } +} \ No newline at end of file diff --git a/inventory-dao/src/main/java/com/rzyc/mapper/EducationStudyMapper.java b/inventory-dao/src/main/java/com/rzyc/mapper/EducationStudyMapper.java new file mode 100644 index 0000000..73969cf --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/mapper/EducationStudyMapper.java @@ -0,0 +1,27 @@ +package com.rzyc.mapper; + +import com.rzyc.bean.educationStudy.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; + +/** + *

+ * 教育培训表 Mapper 接口 + *

+ * + * @author + * @since 2023-03-27 + */ +@Repository +public interface EducationStudyMapper extends BaseMapper { + + List selectEducationStudyList(@Param("startTime") String startTime, + @Param("endTime") String endTime, + @Param("queryWord") String queryWord); + +} diff --git a/inventory-dao/src/main/java/com/rzyc/model/EducationStudy.java b/inventory-dao/src/main/java/com/rzyc/model/EducationStudy.java new file mode 100644 index 0000000..a0ac0f4 --- /dev/null +++ b/inventory-dao/src/main/java/com/rzyc/model/EducationStudy.java @@ -0,0 +1,127 @@ +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-27 + */ +@TableName("education_study") +@ApiModel(value="EducationStudy对象", description="教育培训表") +public class EducationStudy implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId("id") + private String id; + + @ApiModelProperty(value = "企业id") + @TableField("enterprise_id") + private String enterpriseId; + + @ApiModelProperty(value = "摘要") + @TableField("title") + private String title; + + @ApiModelProperty(value = "内容") + @TableField("content") + private String content; + + @ApiModelProperty(value = "上传人id") + @TableField("user_id") + private String userId; + + @ApiModelProperty(value = "培训的学习时间") + @TableField("study_date") + private Date studyDate; + + @ApiModelProperty(value = "培训的学习单位") + @TableField("study_unit") + private String studyUnit; + + @ApiModelProperty(value = "创建时间") + @TableField("create_time") + private Date createTime; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + public String getEnterpriseId() { + return enterpriseId; + } + + public void setEnterpriseId(String enterpriseId) { + this.enterpriseId = enterpriseId; + } + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + public Date getStudyDate() { + return studyDate; + } + + public void setStudyDate(Date studyDate) { + this.studyDate = studyDate; + } + public String getStudyUnit() { + return studyUnit; + } + + public void setStudyUnit(String studyUnit) { + this.studyUnit = studyUnit; + } + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public String toString() { + return "EducationStudy{" + + "id=" + id + + ", enterpriseId=" + enterpriseId + + ", title=" + title + + ", content=" + content + + ", userId=" + userId + + ", studyDate=" + studyDate + + ", studyUnit=" + studyUnit + + ", createTime=" + createTime + + "}"; + } +} diff --git a/inventory-dao/src/main/resources/mapper/EducationStudyMapper.xml b/inventory-dao/src/main/resources/mapper/EducationStudyMapper.xml new file mode 100644 index 0000000..eaa5053 --- /dev/null +++ b/inventory-dao/src/main/resources/mapper/EducationStudyMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + id, enterprise_id, title, content, user_id, study_date, study_unit, create_time + + + + diff --git a/inventory-ent/src/main/java/com/rzyc/config/CodeGenerator.java b/inventory-ent/src/main/java/com/rzyc/config/CodeGenerator.java index 64fb3eb..864711e 100644 --- a/inventory-ent/src/main/java/com/rzyc/config/CodeGenerator.java +++ b/inventory-ent/src/main/java/com/rzyc/config/CodeGenerator.java @@ -25,14 +25,14 @@ import java.util.Scanner; public class CodeGenerator { //java路径 - public static String jarStr = "/citysafexc-api/src/main/java"; + public static String jarStr = "/inventory-dao/src/main/java"; //mapper路径 - public static String mapperStr = "/citysafexc-api/src/main/resources/mapper/"; + public static String mapperStr = "/inventory-dao/src/main/resources/mapper/"; //根目录报名 public static String packgerParent = "com.rzyc"; //mysql相关信息 - public static String url = "jdbc:mysql://121.40.106.103:3306/citysafe_xc_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false"; + public static String url = "jdbc:mysql://121.40.106.103:3306/inventory_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false"; public static String DriverName = "com.mysql.cj.jdbc.Driver"; public static String Username = "rzyc"; public static String Password = "admin@rzyc2022.com##"; 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 a39edf1..6f81d54 100644 --- a/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java +++ b/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java @@ -572,6 +572,10 @@ public class BaseController { @Autowired protected RkCompanyDiagnosisMapper rkCompanyDiagnosisMapper; + //培训学习 + @Autowired + protected EducationStudyMapper educationStudyMapper; + /*高敏感场所*/ 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 new file mode 100644 index 0000000..7f1a0d8 --- /dev/null +++ b/inventory-ent/src/main/java/com/rzyc/controller/EducationStudyController.java @@ -0,0 +1,94 @@ +package com.rzyc.controller; + +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.task.dto.PageDto; +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.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.util.Date; + +/** + * @BelongsProject: inventory-api + * @BelongsPackage: com.rzyc.controller + * @Author: SYZ + * @CreateTime: 2023-03-27 10:39 + * @Version: 1.0 + */ + +@Api(tags = "教育培训接口") +@CrossOrigin("*") +@RequestMapping("education") +@Controller +@Validated +public class EducationStudyController extends BaseController { + + /** + * 检查记录详细 + */ + @ApiOperation(value = "获取列表") + @ApiImplicitParams({ + @ApiImplicitParam(name = "year",value = "年份",dataType = "int",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"); + PageHelper.startPage(dto.getPage(), dto.getPageSize()); + Page list = (Page) educationStudyMapper.selectEducationStudyList(startDate, endDate, dto.getCondition()); + ListPageVo pageVo = new ListPageVo<>(); + pageVo.setRows(list); + pageVo.setTotal(list.getTotal()); + pageVo.setPage(list.getPageNum()); + pageVo.setPageSize(list.getPageSize()); + result.setData(pageVo); + return result; + } + + @ApiOperation(value = "添加") + @PostMapping("/addOne") + @ResponseBody + public SingleResult addOne(@Valid AddEducationStudyDto dto) { + SingleResult result = new SingleResult<>(); + 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.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(), "成功"); + + } + + @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(), "成功"); + } + +} + diff --git a/utils/src/main/java/com/common/utils/DateUtils.java b/utils/src/main/java/com/common/utils/DateUtils.java index e3cd5ca..d4ec3b1 100644 --- a/utils/src/main/java/com/common/utils/DateUtils.java +++ b/utils/src/main/java/com/common/utils/DateUtils.java @@ -476,5 +476,53 @@ public final class DateUtils { return DateUtils.parseCalendar2String(calendar,"yyyy-MM-dd"); } + /** + * 获取指定某年某月的最后一天,最后一秒最后的时间 + * @Version: 1.0 + * @Author: SYZ + * @Date: 2023/1/3 18:18 + */ + public static Date getLastDayOfMonth(int year, int month) { + Calendar cal = Calendar.getInstance(); + //设置年份 + cal.set(Calendar.YEAR, year); + //设置月份 + cal.set(Calendar.MONTH, month-1); + //获取某月最大天数 + int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH); + //设置日历中月份的最大天数 + cal.set(Calendar.DAY_OF_MONTH, lastDay); + cal.set(Calendar.HOUR_OF_DAY, 23); + cal.set(Calendar.MINUTE, 59); + cal.set(Calendar.SECOND, 59); + //格式化日期 +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// +// String lastDayOfMonth = sdf.format(cal.getTime()); + return cal.getTime(); + } + + /** + * 获取指定某年某月的第一天第一秒 + * @Version: 1.0 + * @Author: SYZ + * @Date: 2023/1/3 18:18 + */ + public static Date getFirstDayOfMonth(int year, int month) { + Calendar cal = Calendar.getInstance(); + //设置年份 + cal.set(Calendar.YEAR, year); + //设置月份 + cal.set(Calendar.MONTH, month -1); + + cal.set(Calendar.DAY_OF_MONTH, 1); + cal.set(Calendar.HOUR_OF_DAY, 00); + cal.set(Calendar.MINUTE, 00); + cal.set(Calendar.SECOND, 00); + //格式化日期 +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// String lastDayOfMonth = sdf.format(cal.getTime()); + return cal.getTime(); + } } diff --git a/utils/src/main/java/com/common/utils/model/SingleResult.java b/utils/src/main/java/com/common/utils/model/SingleResult.java index 14ec424..9405bd9 100644 --- a/utils/src/main/java/com/common/utils/model/SingleResult.java +++ b/utils/src/main/java/com/common/utils/model/SingleResult.java @@ -30,4 +30,10 @@ public class SingleResult extends Result { this.data = (T) pager; } + public SingleResult setCodeMessageChain(int code,String msg) { + super.setCode(code); + super.setMessage(msg); + return this; + } + }