Commit 33d729cc authored by 夏敏伟's avatar 夏敏伟

Merge branch 'master' of http://192.168.168.218/wcyuee/szpt

# Conflicts:
#	src/main/java/com/zksy/szpt/controller/IndexController.java
#	src/main/java/com/zksy/szpt/service/IndexService.java
parents 38125140 108148b4
......@@ -3,6 +3,7 @@ package com.zksy.szpt.aspect;
import com.zksy.szpt.domain.HttpResult;
import com.zksy.szpt.domain.HttpResultState;
import com.zksy.szpt.exception.NotificationException;
import org.apache.ibatis.javassist.NotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -135,11 +136,11 @@ public class GlobalExceptionHandler {
//endregion
// @ResponseBody
// @ExceptionHandler({NotificationException.class})
// public HttpResult<HttpResultState> NotificationExceptionHandler(NotificationException e) {
// HttpResultState state = HttpResultState.NOTIFICATION;
// state.setMessage(e.getMessage());
// return new HttpResult<>(state);
// }
@ResponseBody
@ExceptionHandler({NotificationException.class})
public HttpResult<HttpResultState> NotificationExceptionHandler(NotificationException e) {
HttpResultState state = HttpResultState.NOTIFICATION;
state.setMessage(e.getMessage());
return new HttpResult<>(state);
}
}
package com.zksy.szpt.controller;
import com.zksy.szpt.domain.UploadImageDTO;
import com.zksy.szpt.exception.NotificationException;
import com.zksy.szpt.service.ImageUploadService;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
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;
@Api(tags = "文件上传管理")
@RequestMapping("/rest/image")
@RestController
public class ImageUploadController {
private final ImageUploadService imageUploadService;
public ImageUploadController(ImageUploadService imageUploadService) {
this.imageUploadService = imageUploadService;
}
@PostMapping("/upload")
public Integer upload(@RequestBody @Validated UploadImageDTO uploadImageDTO) throws NotificationException {
return imageUploadService.upload(uploadImageDTO);
}
}
......@@ -82,4 +82,28 @@ public class IndexController {
public Integer addSzptQyxx(@RequestBody @Validated SzptQyxxDTO szptQyxxDTO){
return indexService.addSzptQyxx(szptQyxxDTO);
}
@ApiOperation(value="新增账号信息数据")
@PostMapping("/addXxZhxx")
public Integer addXxZhxx(@RequestBody @Validated XxZhxxDTO xxZhxxDTO){
return indexService.addXxZhxx(xxZhxxDTO);
}
@ApiOperation(value="新增账户积分变更信息数据")
@PostMapping("/addXxZhjfbg")
public Integer addXxZhjfbg(@RequestBody @Validated XxZhjfbgDTO dto){
return indexService.addXxZhjfbg(dto);
}
@ApiOperation(value="新增义警任务信息数据")
@PostMapping("/addXxYjrw")
public Integer addXxYjrw(@RequestBody @Validated XxYjrwDTO dto){
return indexService.addXxYjrw(dto);
}
@ApiOperation(value="新增义警队伍代码信息数据")
@PostMapping("/addXxYjdwdm")
public Integer addXxYjdwdm(@RequestBody @Validated XxYjdwdmDTO dto){
return indexService.addXxYjdwdm(dto);
}
}
package com.zksy.szpt.domain;
public enum ListImageType {
FACE,
BODY
}
package com.zksy.szpt.domain;
import javax.validation.constraints.NotBlank;
public class UploadImageDTO {
@NotBlank(message = "图片路径不能为空")
private String imagePath;
private ListImageType imageType;
public String getImagePath() {
return imagePath;
}
public void setImagePath(String imagePath) {
this.imagePath = imagePath;
}
public ListImageType getImageType() {
return imageType;
}
public void setImageType(ListImageType imageType) {
this.imageType = imageType;
}
}
package com.zksy.szpt.domain.dto;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
public class XxYjdwdmDTO {
/**
* 义警队伍代码ID
*/
@NotBlank(message = "义警队伍代码不能为空")
private String id;
/**
* 运营单位ID
*/
@NotBlank(message = "运营单位ID不能为空")
private String mchid;
/**
* 队伍名称
*/
@NotBlank(message = "队伍名称不能为空")
private String yjdwmc;
/**
* 队伍介绍
*/
private String yjdwjs;
/**
* 父分类代码ID
*/
private String fid;
/**
* 状态;cslb=3101
*/
@NotBlank(message = "状态不能为空")
private String zt;
/**
* 队伍类型(0:外部队伍;1:内部队伍)
*/
@NotNull(message = "队伍类型不能为空")
private Integer dwlx;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getMchid() {
return mchid;
}
public void setMchid(String mchid) {
this.mchid = mchid == null ? null : mchid.trim();
}
public String getYjdwmc() {
return yjdwmc;
}
public void setYjdwmc(String yjdwmc) {
this.yjdwmc = yjdwmc == null ? null : yjdwmc.trim();
}
public String getYjdwjs() {
return yjdwjs;
}
public void setYjdwjs(String yjdwjs) {
this.yjdwjs = yjdwjs == null ? null : yjdwjs.trim();
}
public String getFid() {
return fid;
}
public void setFid(String fid) {
this.fid = fid == null ? null : fid.trim();
}
public String getZt() {
return zt;
}
public void setZt(String zt) {
this.zt = zt == null ? null : zt.trim();
}
public Integer getDwlx() {
return dwlx;
}
public void setDwlx(Integer dwlx) {
this.dwlx = dwlx;
}
}
\ No newline at end of file
package com.zksy.szpt.domain.dto;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
public class XxYjrwDTO {
/**
* 任务ID
*/
@NotBlank(message = "任务ID不能为空")
private String rwid;
/**
* 周期任务ID
*/
private String taskId;
/**
* 任务类型;cslb=3211
*/
private String rwlx;
/**
* 任务标题
*/
@NotBlank(message = "任务标题不能为空")
private String rwbt;
/**
* 任务内容;
*/
@NotBlank(message = "任务内容不能为空")
private String rwnr;
/**
* 人均奖励积分
*/
private Long rjjljf;
/**
* 工作人数
*/
@NotNull(message = "工作人数不能为空")
private Long gzrs;
/**
* 完成人数
*/
@NotNull(message = "完成人数不能为空")
private Long wcrs;
/**
* 任务起始日期
*/
private Date rwqsrq;
/**
* 任务截止日期
*/
private Date rwjzrq;
/**
* 时间模式(1:单次;2:周期;3:间隔;)
*/
private Integer timePattern;
/**
* 周期任务id
*/
private String scheduleId;
/**
* 审核模式(0:审核;1:无需审核)
*/
@NotNull(message = "审核模式不能为空")
private Integer sfsh;
/**
* 发表范围
*/
private String fbfw;
/**
* 发表范围编码
*/
private String fbfwbm;
/**
* 发布人id
*/
private String fbrid;
/**
* 发布人姓名
*/
private String fbrxm;
/**
* 发布时间
*/
private Date fbsj;
/**
* 运营单位ID
*/
private String mchid;
/**
* 任务状态;cslb=3213
*/
private String rwzt;
/**
* 图片
*/
private String pictureUrls;
public String getRwid() {
return rwid;
}
public void setRwid(String rwid) {
this.rwid = rwid == null ? null : rwid.trim();
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId == null ? null : taskId.trim();
}
public String getRwlx() {
return rwlx;
}
public void setRwlx(String rwlx) {
this.rwlx = rwlx == null ? null : rwlx.trim();
}
public String getRwbt() {
return rwbt;
}
public void setRwbt(String rwbt) {
this.rwbt = rwbt == null ? null : rwbt.trim();
}
public String getRwnr() {
return rwnr;
}
public void setRwnr(String rwnr) {
this.rwnr = rwnr == null ? null : rwnr.trim();
}
public Long getRjjljf() {
return rjjljf;
}
public void setRjjljf(Long rjjljf) {
this.rjjljf = rjjljf;
}
public Long getGzrs() {
return gzrs;
}
public void setGzrs(Long gzrs) {
this.gzrs = gzrs;
}
public Long getWcrs() {
return wcrs;
}
public void setWcrs(Long wcrs) {
this.wcrs = wcrs;
}
public Date getRwqsrq() {
return rwqsrq;
}
public void setRwqsrq(Date rwqsrq) {
this.rwqsrq = rwqsrq;
}
public Date getRwjzrq() {
return rwjzrq;
}
public void setRwjzrq(Date rwjzrq) {
this.rwjzrq = rwjzrq;
}
public Integer getTimePattern() {
return timePattern;
}
public void setTimePattern(Integer timePattern) {
this.timePattern = timePattern;
}
public String getScheduleId() {
return scheduleId;
}
public void setScheduleId(String scheduleId) {
this.scheduleId = scheduleId == null ? null : scheduleId.trim();
}
public Integer getSfsh() {
return sfsh;
}
public void setSfsh(Integer sfsh) {
this.sfsh = sfsh;
}
public String getFbfw() {
return fbfw;
}
public void setFbfw(String fbfw) {
this.fbfw = fbfw == null ? null : fbfw.trim();
}
public String getFbfwbm() {
return fbfwbm;
}
public void setFbfwbm(String fbfwbm) {
this.fbfwbm = fbfwbm == null ? null : fbfwbm.trim();
}
public String getFbrid() {
return fbrid;
}
public void setFbrid(String fbrid) {
this.fbrid = fbrid == null ? null : fbrid.trim();
}
public String getFbrxm() {
return fbrxm;
}
public void setFbrxm(String fbrxm) {
this.fbrxm = fbrxm == null ? null : fbrxm.trim();
}
public Date getFbsj() {
return fbsj;
}
public void setFbsj(Date fbsj) {
this.fbsj = fbsj;
}
public String getMchid() {
return mchid;
}
public void setMchid(String mchid) {
this.mchid = mchid == null ? null : mchid.trim();
}
public String getRwzt() {
return rwzt;
}
public void setRwzt(String rwzt) {
this.rwzt = rwzt == null ? null : rwzt.trim();
}
public String getPictureUrls() {
return pictureUrls;
}
public void setPictureUrls(String pictureUrls) {
this.pictureUrls = pictureUrls == null ? null : pictureUrls.trim();
}
}
\ No newline at end of file
package com.zksy.szpt.domain.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
public class XxZhjfbgDTO {
/**
* 兑换ID
*/
@NotBlank(message = "兑换ID不能为空")
private String dhid;
/**
* 账户ID
*/
private String zhid;
/**
* 情报ID
*/
@NotBlank(message = "情报ID不能为空")
private String qbid;
/**
* 情报奖励ID
*/
private String qbjlid;
/**
* 变更类型;cslb=1019
*/
private String bglx;
/**
* 变更积分
*/
private Long bgjf;
/**
* 变更前积分
*/
private Long bgqjf;
/**
* 变更后积分
*/
private Long bghjf;
/**
* 变更时间
*/
@NotNull(message = "情报ID不能为空")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date bgsj;
/**
* 备注
*/
private String bz;
/**
* 更新时间
*/
private Date gxsj;
public String getDhid() {
return dhid;
}
public void setDhid(String dhid) {
this.dhid = dhid == null ? null : dhid.trim();
}
public String getZhid() {
return zhid;
}
public void setZhid(String zhid) {
this.zhid = zhid == null ? null : zhid.trim();
}
public String getQbid() {
return qbid;
}
public void setQbid(String qbid) {
this.qbid = qbid == null ? null : qbid.trim();
}
public String getQbjlid() {
return qbjlid;
}
public void setQbjlid(String qbjlid) {
this.qbjlid = qbjlid == null ? null : qbjlid.trim();
}
public String getBglx() {
return bglx;
}
public void setBglx(String bglx) {
this.bglx = bglx == null ? null : bglx.trim();
}
public Long getBgjf() {
return bgjf;
}
public void setBgjf(Long bgjf) {
this.bgjf = bgjf;
}
public Long getBgqjf() {
return bgqjf;
}
public void setBgqjf(Long bgqjf) {
this.bgqjf = bgqjf;
}
public Long getBghjf() {
return bghjf;
}
public void setBghjf(Long bghjf) {
this.bghjf = bghjf;
}
public Date getBgsj() {
return bgsj;
}
public void setBgsj(Date bgsj) {
this.bgsj = bgsj;
}
public String getBz() {
return bz;
}
public void setBz(String bz) {
this.bz = bz == null ? null : bz.trim();
}
public Date getGxsj() {
return gxsj;
}
public void setGxsj(Date gxsj) {
this.gxsj = gxsj;
}
}
\ No newline at end of file
package com.zksy.szpt.domain.dto;
import javax.validation.constraints.NotBlank;
import java.util.Date;
public class XxZhxxDTO {
/**
* 账户ID
*/
@NotBlank(message = "账户ID不能为空")
private String zhid;
/**
* 账户类型;cslb=1004
*/
private String zhlx;
/**
* 社会信息员ID
*/
private String xxyid;
/**
* 姓名
*/
private String xm;
/**
* 身份证号
*/
private String sfzh;
/**
* 联系电话
*/
private String lxdh;
/**
* OPENID
*/
private String openid;
/**
* 昵称
*/
private String nc;
/**
* UNIONID
*/
private String unionid;
/**
* 发送情报数
*/
private String fsqbs;
/**
* 小程序ID
*/
private String accountid;
/**
* 前端权限,默认空,支持多个,逗号分隔
*/
private String roles;
/**
* 邀请码
*/
private String yqm;
/**
* 邀请码ID
*/
private String yqmid;
/**
* 处理标志;cslb=1017
*/
@NotBlank(message = "处理标志不能为空")
private String clbz;
/**
* 处理时间
*/
private Date clsj;
/**
* 处理结果
*/
private String cljg;
/**
* 返回时间
*/
private Date fhsj;
/**
* OCUUID
*/
private String ocuuid;
/**
* 帐号参数JSON
*/
private String zhcs;
/**
* 运营商户ID
*/
private String mchid;
/**
* 状态;cslb=1008
*/
@NotBlank(message = "状态不能为空")
private String zt;
/**
* 头像
*/
private String avatar;
public String getZhid() {
return zhid;
}
public void setZhid(String zhid) {
this.zhid = zhid == null ? null : zhid.trim();
}
public String getZhlx() {
return zhlx;
}
public void setZhlx(String zhlx) {
this.zhlx = zhlx == null ? null : zhlx.trim();
}
public String getXxyid() {
return xxyid;
}
public void setXxyid(String xxyid) {
this.xxyid = xxyid == null ? null : xxyid.trim();
}
public String getXm() {
return xm;
}
public void setXm(String xm) {
this.xm = xm == null ? null : xm.trim();
}
public String getSfzh() {
return sfzh;
}
public void setSfzh(String sfzh) {
this.sfzh = sfzh == null ? null : sfzh.trim();
}
public String getLxdh() {
return lxdh;
}
public void setLxdh(String lxdh) {
this.lxdh = lxdh == null ? null : lxdh.trim();
}
public String getOpenid() {
return openid;
}
public void setOpenid(String openid) {
this.openid = openid == null ? null : openid.trim();
}
public String getNc() {
return nc;
}
public void setNc(String nc) {
this.nc = nc == null ? null : nc.trim();
}
public String getUnionid() {
return unionid;
}
public void setUnionid(String unionid) {
this.unionid = unionid == null ? null : unionid.trim();
}
public String getFsqbs() {
return fsqbs;
}
public void setFsqbs(String fsqbs) {
this.fsqbs = fsqbs == null ? null : fsqbs.trim();
}
public String getAccountid() {
return accountid;
}
public void setAccountid(String accountid) {
this.accountid = accountid == null ? null : accountid.trim();
}
public String getRoles() {
return roles;
}
public void setRoles(String roles) {
this.roles = roles == null ? null : roles.trim();
}
public String getYqm() {
return yqm;
}
public void setYqm(String yqm) {
this.yqm = yqm == null ? null : yqm.trim();
}
public String getYqmid() {
return yqmid;
}
public void setYqmid(String yqmid) {
this.yqmid = yqmid == null ? null : yqmid.trim();
}
public String getClbz() {
return clbz;
}
public void setClbz(String clbz) {
this.clbz = clbz == null ? null : clbz.trim();
}
public Date getClsj() {
return clsj;
}
public void setClsj(Date clsj) {
this.clsj = clsj;
}
public String getCljg() {
return cljg;
}
public void setCljg(String cljg) {
this.cljg = cljg == null ? null : cljg.trim();
}
public Date getFhsj() {
return fhsj;
}
public void setFhsj(Date fhsj) {
this.fhsj = fhsj;
}
public String getOcuuid() {
return ocuuid;
}
public void setOcuuid(String ocuuid) {
this.ocuuid = ocuuid == null ? null : ocuuid.trim();
}
public String getZhcs() {
return zhcs;
}
public void setZhcs(String zhcs) {
this.zhcs = zhcs == null ? null : zhcs.trim();
}
public String getMchid() {
return mchid;
}
public void setMchid(String mchid) {
this.mchid = mchid == null ? null : mchid.trim();
}
public String getZt() {
return zt;
}
public void setZt(String zt) {
this.zt = zt == null ? null : zt.trim();
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar == null ? null : avatar.trim();
}
}
\ No newline at end of file
package com.zksy.szpt.domain.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
@TableName("xx_imgfile")
public class XxImgfile {
/**
* 图片IID
......@@ -11,6 +16,7 @@ public class XxImgfile {
/**
* 图片ID
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
......
package com.zksy.szpt.domain.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
@TableName
public class XxImgindex {
/**
* 图片IID
......@@ -11,6 +16,7 @@ public class XxImgindex {
/**
* 图片ID
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
......
package com.zksy.szpt.domain.po;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.util.Date;
public class XxYjdwdm {
/**
* 义警队伍代码IID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long iid;
/**
......@@ -46,16 +52,19 @@ public class XxYjdwdm {
/**
* 创建人id
*/
@TableField(fill = FieldFill.INSERT)
private String cjrid;
/**
* 创建人姓名
*/
@TableField(fill = FieldFill.INSERT)
private String cjrxm;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date cjsj;
/**
......
package com.zksy.szpt.domain.po;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.util.Date;
public class XxYjrw {
/**
* IID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long iid;
/**
......@@ -111,16 +117,19 @@ public class XxYjrw {
/**
* 创建人id
*/
@TableField(fill = FieldFill.INSERT)
private String cjrid;
/**
* 创建人姓名
*/
@TableField(fill = FieldFill.INSERT)
private String cjrxm;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date cjsj;
/**
......
package com.zksy.szpt.domain.po;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.util.Date;
public class XxZhjfbg {
/**
* IID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long iid;
/**
......@@ -61,11 +67,13 @@ public class XxZhjfbg {
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date cjsj;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT)
private Date gxsj;
public Long getIid() {
......
package com.zksy.szpt.domain.po;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.util.Date;
public class XxZhxx {
/**
* IID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long iid;
/**
......@@ -121,11 +127,13 @@ public class XxZhxx {
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date cjsj;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT)
private Date gxsj;
/**
......
package com.zksy.szpt.exception;
/**
* 其他主动抛出的信息
*/
public class NotificationException extends Exception {
//异常信息
private final String message;
//构造函数
public NotificationException(String message) {
super(message);
this.message = message;
this.initCause(new Throwable(message));//设置cause,方便获取异常信息
}
}
......@@ -22,12 +22,14 @@ public class SzptMetaObjectHandler implements MetaObjectHandler {
List<StrictFill> fields = Arrays.asList(
StrictFill.of("createTime", Date.class, new Date()),
StrictFill.of("cjsj", Date.class, new Date()),
StrictFill.of("gxsj", Date.class, new Date()),
StrictFill.of("updateTime", Date.class, new Date()),
StrictFill.of("sjgsdwdm", String.class, "1"),
StrictFill.of("sjgsdwmc", String.class, "1"),
StrictFill.of("createGajgjgdm", String.class, "1"),
StrictFill.of("createGajgmc", String.class, "1"),
StrictFill.of("createId", String.class, "1"),
StrictFill.of("cjrid", String.class, "1"),
StrictFill.of("createBy", String.class, "1"),
StrictFill.of("createTerminal", String.class, "1"),
StrictFill.of("createIp", String.class, "1"),
......
package com.zksy.szpt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zksy.szpt.domain.po.XxImgfile;
import com.zksy.szpt.domain.po.XxImgfileExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface XxImgfileMapper {
public interface XxImgfileMapper extends BaseMapper<XxImgfile> {
long countByExample(XxImgfileExample example);
int deleteByExample(XxImgfileExample example);
int deleteByPrimaryKey(Long iid);
int insert(XxImgfile record);
// int insert(XxImgfile record);
int insertSelective(XxImgfile record);
......
package com.zksy.szpt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zksy.szpt.domain.po.XxImgindex;
import com.zksy.szpt.domain.po.XxImgindexExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface XxImgindexMapper {
public interface XxImgindexMapper extends BaseMapper<XxImgindex> {
long countByExample(XxImgindexExample example);
int deleteByExample(XxImgindexExample example);
......
package com.zksy.szpt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zksy.szpt.domain.po.XxYjdwdm;
import com.zksy.szpt.domain.po.XxYjdwdmExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface XxYjdwdmMapper {
public interface XxYjdwdmMapper extends BaseMapper<XxYjdwdm> {
long countByExample(XxYjdwdmExample example);
int deleteByExample(XxYjdwdmExample example);
int deleteByPrimaryKey(Long iid);
int insert(XxYjdwdm record);
// int insert(XxYjdwdm record);
int insertSelective(XxYjdwdm record);
......
package com.zksy.szpt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zksy.szpt.domain.po.XxYjrw;
import com.zksy.szpt.domain.po.XxYjrwExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface XxYjrwMapper {
public interface XxYjrwMapper extends BaseMapper<XxYjrw> {
long countByExample(XxYjrwExample example);
int deleteByExample(XxYjrwExample example);
int deleteByPrimaryKey(Long iid);
int insert(XxYjrw record);
// int insert(XxYjrw record);
int insertSelective(XxYjrw record);
......
package com.zksy.szpt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zksy.szpt.domain.po.XxZhjfbg;
import com.zksy.szpt.domain.po.XxZhjfbgExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface XxZhjfbgMapper {
public interface XxZhjfbgMapper extends BaseMapper<XxZhjfbg> {
long countByExample(XxZhjfbgExample example);
int deleteByExample(XxZhjfbgExample example);
int deleteByPrimaryKey(Long iid);
int insert(XxZhjfbg record);
// int insert(XxZhjfbg record);
int insertSelective(XxZhjfbg record);
......
package com.zksy.szpt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zksy.szpt.domain.po.XxZhxx;
import com.zksy.szpt.domain.po.XxZhxxExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface XxZhxxMapper {
public interface XxZhxxMapper extends BaseMapper<XxZhxx> {
long countByExample(XxZhxxExample example);
int deleteByExample(XxZhxxExample example);
int deleteByPrimaryKey(Long iid);
int insert(XxZhxx record);
// int insert(XxZhxx record);
int insertSelective(XxZhxx record);
......
package com.zksy.szpt.service;
import com.zksy.szpt.domain.UploadImageDTO;
import com.zksy.szpt.domain.po.XxImgfile;
import com.zksy.szpt.domain.po.XxImgindex;
import com.zksy.szpt.domain.po.XxImgindexExample;
import com.zksy.szpt.exception.NotificationException;
import com.zksy.szpt.mapper.XxImgfileMapper;
import com.zksy.szpt.mapper.XxImgindexMapper;
import io.netty.channel.ChannelOption;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.handler.timeout.WriteTimeoutHandler;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClientResponseException;
import reactor.core.publisher.Mono;
import reactor.netty.http.client.HttpClient;
import reactor.netty.tcp.TcpClient;
import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@Service
public class ImageUploadService {
//日志
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ImageUploadService.class);
private final XxImgfileMapper xxImgfileMapper;
private final XxImgindexMapper xxImgindexMapper;
public ImageUploadService(XxImgfileMapper xxImgfileMapper, XxImgindexMapper xxImgindexMapper) {
this.xxImgfileMapper = xxImgfileMapper;
this.xxImgindexMapper = xxImgindexMapper;
}
public Integer upload(UploadImageDTO uploadImageDTO) throws NotificationException {
// 创建一个 TcpClient 并设置超时时间
final TcpClient tcpClient = TcpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) // 连接超时时间
.doOnConnected(connection -> connection.addHandlerLast(new ReadTimeoutHandler(5)) // 读取超时时间
.addHandlerLast(new WriteTimeoutHandler(5))); // 写入超时时间
// 创建 WebClient 实例用于下载文件
WebClient webClient = WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(HttpClient.from(tcpClient)))
.baseUrl(uploadImageDTO.getImagePath())
.build();
// 下载文件到内存中的字节数组
Mono<byte[]> fileContentMono = webClient.get()
.uri("")
.retrieve()
.bodyToMono(byte[].class)
.onErrorResume(WebClientResponseException.class, ex -> {
log.warn("WebClientResponseException: {}", ex.getResponseBodyAsString());
return Mono.error(new NotificationException(uploadImageDTO.getImagePath() + ",Failed to download file: " + ex.getStatusText()));
})
.onErrorResume(URISyntaxException.class, ex -> {
log.warn("URISyntaxException: {}", ex.getMessage());
return Mono.error(new NotificationException(uploadImageDTO.getImagePath() + ",Invalid URL format"));
})
.onErrorResume(Exception.class, ex -> {
log.warn("General Exception: {}", ex.getMessage());
return Mono.error(new NotificationException(ex.getMessage()));
});
XxImgfile xxImgfile = new XxImgfile();
xxImgfile.setOurl(uploadImageDTO.getImagePath());
xxImgfile.setNwzh("0");
// 等待文件内容下载完成
try {
byte[] fileContent = fileContentMono.block();
if (fileContent == null) {
throw new NotificationException("Failed to download file");
}
xxImgfile.setData(fileContent);
// 将文件内容转换为十六进制字符串
String fileContentHexString = toMd5(fileContent);
if (checkByMd5(fileContentHexString)) {
throw new NotificationException("File already exists");
}
//入库
XxImgindex xxImgindex = new XxImgindex();
xxImgindex.setOurl(uploadImageDTO.getImagePath());
xxImgindex.setMd5(fileContentHexString);
xxImgindexMapper.insert(xxImgindex);
return xxImgfileMapper.insert(xxImgfile);
} catch (Exception e) {
throw new NotificationException(e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
}
// 将文件内容插入数据库
// fileContentMono.flatMap(fileContent -> {
// try {
// xxImgfile.setData(fileContent);
// return Mono.just(xxImgfileMapper.insert(xxImgfile));
// } catch (Exception e) {
// e.printStackTrace();
// return Mono.error(e);
// }
// }).subscribe(rowsAffected -> {
// System.out.println("Rows affected: " + rowsAffected);
// }, error -> {
// error.printStackTrace();
// });
}
private boolean checkByMd5(String imageUrl) {
XxImgindexExample example = new XxImgindexExample();
example.createCriteria().andMd5EqualTo(imageUrl);
return xxImgindexMapper.countByExample(example) >= 1;
}
private static final char[] hexCode = "0123456789ABCDEF".toCharArray();
private static String toMd5(byte[] data) throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(data, 0, data.length);
byte[] hashBytes = digest.digest();
StringBuilder r = new StringBuilder(hashBytes.length * 2);
for (byte b : hashBytes) {
r.append(hexCode[(b >> 4) & 0xF]);
r.append(hexCode[(b & 0xF)]);
}
return r.toString();
}
}
......@@ -21,50 +21,57 @@ public class IndexService {
@Resource
private SzptClockInMapper szptClockInMapper;
public Integer addSzptClockIn(SzptClockInDTO szptClockInDTO){
SzptClockIn szptClockIn = BeanMapperUtil.map(szptClockInDTO,SzptClockIn.class);
public Integer addSzptClockIn(SzptClockInDTO szptClockInDTO) {
SzptClockIn szptClockIn = BeanMapperUtil.map(szptClockInDTO, SzptClockIn.class);
return szptClockInMapper.insert(szptClockIn);
}
@Resource
private SzptClockInRulesMapper szptClockInRulesMapper;
public Integer addSzptClockInRules(SzptClockInRulesDTO szptClockInRulesDTO){
SzptClockInRules szptClockInRules = BeanMapperUtil.map(szptClockInRulesDTO,SzptClockInRules.class);
public Integer addSzptClockInRules(SzptClockInRulesDTO szptClockInRulesDTO) {
SzptClockInRules szptClockInRules = BeanMapperUtil.map(szptClockInRulesDTO, SzptClockInRules.class);
return szptClockInRulesMapper.insert(szptClockInRules);
}
@Resource
private SzptFwxxMapper szptFwxxMapper;
public Integer addSzptFwxx(SzptFwxxDTO szptFwxxDTO){
SzptFwxx szptFwxx = BeanMapperUtil.map(szptFwxxDTO,SzptFwxx.class);
public Integer addSzptFwxx(SzptFwxxDTO szptFwxxDTO) {
SzptFwxx szptFwxx = BeanMapperUtil.map(szptFwxxDTO, SzptFwxx.class);
return szptFwxxMapper.insert(szptFwxx);
}
@Resource
private SzptGdCsyjhldxMapper szptGdCsyjhldxMapper;
public Integer addSzptGdCsyjhldx(SzptGdCsyjhldxDTO szptGdCsyjhldxDTO){
SzptGdCsyjhldx szptGdCsyjhldx = BeanMapperUtil.map(szptGdCsyjhldxDTO,SzptGdCsyjhldx.class);
public Integer addSzptGdCsyjhldx(SzptGdCsyjhldxDTO szptGdCsyjhldxDTO) {
SzptGdCsyjhldx szptGdCsyjhldx = BeanMapperUtil.map(szptGdCsyjhldxDTO, SzptGdCsyjhldx.class);
return szptGdCsyjhldxMapper.insert(szptGdCsyjhldx);
}
@Resource
private SzptGdRyxxMapper szptGdRyxxMapper;
public Integer addSzptGdRyxx(SzptGdRyxxDTO szptGdRyxxDTO){
SzptGdRyxx szptGdRyxx = BeanMapperUtil.map(szptGdRyxxDTO,SzptGdRyxx.class);
public Integer addSzptGdRyxx(SzptGdRyxxDTO szptGdRyxxDTO) {
SzptGdRyxx szptGdRyxx = BeanMapperUtil.map(szptGdRyxxDTO, SzptGdRyxx.class);
return szptGdRyxxMapper.insert(szptGdRyxx);
}
@Resource
private SzptGdSbxxMapper szptGdSbxxMapper;
public Integer addSzptGdSbxx(SzptGdSbxxDTO szptGdSbxxDTO){
SzptGdSbxx szptGdSbxx = BeanMapperUtil.map(szptGdSbxxDTO,SzptGdSbxx.class);
public Integer addSzptGdSbxx(SzptGdSbxxDTO szptGdSbxxDTO) {
SzptGdSbxx szptGdSbxx = BeanMapperUtil.map(szptGdSbxxDTO, SzptGdSbxx.class);
return szptGdSbxxMapper.insert(szptGdSbxx);
}
@Resource
private SzptGdXxMapper szptGdXxMapper;
public Integer addSzptGdXx(SzptGdXxDTO szptGdXxDTO){
SzptGdXx szptGdXx = BeanMapperUtil.map(szptGdXxDTO,SzptGdXx.class);
public Integer addSzptGdXx(SzptGdXxDTO szptGdXxDTO) {
SzptGdXx szptGdXx = BeanMapperUtil.map(szptGdXxDTO, SzptGdXx.class);
return szptGdXxMapper.insert(szptGdXx);
}
......@@ -81,4 +88,38 @@ public class IndexService {
SzptQyxx szptQyxx = BeanMapperUtil.map(szptQyxxDTO,SzptQyxx.class);
return szptQyxxMapper.insert(szptQyxx);
}
@Resource
private XxZhxxMapper xxZhxxMapper;
public Integer addXxZhxx(XxZhxxDTO xxZhxxDTO) {
XxZhxx xxZhxx = BeanMapperUtil.map(xxZhxxDTO, XxZhxx.class);
return xxZhxxMapper.insert(xxZhxx);
}
@Resource
private XxZhjfbgMapper xxZhjfbgMapper;
public Integer addXxZhjfbg(XxZhjfbgDTO dto) {
XxZhjfbg xxZhjfbg = BeanMapperUtil.map(dto, XxZhjfbg.class);
return xxZhjfbgMapper.insert(xxZhjfbg);
}
@Resource
private XxYjrwMapper xxYjrwMapper;
public Integer addXxYjrw(XxYjrwDTO dto) {
XxYjrw xxYjrw = BeanMapperUtil.map(dto, XxYjrw.class);
return xxYjrwMapper.insert(xxYjrw);
}
@Resource
private XxYjdwdmMapper xxYjdwdmMapper;
public Integer addXxYjdwdm(XxYjdwdmDTO dto) {
XxYjdwdm xxYjdwdm = BeanMapperUtil.map(dto, XxYjdwdm.class);
return xxYjdwdmMapper.insert(xxYjdwdm);
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment