diff --git a/src/main/java/com/fxzy/warn/common/constants/UserConstants.java b/src/main/java/com/fxzy/warn/common/constants/UserConstants.java index 8c14d6b..5ccfb49 100644 --- a/src/main/java/com/fxzy/warn/common/constants/UserConstants.java +++ b/src/main/java/com/fxzy/warn/common/constants/UserConstants.java @@ -46,8 +46,21 @@ public class UserConstants { */ public final static Integer RANDOM_CAPTCHA = 1; + /** + * 测试账号 + */ + public final static Integer IS_TRIAL = 0; + /** + * 试用账号状态 + */ + // 未启用 + public static final int ACCOUNT_STATUS_UNENABLED = 0; + // 试用中 + public static final int ACCOUNT_STATUS_TRIAL = 1; + // 冻结 + public static final int ACCOUNT_STATUS_FROZEN = 2; } diff --git a/src/main/java/com/fxzy/warn/controller/ContractController.java b/src/main/java/com/fxzy/warn/controller/ContractController.java new file mode 100644 index 0000000..e6786d1 --- /dev/null +++ b/src/main/java/com/fxzy/warn/controller/ContractController.java @@ -0,0 +1,97 @@ +package com.fxzy.warn.controller; + +import com.alibaba.fastjson.JSONObject; +import com.fxzy.warn.common.constants.ResponseMsgConstants; +import com.fxzy.warn.common.request.RequestParameter; +import com.fxzy.warn.common.response.ApiResponse; +import com.fxzy.warn.model.Contract; +import com.fxzy.warn.service.ContractService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * @author zhangjing + * @date 2024/05/21 11:22 + * @description + */ +@Api(tags = "合同管理") +@RestController +@RequestMapping("contract/") +@Slf4j +public class ContractController { + @Resource + private ContractService contractService ; + + @RequestMapping(value = "save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ApiOperation(value = "新增") + public ApiResponse save(@ApiParam("{\n" + + "\"userId\":\"关联用户\",\n" + + "\"signingDate\":\"合同签订日期\",\n" + + "\"contractAmount\":\"合同金额\",\n" + + "}") @RequestBody Contract entity, @RequestHeader String ticket) { + ApiResponse response = new ApiResponse(); + try { + return contractService.saveModel(entity,ticket); + } catch (Exception e) { + response.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return response; + } + + /** + * 修改 + * + * @param + * @return + */ + @ResponseBody + @ApiOperation(value = "修改") + @RequestMapping(value = "edit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public ApiResponse edit(@ApiParam() @RequestBody Contract entity,@RequestHeader String ticket) { + log.info("修改==== 参数{" + entity != null ? entity.toString() : "null" + "}"); + ApiResponse response = new ApiResponse(); + try { + return contractService.updateModel(entity,ticket); + } catch (Exception e) { + response.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return response; + } + /** + * 通过ids删除 + * + * @param + * @return + */ + @ResponseBody + @ApiOperation(value = "删除") + @RequestMapping(value = "remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public ApiResponse remove(@ApiParam("{\"ids\":[\"1\",\"2\"]}") @RequestBody JSONObject jsonObject) { + ApiResponse apiResponse = new ApiResponse(); + try { + return contractService.deleteModel(jsonObject.getJSONArray("ids").toJavaList(String.class)); + } catch (Exception e) { + apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return apiResponse; + } + @RequestMapping(value = "queryPage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "分页查询") + public ApiResponse queryPage(@ApiParam() @RequestBody RequestParameter parameter) { + ApiResponse apiResponse = new ApiResponse(); + try { + apiResponse.setData(contractService.queryPage(parameter)); + apiResponse.setMessage(ResponseMsgConstants.OPERATE_SUCCESS); + } catch (Exception e) { + apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return apiResponse; + } + +} diff --git a/src/main/java/com/fxzy/warn/controller/PermissionController.java b/src/main/java/com/fxzy/warn/controller/PermissionController.java index 98a18c1..4e90ce3 100644 --- a/src/main/java/com/fxzy/warn/controller/PermissionController.java +++ b/src/main/java/com/fxzy/warn/controller/PermissionController.java @@ -22,7 +22,7 @@ import javax.annotation.Resource; */ @Api(tags = "数据权限管理") @RestController -@RequestMapping("Permission/") +@RequestMapping("permission/") @Slf4j public class PermissionController { @Resource diff --git a/src/main/java/com/fxzy/warn/controller/ReportController.java b/src/main/java/com/fxzy/warn/controller/ReportController.java new file mode 100644 index 0000000..fe6def1 --- /dev/null +++ b/src/main/java/com/fxzy/warn/controller/ReportController.java @@ -0,0 +1,99 @@ +package com.fxzy.warn.controller; + +import com.alibaba.fastjson.JSONObject; +import com.fxzy.warn.common.constants.ResponseMsgConstants; +import com.fxzy.warn.common.request.RequestParameter; +import com.fxzy.warn.common.response.ApiResponse; +import com.fxzy.warn.model.Report; +import com.fxzy.warn.service.ReportService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * @author zhangjing + * @date 2024/05/21 11:22 + * @description + */ +@Api(tags = "司法报告") +@RestController +@RequestMapping("report/") +@Slf4j +public class ReportController { + @Resource + private ReportService reportService ; + + @RequestMapping(value = "save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ApiOperation(value = "新增") + public ApiResponse save(@ApiParam("{\n" + + "\"companyName\":\"企业名称\",\n" + + "\"creditCode\":\"统一社会信用代码\",\n" + + "\"legalPerson\":\"企业法人\",\n" + + "\"address\":\"地址\"\n" + + "\"authorizationId\":\"授权书id\"\n" + + "}") @RequestBody Report entity, @RequestHeader String ticket) { + ApiResponse response = new ApiResponse(); + try { + return reportService.saveModel(entity,ticket); + } catch (Exception e) { + response.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return response; + } + + /** + * 修改 + * + * @param + * @return + */ + @ResponseBody + @ApiOperation(value = "修改") + @RequestMapping(value = "edit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public ApiResponse edit(@ApiParam() @RequestBody Report entity,@RequestHeader String ticket) { + log.info("修改==== 参数{" + entity != null ? entity.toString() : "null" + "}"); + ApiResponse response = new ApiResponse(); + try { + return reportService.updateModel(entity,ticket); + } catch (Exception e) { + response.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return response; + } + /** + * 通过ids删除 + * + * @param + * @return + */ + @ResponseBody + @ApiOperation(value = "删除") + @RequestMapping(value = "remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public ApiResponse remove(@ApiParam("{\"ids\":[\"1\",\"2\"]}") @RequestBody JSONObject jsonObject) { + ApiResponse apiResponse = new ApiResponse(); + try { + return reportService.deleteModel(jsonObject.getJSONArray("ids").toJavaList(String.class)); + } catch (Exception e) { + apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return apiResponse; + } + @RequestMapping(value = "queryPage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "分页查询") + public ApiResponse queryPage(@ApiParam() @RequestBody RequestParameter parameter) { + ApiResponse apiResponse = new ApiResponse(); + try { + apiResponse.setData(reportService.queryPage(parameter)); + apiResponse.setMessage(ResponseMsgConstants.OPERATE_SUCCESS); + } catch (Exception e) { + apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return apiResponse; + } + +} diff --git a/src/main/java/com/fxzy/warn/controller/TrialController.java b/src/main/java/com/fxzy/warn/controller/TrialController.java new file mode 100644 index 0000000..786f732 --- /dev/null +++ b/src/main/java/com/fxzy/warn/controller/TrialController.java @@ -0,0 +1,94 @@ +package com.fxzy.warn.controller; + +import com.alibaba.fastjson.JSONObject; +import com.fxzy.warn.common.constants.ResponseMsgConstants; +import com.fxzy.warn.common.request.RequestParameter; +import com.fxzy.warn.common.response.ApiResponse; +import com.fxzy.warn.model.User; +import com.fxzy.warn.service.UserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Objects; + +/** + * @author zhangjing + * @date 2024/05/21 11:22 + * @description + */ +@Api(tags = "试用授权") +@RestController +@RequestMapping("trial/") +@Slf4j +public class TrialController { + @Resource + private UserService userService ; + + + + + @RequestMapping(value = "createTrial", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ApiOperation(value = "创建试用账号") + public ApiResponse createTrial(@ApiParam("{\n" + + "\"companyName\":\"企业名称\",\n" + + "\"creditCode\":\"统一社会信用代码\",\n" + + "\"phoneNumber\":\"手机号\",\n" + + "\"email\":\"邮箱\"\n" + + "\"province\":\"所在省\"\n" + + "\"city\":\"所在市\"\n" + + "\"district\":\"所在区\"\n" + + "\"detailedAddress\":\"详细地址\"\n" + + "\"businessPerson\":\"商务负责人\"\n" + + "\"remarks\":\"备注\"\n" + + "}") @RequestBody User entity, String ticket) { + ApiResponse response = new ApiResponse(); + try { + return userService.createTrial(entity,ticket); + } catch (Exception e) { + response.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return response; + } + @RequestMapping(value = "queryPage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "分页查询") + public ApiResponse queryPage(@ApiParam() @RequestBody RequestParameter parameter) { + log.info("分页查询 ==== 参数{" + parameter.toString() + "}"); + ApiResponse apiResponse = new ApiResponse(); + if (!Objects.isNull(parameter) && !Objects.isNull(parameter.getParameter())) { + try { + apiResponse.setData(userService.queryPageTrial(parameter)); + apiResponse.setMessage(ResponseMsgConstants.OPERATE_SUCCESS); + } catch (Exception e) { + log.error("查询错误,errMsg==={}", e.getMessage()); + e.printStackTrace(); + apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + } else { + apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return apiResponse; + } + @RequestMapping(value = "setTrial", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ApiOperation(value = "配置试用账号") + public ApiResponse setTrial(@ApiParam("{\n" + + "\"id\":\"id\",\n" + + "\"trialStatus\":\"1试用中2冻结\",\n" + + "\"trialDay\":\"试用天数\",\n" + + "}") @RequestBody User entity, String ticket) { + ApiResponse response = new ApiResponse(); + try { + return userService.setTrial(entity,ticket); + } catch (Exception e) { + response.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return response; + } +} diff --git a/src/main/java/com/fxzy/warn/mapper/ContractMapper.java b/src/main/java/com/fxzy/warn/mapper/ContractMapper.java new file mode 100644 index 0000000..d21ad36 --- /dev/null +++ b/src/main/java/com/fxzy/warn/mapper/ContractMapper.java @@ -0,0 +1,14 @@ +package com.fxzy.warn.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.fxzy.warn.model.Contract; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author zhangjing + * @date 2024/12/04 14:48 + * @description + */ +@Mapper +public interface ContractMapper extends BaseMapper { +} diff --git a/src/main/java/com/fxzy/warn/mapper/ReportMapper.java b/src/main/java/com/fxzy/warn/mapper/ReportMapper.java new file mode 100644 index 0000000..f6b7e2a --- /dev/null +++ b/src/main/java/com/fxzy/warn/mapper/ReportMapper.java @@ -0,0 +1,14 @@ +package com.fxzy.warn.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.fxzy.warn.model.Report; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author zhangjing + * @date 2024/12/04 14:48 + * @description + */ +@Mapper +public interface ReportMapper extends BaseMapper { +} diff --git a/src/main/java/com/fxzy/warn/model/Contract.java b/src/main/java/com/fxzy/warn/model/Contract.java new file mode 100644 index 0000000..600e4f2 --- /dev/null +++ b/src/main/java/com/fxzy/warn/model/Contract.java @@ -0,0 +1,55 @@ +package com.fxzy.warn.model; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 合同 + * + * @author zhangjing + * @date 2024/12/05 14:07 + * @description + */ +@Data +@TableName("t_contract") +public class Contract extends BaseField { + /** + * id + */ + @ApiModelProperty("id") + @TableId(type = IdType.AUTO) + private Integer id; + /** + * 关联用户 + */ + @ApiModelProperty("关联用户") + private Integer userId; + /** + * 合同签订日期 + */ + @ApiModelProperty("合同签订日期") + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") + private Date signingDate; + /** + * 合同金额 + */ + @ApiModelProperty("合同金额") + private BigDecimal contractAmount; + /** + * 合同url + */ + @ApiModelProperty("合同url") + private String fileUrl; + /** + * 发票url + */ + @ApiModelProperty("发票url") + private String invoiceUrl; +} diff --git a/src/main/java/com/fxzy/warn/model/Report.java b/src/main/java/com/fxzy/warn/model/Report.java new file mode 100644 index 0000000..ed7924e --- /dev/null +++ b/src/main/java/com/fxzy/warn/model/Report.java @@ -0,0 +1,61 @@ +package com.fxzy.warn.model; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 司法报告 + * @author zhangjing + * @date 2024/12/05 14:07 + * @description + */ +@Data +@TableName("t_report") +public class Report extends BaseField{ + /** + * id + */ + @ApiModelProperty("id") + @TableId(type = IdType.AUTO) + private Integer id; + /** + * 报告名称 + */ + @ApiModelProperty("报告名称") + private String name; + /** + * 报告类型 + */ + @ApiModelProperty("报告类型") + private String type; + /** + * 报告时间 + */ + @ApiModelProperty("报告时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private Date reportTime; + /** + * 企业名称 + */ + @ApiModelProperty("企业名称") + private String companyName; + + + /** + * 关联业务id + */ + @ApiModelProperty("关联业务id") + private Integer businessId; + + /** + * 是否已读 + */ + @ApiModelProperty("是否已读") + private Integer isRead; +} diff --git a/src/main/java/com/fxzy/warn/model/User.java b/src/main/java/com/fxzy/warn/model/User.java index adaed34..97a940f 100644 --- a/src/main/java/com/fxzy/warn/model/User.java +++ b/src/main/java/com/fxzy/warn/model/User.java @@ -14,7 +14,7 @@ import java.util.Date; */ @Data @TableName("t_user") -public class User extends BaseField{ +public class User extends BaseField { /** * id */ @@ -97,9 +97,28 @@ public class User extends BaseField{ * 授权状态 0待申请1待审批2授权有效3授权过期 */ @ApiModelProperty("授权状态 0待申请1待审批2授权有效3授权过期") - private Integer authorizationStatus; + private Integer authorizationStatus; @ApiModelProperty("授权时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date auditDate; + + /** + * 试用账号状态 0未启用1试用中2冻结 + */ + @ApiModelProperty("试用账号状态 0未启用1试用中2冻结") + private Integer trialStatus; + /** + * 试用天数 + */ + @ApiModelProperty("试用天数") + private Integer trialDay; + + @ApiModelProperty("启用时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date enableDate; + + @ApiModelProperty("结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date endDate; } diff --git a/src/main/java/com/fxzy/warn/service/ContractService.java b/src/main/java/com/fxzy/warn/service/ContractService.java new file mode 100644 index 0000000..e40fa7e --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/ContractService.java @@ -0,0 +1,48 @@ +package com.fxzy.warn.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.fxzy.warn.common.request.RequestParameter; +import com.fxzy.warn.common.response.ApiResponse; +import com.fxzy.warn.model.Contract; + +import java.util.List; + +/** + * @author zhangjing + * @date 2023/10/16 18:17 + * @description + */ +public interface ContractService extends IService { + + /** + * 保存 + * @param entity + * @return + */ + ApiResponse saveModel(Contract entity,String ticket); + + /** + * 修改 + * @param entity + * @return + */ + ApiResponse updateModel(Contract entity,String ticket); + + /** + * 删除 + * @param ids + * @return + */ + ApiResponse deleteModel(List ids); + + /** + * 分页查询 + * @param parameter + * @return + */ + Page queryPage(RequestParameter parameter); + + + +} diff --git a/src/main/java/com/fxzy/warn/service/ReportService.java b/src/main/java/com/fxzy/warn/service/ReportService.java new file mode 100644 index 0000000..945c324 --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/ReportService.java @@ -0,0 +1,48 @@ +package com.fxzy.warn.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.fxzy.warn.common.request.RequestParameter; +import com.fxzy.warn.common.response.ApiResponse; +import com.fxzy.warn.model.Report; + +import java.util.List; + +/** + * @author zhangjing + * @date 2023/10/16 18:17 + * @description + */ +public interface ReportService extends IService { + + /** + * 保存 + * @param entity + * @return + */ + ApiResponse saveModel(Report entity,String ticket); + + /** + * 修改 + * @param entity + * @return + */ + ApiResponse updateModel(Report entity,String ticket); + + /** + * 删除 + * @param ids + * @return + */ + ApiResponse deleteModel(List ids); + + /** + * 分页查询 + * @param parameter + * @return + */ + Page queryPage(RequestParameter parameter); + + + +} diff --git a/src/main/java/com/fxzy/warn/service/UserService.java b/src/main/java/com/fxzy/warn/service/UserService.java index 6f03722..954d541 100644 --- a/src/main/java/com/fxzy/warn/service/UserService.java +++ b/src/main/java/com/fxzy/warn/service/UserService.java @@ -81,4 +81,31 @@ public interface UserService extends IService { * @return */ User getUserByTicket(String ticket); + + /** + * + * 创建试用用户 + * @param entity + * @return com.fxzy.warn.common.response.ApiResponse + * @author zhangjing + * @create 2024/12/4 + **/ + ApiResponse createTrial(User entity,String ticket); + + /** + * 试用分页 + * @param parameter + * @return + */ + Page queryPageTrial(RequestParameter parameter); + + /** + * + * 配置试用账号 + * @param entity + * @return com.fxzy.warn.common.response.ApiResponse + * @author zhangjing + * @create 2024/12/4 + **/ + ApiResponse setTrial(User entity,String ticket); } diff --git a/src/main/java/com/fxzy/warn/service/impl/ContractServiceImpl.java b/src/main/java/com/fxzy/warn/service/impl/ContractServiceImpl.java new file mode 100644 index 0000000..41f1b65 --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/impl/ContractServiceImpl.java @@ -0,0 +1,58 @@ +package com.fxzy.warn.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fxzy.warn.common.constants.EntityConstants; +import com.fxzy.warn.common.request.RequestParameter; +import com.fxzy.warn.common.response.ApiResponse; +import com.fxzy.warn.mapper.ContractMapper; +import com.fxzy.warn.model.Contract; +import com.fxzy.warn.service.ContractService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author zhangjing + * @date 2023/10/16 18:17 + * @description + */ +@Service +public class ContractServiceImpl extends ServiceImpl implements + ContractService { + + + @Override + public ApiResponse saveModel(Contract entity, String ticket) { + save(entity); + return new ApiResponse(); + } + + @Override + public ApiResponse updateModel(Contract entity,String ticket) { + this.updateById(entity); + return new ApiResponse(); + } + + @Override + public ApiResponse deleteModel(List ids) { + Contract entity = new Contract(); + entity.setIsDel(EntityConstants.DEL); + QueryWrapper wrapper = new QueryWrapper(); + wrapper.in("id", ids); + update(entity, wrapper); + return new ApiResponse(); + } + + @Override + public Page queryPage(RequestParameter parameter) { + Contract entity = parameter.getParameter().toJavaObject(Contract.class); + Page page = new Page(parameter.getCurrent(), parameter.getSize()); + page.setSearchCount(true); + page.setOptimizeCountSql(true); + QueryWrapper eWrapper = new QueryWrapper(entity); + Page result = this.page(page, eWrapper); + return result; + } +} diff --git a/src/main/java/com/fxzy/warn/service/impl/ReportServiceImpl.java b/src/main/java/com/fxzy/warn/service/impl/ReportServiceImpl.java new file mode 100644 index 0000000..c874ad4 --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/impl/ReportServiceImpl.java @@ -0,0 +1,58 @@ +package com.fxzy.warn.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fxzy.warn.common.constants.EntityConstants; +import com.fxzy.warn.common.request.RequestParameter; +import com.fxzy.warn.common.response.ApiResponse; +import com.fxzy.warn.mapper.ReportMapper; +import com.fxzy.warn.model.Report; +import com.fxzy.warn.service.ReportService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author zhangjing + * @date 2023/10/16 18:17 + * @description + */ +@Service +public class ReportServiceImpl extends ServiceImpl implements + ReportService { + + + @Override + public ApiResponse saveModel(Report entity, String ticket) { + save(entity); + return new ApiResponse(); + } + + @Override + public ApiResponse updateModel(Report entity,String ticket) { + this.updateById(entity); + return new ApiResponse(); + } + + @Override + public ApiResponse deleteModel(List ids) { + Report entity = new Report(); + entity.setIsDel(EntityConstants.DEL); + QueryWrapper wrapper = new QueryWrapper(); + wrapper.in("id", ids); + update(entity, wrapper); + return new ApiResponse(); + } + + @Override + public Page queryPage(RequestParameter parameter) { + Report entity = parameter.getParameter().toJavaObject(Report.class); + Page page = new Page(parameter.getCurrent(), parameter.getSize()); + page.setSearchCount(true); + page.setOptimizeCountSql(true); + QueryWrapper eWrapper = new QueryWrapper(entity); + Page result = this.page(page, eWrapper); + return result; + } +} diff --git a/src/main/java/com/fxzy/warn/service/impl/UserServiceImpl.java b/src/main/java/com/fxzy/warn/service/impl/UserServiceImpl.java index 04a77e5..9692873 100644 --- a/src/main/java/com/fxzy/warn/service/impl/UserServiceImpl.java +++ b/src/main/java/com/fxzy/warn/service/impl/UserServiceImpl.java @@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.fxzy.warn.common.constants.AuthorizationConstants; -import com.fxzy.warn.common.constants.RedisKeyConstants; -import com.fxzy.warn.common.constants.ResponseMsgConstants; -import com.fxzy.warn.common.constants.UserConstants; +import com.fxzy.warn.common.constants.*; import com.fxzy.warn.common.request.RequestParameter; import com.fxzy.warn.common.response.ApiResponse; import com.fxzy.warn.common.util.JWTUtil; @@ -26,6 +23,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import java.time.LocalDate; +import java.time.ZoneId; import java.util.Date; import java.util.Random; import java.util.UUID; @@ -94,7 +93,7 @@ public class UserServiceImpl extends ServiceImpl implements String password = jsonObject.getString("password"); //验证码 String code = jsonObject.getString("code"); - User user=null; + User user = null; if (loginType.equals(UserConstants.SMS_CAPTCHA_LOGIN)) { //验证码登录 String number = redisUtil.getString("code:" + phoneNumber); @@ -131,9 +130,10 @@ public class UserServiceImpl extends ServiceImpl implements String token = this.createToken(user); String ticket = createTicket(token); - redisUtil.setString(RedisKeyConstants.LOGIN_ST + ticket,token , 60 * 60 * 12); + redisUtil.setString(RedisKeyConstants.LOGIN_ST + ticket, token, 60 * 60 * 12); return response; } + private String createTicket(String token) { String ticket = RedisKeyConstants.LOGIN_ST_HEADER + UUID.randomUUID().toString().replace("-", ""); try { @@ -144,6 +144,7 @@ public class UserServiceImpl extends ServiceImpl implements } return ticket; } + private String createToken(User user) { String publicKey = jwtUtil.getPublicKey(); String token = null; @@ -154,6 +155,7 @@ public class UserServiceImpl extends ServiceImpl implements } return token; } + @Override public ApiResponse createUser(User entity, String ticket) { ApiResponse response = new ApiResponse(); @@ -209,6 +211,53 @@ public class UserServiceImpl extends ServiceImpl implements return user; } + @Override + public ApiResponse createTrial(User entity, String ticket) { + ApiResponse response = new ApiResponse(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("phone_number", entity.getPhoneNumber()); + //用户是否存在 + User user = getOne(queryWrapper); + if (user != null) { + response.recordMsgError(ResponseMsgConstants.USER_PHONE_EXIST); + return response; + } + entity.setIsOfficialAccount(UserConstants.IS_TRIAL); + entity.setTrialStatus(UserConstants.ACCOUNT_STATUS_UNENABLED); + save(entity); + return response; + } + + @Override + public Page queryPageTrial(RequestParameter parameter) { + User entity = parameter.getParameter().toJavaObject(User.class); + Page page = new Page(parameter.getCurrent(), parameter.getSize()); + page.setSearchCount(true); + page.setOptimizeCountSql(true); + QueryWrapper eWrapper = new QueryWrapper(entity); + eWrapper.eq("is_official_account", UserConstants.IS_TRIAL) + .eq("is_del", EntityConstants.NORMAL) + .orderByDesc("creat_time"); + Page result = this.page(page, eWrapper); + setInfo(result); + return result; + } + + @Override + public ApiResponse setTrial(User entity, String ticket) { + ApiResponse response = new ApiResponse(); + if (entity.getTrialStatus() == UserConstants.ACCOUNT_STATUS_TRIAL) { + Date now = new Date(); + LocalDate localNow = now.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + LocalDate end = localNow.plusDays(entity.getTrialDay()); + Date endDate = Date.from(end.atStartOfDay(ZoneId.systemDefault()).toInstant()); + entity.setEnableDate(now); + entity.setEndDate(endDate); + } + updateById(entity); + return response; + } + private void setInfo(Page result) { for (User user : result.getRecords()) { // 这里可以添加需要返回的字段的填充