diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/filter/AuthCheckFilter.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/filter/AuthCheckFilter.java index a246927..799a038 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/filter/AuthCheckFilter.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/filter/AuthCheckFilter.java @@ -94,7 +94,7 @@ public class AuthCheckFilter extends OncePerRequestFilter { JwtAuthenticationToken token = new JwtAuthenticationToken(userName, authorities, userInfoVO); SecurityContextHolder.getContext().setAuthentication(token); } catch (ExpiredJwtException e) { - ResultVO resultVO = ResultUtils.error(CodeMsg.USER_TOKEN_EXPIRED);// 用户凭证过期 + ResultVO resultVO = ResultUtils.error(CodeMsg.USER_CREDENTIALS_EXPIRED);// 用户凭证过期 ResponseUtils.output(response, resultVO); } finally { filterChain.doFilter(request, response); diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/filter/LoginFilter.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/filter/LoginFilter.java index 3230d0c..1d38bd0 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/filter/LoginFilter.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/filter/LoginFilter.java @@ -118,7 +118,7 @@ public class LoginFilter extends AbstractAuthenticationProcessingFilter {//OnceP stringRedisTemplate.opsForValue().set("jwt_token:"+authResult.getName(),jwt,10, TimeUnit.DAYS); // stringRedisTemplate.delete("user_attempts:"+request.getRemoteAddr()); // 记录登录日志 - loginLogService.addLoginLog(userInfoVO.getId(), true); + loginLogService.addLoginLog(userInfoVO.getUserID(), true); // 返回结果 ResultVO result = ResultUtils.success("登录成功", jwt); @@ -180,8 +180,6 @@ public class LoginFilter extends AbstractAuthenticationProcessingFilter {//OnceP resultVO = ResultUtils.error(CodeMsg.USER_IS_LOCKED); } else if (failed instanceof CredentialsExpiredException) { resultVO = ResultUtils.error(CodeMsg.USER_CREDENTIALS_EXPIRED); - } else if (failed instanceof AccountExpiredException) { - resultVO = ResultUtils.error(CodeMsg.USER_ACCOUNT_EXPIRED); } else if (failed instanceof DisabledException) { resultVO = ResultUtils.error(CodeMsg.USER_IS_DISABLED); } else if (failed instanceof AuthenticationException) { diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/token/JwtAuthenticationToken.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/token/JwtAuthenticationToken.java index 3cf5331..a427870 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/token/JwtAuthenticationToken.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/config/security/token/JwtAuthenticationToken.java @@ -1,5 +1,6 @@ package edu.ncst.ioreport.config.security.token; +import edu.ncst.ioreport.model.User; import edu.ncst.ioreport.vo.result.UserInfoVO; import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.core.GrantedAuthority; diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/IORecordsController.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/IORecordsController.java index ca794d7..5bf02ac 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/IORecordsController.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/IORecordsController.java @@ -1,20 +1,14 @@ package edu.ncst.ioreport.controller; -import edu.ncst.ioreport.exception.CodeMsg; import edu.ncst.ioreport.model.IORecords; import edu.ncst.ioreport.service.IIORecordService; -import edu.ncst.ioreport.utils.ResponseUtils; import edu.ncst.ioreport.utils.ResultUtils; -import edu.ncst.ioreport.vo.ListResultVO; import edu.ncst.ioreport.vo.ResultVO; import edu.ncst.ioreport.vo.param.QRecord; -import edu.ncst.ioreport.vo.param.QUser; -import edu.ncst.ioreport.vo.result.UserInfoVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -39,8 +33,15 @@ public class IORecordsController { @ApiOperation("根据记录ID获取记录详细信息") @GetMapping("/detail") - public ResultVO getIORecordByID(@RequestParam(name = "ID", required = true) Integer ID){ + public ResultVO getIORecordByID(@RequestParam(name = "ID") Integer ID){ IORecords record = iioRecordService.getIORecordsDetail(ID); return ResultUtils.success(record); } + + @ApiOperation("根据记录ID获取记录详细信息") + @PostMapping("/add") + public ResultVO addIORecord(@RequestBody IORecords param){ + int id = iioRecordService.addIORecord(param); + return ResultUtils.success(Integer.valueOf(id)); + } } diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/TestController.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/TestController.java index 0fea2ac..aef158b 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/TestController.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/TestController.java @@ -3,12 +3,12 @@ package edu.ncst.ioreport.controller; import edu.ncst.ioreport.exception.CodeMsg; import edu.ncst.ioreport.model.Resource; +import edu.ncst.ioreport.model.User; import edu.ncst.ioreport.service.IUserService; import edu.ncst.ioreport.utils.ResponseUtils; import edu.ncst.ioreport.utils.ResultUtils; import edu.ncst.ioreport.vo.ResultVO; import edu.ncst.ioreport.vo.param.QUser; -import edu.ncst.ioreport.vo.result.UserInfoVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -34,7 +34,7 @@ public class TestController { } QUser queryVO = new QUser(); queryVO.setPhone(param); - UserInfoVO user = userService.getUserInfo(queryVO); + User user = userService.getUserInfo(queryVO); return ResponseUtils.success(user); } @@ -47,78 +47,78 @@ public class TestController { } QUser queryVO = new QUser(); queryVO.setPhone(param); - UserInfoVO user = userService.getUserInfo(queryVO); + User user = userService.getUserInfo(queryVO); return ResponseUtils.success(user); } @ApiOperation("get方法传参,类接收,无注解") @GetMapping("/user/detail1") @ResponseBody - public UserInfoVO getUserInfo1(QUser param){ + public User getUserInfo1(QUser param){ if(param.getPhone()==null){ String s = param.getPhone().toString(); } - UserInfoVO user = userService.getUserInfo(param); - user.setFullName("getUserInfo1"); + User user = userService.getUserInfo(param); + user.setName("getUserInfo1"); return user; } @ApiOperation("post方法传参,类接收,无注解") @PostMapping("/user/detail11") @ResponseBody - public UserInfoVO getUserInfo11(QUser param){ + public User getUserInfo11(QUser param){ if(param.getPhone()==null){ String s = param.getPhone().toString(); } - UserInfoVO user = userService.getUserInfo(param); - user.setFullName("getUserInfo1"); + User user = userService.getUserInfo(param); + user.setName("getUserInfo1"); return user; } @ApiOperation("get方法传参,类接收,requestparam注解") @GetMapping("/user/detail2") @ResponseBody - public UserInfoVO getUserInfo2(@RequestParam QUser param){ + public User getUserInfo2(@RequestParam QUser param){ if(param.getPhone()==null){ String s = param.getPhone().toString(); } - UserInfoVO user = userService.getUserInfo(param); - user.setFullName("getUserInfo2"); + User user = userService.getUserInfo(param); + user.setName("getUserInfo2"); return user; } @ApiOperation("post方法传参,类接收,requestparam注解") @PostMapping("/user/detail22") @ResponseBody - public UserInfoVO getUserInfo22(@RequestParam QUser param){ + public User getUserInfo22(@RequestParam QUser param){ if(param.getPhone()==null){ String s = param.getPhone().toString(); } - UserInfoVO user = userService.getUserInfo(param); - user.setFullName("getUserInfo22"); + User user = userService.getUserInfo(param); + user.setName("getUserInfo22"); return user; } @ApiOperation("get方法传参,类接收,requestbody注解") @GetMapping("/user/detail3") @ResponseBody - public UserInfoVO getUserInfo3(@RequestBody QUser param){ + public User getUserInfo3(@RequestBody QUser param){ if(param.getPhone()==null){ String s = param.getPhone().toString(); } - UserInfoVO user = userService.getUserInfo(param); - user.setFullName("getUserInfo3"); + User user = userService.getUserInfo(param); + user.setName("getUserInfo3"); return user; } @ApiOperation("post方法传参,类接收,requestbody注解") @PostMapping("/user/detail4") @ResponseBody - public UserInfoVO getUserInfo4(@RequestBody QUser param){ + public User getUserInfo4(@RequestBody QUser param){ if(param.getPhone()==null){ String s = param.getPhone().toString(); } - UserInfoVO user = userService.getUserInfo(param); - user.setFullName("getUserInfo3"); + User user = userService.getUserInfo(param); + user.setName("getUserInfo3"); return user; } diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/UserController.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/UserController.java index 080c2cb..8b07db4 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/UserController.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/controller/UserController.java @@ -4,18 +4,16 @@ package edu.ncst.ioreport.controller; import edu.ncst.ioreport.model.User; import edu.ncst.ioreport.service.IRoleService; import edu.ncst.ioreport.service.IUserService; -import edu.ncst.ioreport.utils.ResponseUtils; import edu.ncst.ioreport.utils.ResultUtils; import edu.ncst.ioreport.vo.ListResultVO; import edu.ncst.ioreport.vo.ResultVO; -import edu.ncst.ioreport.vo.param.CurrentUserVO; import edu.ncst.ioreport.vo.param.QUser; -import edu.ncst.ioreport.vo.result.UserInfoVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; ; @@ -46,8 +44,8 @@ public class UserController { @ApiOperation("获取当前用户信息") @GetMapping("/current") - public ResultVO getCurrentUser() { - UserInfoVO currentUserDTO = userService.getCurrentUser(); + public ResultVO getCurrentUser() { + User currentUserDTO = userService.getCurrentUser(); // roleService.selectRoleAll(); return ResultUtils.success(currentUserDTO); } diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/exception/CodeMsg.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/exception/CodeMsg.java index ff5f3eb..6567338 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/exception/CodeMsg.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/exception/CodeMsg.java @@ -13,24 +13,17 @@ public class CodeMsg { public static final CodeMsg BUSINESS_ERROR = new CodeMsg(503, "业务错误:%s");; public final static CodeMsg USER_NEED_LOGIN = new CodeMsg(10000, "尚未登录,请登录。"); - public final static CodeMsg USERNAME_REQUIRE_NOT_NULL = new CodeMsg(10001, "用户名不能为空"); - public final static CodeMsg PASSWORD_REQUIRE_NOT_NULL = new CodeMsg(10002, "用户密码不能为空"); - public final static CodeMsg USER_NOT_FOUND = new CodeMsg(10003, "该用户不存在。"); - public final static CodeMsg USERNAME_OR_PASSWORD_ERROR = new CodeMsg(10004, "用户名或密码错误"); - public final static CodeMsg USER_IS_LOCKED = new CodeMsg(10005, "当前IP已被锁定,请1小时后再试。"); - public final static CodeMsg USER_CREDENTIALS_EXPIRED = new CodeMsg(10006, "用户登录凭证过期,请重新登录。"); - public final static CodeMsg USER_ACCOUNT_EXPIRED = new CodeMsg(10007, "用户账号过期,请联系管理员。"); - public final static CodeMsg USER_IS_DISABLED = new CodeMsg(10008, "该用户已被禁用,请联系管理员。"); - public final static CodeMsg USER_BAD_CREDENTIALS = new CodeMsg(10009, "无效的登录凭证,请尝试重新登录"); - public final static CodeMsg USER_TOKEN_EXPIRED = new CodeMsg(10010, "用户凭证已过期,请联系管理员。"); - public final static CodeMsg NOT_GET_CURRENT_USER_INFO = new CodeMsg(10011, "无法获取当前用户信息。"); - public final static CodeMsg CAN_NOT_DATA_ACCESS = new CodeMsg(10012, "当前用户没有访问相关数据的权限。"); - public final static CodeMsg LOGIN_FAIL = new CodeMsg(10015, "登录失败,未知原因。"); - public final static CodeMsg CAPTCHA_IS_NOT_RIGHT = new CodeMsg(10018, "验证码错误。"); - public final static CodeMsg CAPTCHA_IS_EMPTY = new CodeMsg(10019, "验证码不能为空。"); - public final static CodeMsg CAPTCHA_IS_EXPIRED = new CodeMsg(10020, "验证码已过期。"); - public static final CodeMsg TEMP_TOKEN_NOT_FOUND = new CodeMsg(10021,"无法获取临时授权"); - public static final CodeMsg TEMP_TOKEN_EXPIRED = new CodeMsg(10022,"临时授权已过期"); + public final static CodeMsg USER_NOT_FOUND = new CodeMsg(10001, "该用户不存在。"); + public final static CodeMsg USER_CREDENTIALS_EXPIRED = new CodeMsg(10002, "用户登录凭证过期,请重新登录。"); + public final static CodeMsg USER_IS_DISABLED = new CodeMsg(10003, "该用户已被禁用,请联系管理员。"); + public final static CodeMsg USER_BAD_CREDENTIALS = new CodeMsg(10004, "无效的登录凭证,请尝试重新登录"); + public final static CodeMsg NOT_GET_CURRENT_USER_INFO = new CodeMsg(10005, "无法获取当前用户信息。"); + public final static CodeMsg CAN_NOT_DATA_ACCESS = new CodeMsg(10006, "当前用户没有访问相关数据的权限。"); + public static final CodeMsg TEMP_TOKEN_NOT_FOUND = new CodeMsg(10007,"无法获取临时授权"); + public static final CodeMsg TEMP_TOKEN_EXPIRED = new CodeMsg(10008,"临时授权已过期"); + public static final CodeMsg USER_IS_LOCKED = new CodeMsg(10009,"用户被锁定"); + public static final CodeMsg USER_ACCOUNT_EXPIRED = new CodeMsg(10008,"临时授权已过期"); + public final static CodeMsg LOGIN_FAIL = new CodeMsg(10009, "登录失败。"); /** * 基本操作 101XX diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/mapper/IORecordsMapper.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/mapper/IORecordsMapper.java index d6b1c60..65561ae 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/mapper/IORecordsMapper.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/mapper/IORecordsMapper.java @@ -7,4 +7,5 @@ import org.springframework.stereotype.Repository; @Repository public interface IORecordsMapper extends BaseMapper { + int insertAndGetId(IORecords record); } diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/BaseEntity.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/BaseEntity.java deleted file mode 100644 index 2af983c..0000000 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/BaseEntity.java +++ /dev/null @@ -1,40 +0,0 @@ -package edu.ncst.ioreport.model; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableLogic; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -@Data -public abstract class BaseEntity implements Serializable { - - @ApiModelProperty(value = "创建时间") - @TableField(value = "create_time", fill = FieldFill.INSERT) - private Date createTime; - - @ApiModelProperty(value = "创建人") - @TableField(value = "create_user_id", fill = FieldFill.INSERT) - private Integer createUserId; - - @ApiModelProperty(value = "最后更新时间") - @TableField(value = "last_modify_time", fill = FieldFill.INSERT_UPDATE) - private Date lastModifyTime; - - @ApiModelProperty(value = "最后更新者") - @TableField(value = "last_modify_user_id", fill = FieldFill.INSERT_UPDATE) - private Integer lastModifyUserId; - - @ApiModelProperty(value = "删除时间") - @TableField("delete_time") - @TableLogic - private Date deleteTime; - - @ApiModelProperty(value = "删除者") - @TableField("delete_user_id") - private Integer deleteUserId; - -} diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/Department.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/Department.java new file mode 100644 index 0000000..597fc96 --- /dev/null +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/Department.java @@ -0,0 +1,18 @@ +package edu.ncst.ioreport.model; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@ApiModel(value="Department", description="二级学院") +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("Department") +public class Department { + @ApiModelProperty(value = "部门编码") + private String departmentID; + @ApiModelProperty(value = "部门名称") + private String department; +} diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/IORecords.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/IORecords.java index faeca70..0167a20 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/IORecords.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/IORecords.java @@ -1,13 +1,13 @@ package edu.ncst.ioreport.model; import com.baomidou.mybatisplus.annotation.*; -import edu.ncst.ioreport.model.BaseEntity; import edu.ncst.ioreport.vo.QRToken; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotNull; import java.util.Date; /** @@ -25,21 +25,27 @@ public class IORecords { private Integer id; @ApiModelProperty(value = "教师工号") + @NotNull(message = "教师信息不能为空") private String teacherID; @ApiModelProperty(value = "报备单类型:1-出;0-入") + @NotNull(message = "报备类型不能为空") private String ioType; @ApiModelProperty(value = "校外居住地") + @NotNull(message = "校外居住地不能为空") private String outerResidence; @ApiModelProperty(value = "校内居住地") + @NotNull(message = "校内居住地不能为空") private String innerResidence; @ApiModelProperty(value = "申请事由") + @NotNull(message = "申请事由不能为空") private String reason; @ApiModelProperty(value = "出入校时间") + @NotNull(message = "出入校时间不能为空") private Date commitTime; @ApiModelProperty(value = "院级审核人") @@ -63,6 +69,22 @@ public class IORecords { @ApiModelProperty(value = "单据状态:0-保存;1-提交待审核;2-院级审核通过;3-校级审核通过;4-核验通过;9-院级审核不通过;8-校级审核不通过;7-核验不通过") private String status; + @ApiModelProperty(value = "教师") + @TableField(exist = false) + private User teacher; + + @ApiModelProperty(value = "院级审核人") + @TableField(exist = false) + private User deptAuditor; + + @ApiModelProperty(value = "校级审核人") + @TableField(exist = false) + private User schoolAuditor; + + @ApiModelProperty(value = "核验人") + @TableField(exist = false) + private User validator; + @ApiModelProperty(value = "二维码token") @TableField(exist = false) private QRToken qrToken; diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/User.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/User.java index 445df03..2258f5b 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/User.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/model/User.java @@ -21,26 +21,35 @@ import java.util.stream.Collectors; @Data @EqualsAndHashCode(callSuper = false) @TableName("user") -public class User extends BaseEntity implements Serializable, UserDetails { +public class User implements Serializable, UserDetails { @ApiModelProperty(value = "用户id") - private Integer id; + private Integer userID; + @ApiModelProperty(value = "用户名(微信名)") + private String userName; @ApiModelProperty(value = "教师工号") private String teacherID; - @ApiModelProperty(value = "用户真实名") - private String fullName; + @ApiModelProperty(value = "用户姓名") + private String name; @ApiModelProperty(value = "地址信息") private String address; + @ApiModelProperty(value = "密码") + private String password; @ApiModelProperty(value = "手机号") - private String phone; + private String mobile; @ApiModelProperty(value = "所属单位") - private Integer unitId; + private Integer departmentID; @ApiModelProperty(value = "微信小程序id") - private Integer wechatId; + private Integer wechatID; @ApiModelProperty(value = "角色列表") @TableField(exist = false) private List roles; - @ApiModelProperty(value = "是否启用 1:启用 0:禁用") - private Boolean enable; + @ApiModelProperty(value = "所属学院") + @TableField(exist = false) + private Department dept; + @ApiModelProperty(value = "是否在校 1:在校 0:未在") + private Boolean isInSchool; + @ApiModelProperty(value = "是否在校 1:在校 0:未在") + private Boolean enabled; @@ -88,6 +97,6 @@ public class User extends BaseEntity implements Serializable, UserDetails { @Override public boolean isEnabled() { - return this.enable; + return true; }//是否启用 } diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/IIORecordService.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/IIORecordService.java index 89591e3..e208379 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/IIORecordService.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/IIORecordService.java @@ -10,4 +10,6 @@ public interface IIORecordService { List getIORecordsList(QRecord query); IORecords getIORecordsDetail(Integer ID); + + int addIORecord(IORecords record); } diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/IUserService.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/IUserService.java index ce66dd9..eda3b97 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/IUserService.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/IUserService.java @@ -2,18 +2,16 @@ package edu.ncst.ioreport.service; import edu.ncst.ioreport.model.User; import edu.ncst.ioreport.vo.ListResultVO; -import edu.ncst.ioreport.vo.param.CurrentUserVO; import edu.ncst.ioreport.vo.param.QUser; -import edu.ncst.ioreport.vo.result.UserInfoVO; import org.springframework.security.core.userdetails.UserDetails; public interface IUserService { - UserInfoVO getUserInfo(QUser query); + User getUserInfo(QUser query); ListResultVO getUserList(QUser query); - UserInfoVO getCurrentUser(); + User getCurrentUser(); UserDetails loadUserByWechatId(String wechatId); } diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/IORecordServiceImpl.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/IORecordServiceImpl.java index 2956c19..e1e71fc 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/IORecordServiceImpl.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/IORecordServiceImpl.java @@ -7,9 +7,12 @@ import edu.ncst.ioreport.exception.BusinessException; import edu.ncst.ioreport.exception.CodeMsg; import edu.ncst.ioreport.mapper.IORecordsMapper; import edu.ncst.ioreport.model.IORecords; +import edu.ncst.ioreport.model.User; import edu.ncst.ioreport.service.IIORecordService; +import edu.ncst.ioreport.utils.SessionUtils; import edu.ncst.ioreport.vo.QRToken; import edu.ncst.ioreport.vo.param.QRecord; +import edu.ncst.ioreport.vo.result.UserInfoVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -64,4 +67,23 @@ public class IORecordServiceImpl implements IIORecordService { } return records; } + + @Override + public int addIORecord(IORecords record) { + UserInfoVO user = SessionUtils.getCurrentUser(); + List roles = user.getRoles(); + if(roles==null||(roles.size()==1&&user.getRoles().get(0).compareTo("DOOR_GUARD")==0)){ + throw new BusinessException(CodeMsg.CAN_NOT_DATA_ACCESS); + } + if(user.getTeacherID().compareTo(record.getTeacherID())!=0){ + throw new BusinessException(CodeMsg.BUSINESS_ERROR.fillArgs("当前用户为"+user.getTeacherID()+",与单据中提交人不一致")); + } + record.setStatus("SUBMIT"); + int id = recordsMapper.insertAndGetId(record); + if(id==1){ + return record.getId(); + }else{ + throw new BusinessException(CodeMsg.ADD_ERROR); + } + } } diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/ResourceServiceImpl.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/ResourceServiceImpl.java index 566f8ce..9537da2 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/ResourceServiceImpl.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/ResourceServiceImpl.java @@ -57,6 +57,7 @@ public class ResourceServiceImpl implements IResourceService { urls.add("/api/user/current"); urls.add("/api/records/detail"); urls.add("/api/records/list"); + urls.add("/api/records/add"); return urls; } } diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/UserServiceImpl.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/UserServiceImpl.java index c0aef69..f244b84 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/UserServiceImpl.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/service/impl/UserServiceImpl.java @@ -1,15 +1,17 @@ package edu.ncst.ioreport.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import edu.ncst.ioreport.exception.BusinessException; +import edu.ncst.ioreport.exception.CodeMsg; import edu.ncst.ioreport.mapper.UserMapper; -import edu.ncst.ioreport.model.Role; +import edu.ncst.ioreport.model.Department; import edu.ncst.ioreport.model.User; import edu.ncst.ioreport.service.IUserService; import edu.ncst.ioreport.utils.SessionUtils; import edu.ncst.ioreport.vo.ListResultVO; -import edu.ncst.ioreport.vo.param.CurrentUserVO; import edu.ncst.ioreport.vo.param.QUser; import edu.ncst.ioreport.vo.result.UserInfoVO; +import org.springframework.beans.BeanUtils; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; @@ -21,12 +23,12 @@ import java.util.List; @Service public class UserServiceImpl extends ServiceImpl implements IUserService, UserDetailsService { @Override - public UserInfoVO getUserInfo(QUser query) { - UserInfoVO vo = new UserInfoVO(); + public User getUserInfo(QUser query) { + User vo = new User(); vo.setTeacherID("1001"); vo.setAddress("address 1111111"); - vo.setFullName("zhangsan"); - vo.setFullName("张三"); + vo.setUserName("zhangsan"); + vo.setName("张三"); return vo; } @@ -35,8 +37,8 @@ public class UserServiceImpl extends ServiceImpl implements IU User user = new User(); user.setAddress("address 1111111"); user.setTeacherID("1001"); - user.setFullName("张三"); - user.setEnable(true); + user.setName("张三"); + user.setIsInSchool(true); ListResultVO listResultVO = new ListResultVO(); List list = new ArrayList<>(); list.add(user); @@ -45,9 +47,19 @@ public class UserServiceImpl extends ServiceImpl implements IU } @Override - public UserInfoVO getCurrentUser() { - UserInfoVO user = SessionUtils.getCurrentUser(); + public User getCurrentUser() { + UserInfoVO userinfo = SessionUtils.getCurrentUser(); + if(userinfo==null){ + throw new BusinessException(CodeMsg.USER_NEED_LOGIN); + } + User user = new User();//根据userinfo.techerid从数据库获取用户的部门等详细信息 + BeanUtils.copyProperties(userinfo,user); + Department dept =new Department(); + dept.setDepartment("人工智能"); + dept.setDepartmentID("01"); + user.setDept(dept); + user.setMobile("123344444"); return user; } @@ -56,11 +68,16 @@ public class UserServiceImpl extends ServiceImpl implements IU User user = new User(); user.setAddress("address 1111111"); user.setTeacherID("1001"); - user.setFullName("张三"); + user.setUserID(Integer.valueOf(1)); + user.setName("张三"); List roles = new ArrayList<>(); roles.add("Admin");//Teacher;Doorman user.setRoles(roles); - user.setEnable(true); + user.setIsInSchool(true); + Department dept =new Department(); + dept.setDepartment("人工智能"); + dept.setDepartmentID("01"); + user.setDept(dept); return user; } @@ -69,10 +86,10 @@ public class UserServiceImpl extends ServiceImpl implements IU User user = new User(); user.setAddress("address 1111111"); user.setTeacherID("1001"); - user.setFullName("张三"); + user.setName("张三"); List roles = new ArrayList<>(); roles.add("Admin"); - user.setEnable(true); + user.setIsInSchool(true); return user; } } diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/utils/SessionUtils.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/utils/SessionUtils.java index 3177e4f..77112af 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/utils/SessionUtils.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/utils/SessionUtils.java @@ -2,6 +2,7 @@ package edu.ncst.ioreport.utils; import edu.ncst.ioreport.exception.BusinessException; import edu.ncst.ioreport.exception.CodeMsg; +import edu.ncst.ioreport.model.User; import edu.ncst.ioreport.service.IUserService; import edu.ncst.ioreport.vo.result.UserInfoVO; import org.springframework.beans.factory.annotation.Autowired; diff --git a/IOReportSysBE/src/main/java/edu/ncst/ioreport/vo/result/UserInfoVO.java b/IOReportSysBE/src/main/java/edu/ncst/ioreport/vo/result/UserInfoVO.java index d673091..765ea84 100644 --- a/IOReportSysBE/src/main/java/edu/ncst/ioreport/vo/result/UserInfoVO.java +++ b/IOReportSysBE/src/main/java/edu/ncst/ioreport/vo/result/UserInfoVO.java @@ -1,5 +1,6 @@ package edu.ncst.ioreport.vo.result; +import com.baomidou.mybatisplus.annotation.TableField; import edu.ncst.ioreport.model.Role; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -11,19 +12,18 @@ import java.util.List; @ApiModel(description = "用户信息") public class UserInfoVO { @ApiModelProperty(value = "用户id") - private Integer id; + private Integer userID; @ApiModelProperty(value = "教师工号") private String teacherID; - @ApiModelProperty(value = "真实名") - private String fullName; + @ApiModelProperty(value = "用户姓名") + private String name; @ApiModelProperty(value = "地址信息") private String address; @ApiModelProperty(value = "手机号") - private String phone; + private String mobile; @ApiModelProperty(value = "所属单位") - private Integer unitId; - @ApiModelProperty(value = "微信id") - private String wechatID; + private Integer departmentID; @ApiModelProperty(value = "角色列表") + @TableField(exist = false) private List roles; } diff --git a/IOReportSysBE/src/main/resources/application.yml b/IOReportSysBE/src/main/resources/application.yml index 6269328..3b78fab 100644 --- a/IOReportSysBE/src/main/resources/application.yml +++ b/IOReportSysBE/src/main/resources/application.yml @@ -25,9 +25,9 @@ server: servlet: encoding: charset: utf-8 -#mybatis: -# mapper-locations: classpath:mapping/*.xml -# type-aliases-package: edu.ncst.ioreport.model +mybatis: + mapper-locations: classpath:mapping/*.xml + type-aliases-package: edu.ncst.ioreport.model swagger: enable: true @@ -50,12 +50,12 @@ logging: # ## MyBatis Plus mybatis-plus: -# global-config: -# db-config: -# logic-delete-field: deleteAt -# logic-delete-value: now() -# logic-not-delete-value: null -# banner: false # 关闭控制台的 LOGO -# mapper-locations: classpath*:/mapping/**/*.xml - configuration: - map-underscore-to-camel-case: false \ No newline at end of file + global-config: + db-config: + logic-delete-field: deleted + logic-delete-value: 1 + logic-not-delete-value: 0 + banner: false # 关闭控制台的 LOGO + mapper-locations: classpath*:/mapping/**/*.xml + configuration: + map-underscore-to-camel-case: false \ No newline at end of file diff --git a/IOReportSysBE/src/main/resources/mapping/IORecordMapper.xml b/IOReportSysBE/src/main/resources/mapping/IORecordMapper.xml new file mode 100644 index 0000000..035ffb5 --- /dev/null +++ b/IOReportSysBE/src/main/resources/mapping/IORecordMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + insert into iorecords (teacherid,iotype,outerResidence,innerResidence,reason,committime,status) + values(#{teacherID},#{ioType},#{outerResidence},#{innerResidence},#{reason},#{commitTime},#{status}) + + \ No newline at end of file diff --git a/IOReportSysMP/miniprogram/api/userApi/userApi.js b/IOReportSysMP/miniprogram/api/userApi/userApi.js index 9531dc6..c090359 100644 --- a/IOReportSysMP/miniprogram/api/userApi/userApi.js +++ b/IOReportSysMP/miniprogram/api/userApi/userApi.js @@ -80,7 +80,6 @@ var login = function () { return __awaiter(void 0, void 0, void 0, function () { return [4 /*yield*/, request_1.request({ url: BASE_URL + 'api/userInfo', data: token, method: "POST" })]; case 2: data = (_a.sent()).data; - wx.setStorageSync(constant_1.default.ROLE_LIST, data.roles); wx.setStorageSync(constant_1.default.USER_INFO, data); return [2 /*return*/, data]; } diff --git a/IOReportSysMP/miniprogram/api/userApi/userApi.ts b/IOReportSysMP/miniprogram/api/userApi/userApi.ts index 11586ba..978087e 100644 --- a/IOReportSysMP/miniprogram/api/userApi/userApi.ts +++ b/IOReportSysMP/miniprogram/api/userApi/userApi.ts @@ -32,7 +32,6 @@ const login = async () => { }) wx.setStorageSync(constant.SYS_TOKEN, token); const { data } = await request>({ url: BASE_URL + 'api/userInfo', data: token, method: "POST" }) - wx.setStorageSync(constant.ROLE_LIST, data.roles) wx.setStorageSync(constant.USER_INFO, data) return data; } diff --git a/IOReportSysMP/miniprogram/app.json b/IOReportSysMP/miniprogram/app.json index 2eb1ac7..11f28f8 100644 --- a/IOReportSysMP/miniprogram/app.json +++ b/IOReportSysMP/miniprogram/app.json @@ -3,8 +3,8 @@ "pages/index/index", "pages/report/list/myReport", "pages/report/detail/reportDetail", - "pages/logs/logs", "pages/report/enter/enterReport", + "pages/logs/logs", "pages/report/out/outerReport", "pages/audit/list/auditList", "pages/audit/detail/index", diff --git a/IOReportSysMP/miniprogram/components/ybutton/ybutton.js b/IOReportSysMP/miniprogram/components/ybutton/ybutton.js index 13a187b..2ee769a 100644 --- a/IOReportSysMP/miniprogram/components/ybutton/ybutton.js +++ b/IOReportSysMP/miniprogram/components/ybutton/ybutton.js @@ -8,6 +8,7 @@ Component({ title: String, bgColor: String, lineHeight: String, + formtype: String }, /** * 组件的初始数据 diff --git a/IOReportSysMP/miniprogram/components/ybutton/ybutton.ts b/IOReportSysMP/miniprogram/components/ybutton/ybutton.ts index 79124b8..82e644c 100644 --- a/IOReportSysMP/miniprogram/components/ybutton/ybutton.ts +++ b/IOReportSysMP/miniprogram/components/ybutton/ybutton.ts @@ -7,6 +7,7 @@ Component({ title: String, bgColor: String, lineHeight: String, + formtype:String }, /** diff --git a/IOReportSysMP/miniprogram/components/ybutton/ybutton.wxml b/IOReportSysMP/miniprogram/components/ybutton/ybutton.wxml index aa600eb..8419b31 100644 --- a/IOReportSysMP/miniprogram/components/ybutton/ybutton.wxml +++ b/IOReportSysMP/miniprogram/components/ybutton/ybutton.wxml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/IOReportSysMP/miniprogram/components/yform/yform.js b/IOReportSysMP/miniprogram/components/yform/yform.js index 4a5b49b..9cb1194 100644 --- a/IOReportSysMP/miniprogram/components/yform/yform.js +++ b/IOReportSysMP/miniprogram/components/yform/yform.js @@ -7,6 +7,7 @@ var yfieldsControls_1 = __importDefault(require("../yfieldsControls")); Component({ properties: { rules: Object, + bindsubmit: String }, data: { form: {}, @@ -55,6 +56,7 @@ Component({ return true; }, onSubmit: function () { + console.log("ddddd"); if (!this.validate()) return; this.triggerEvent("onSubmit", this.data.form, {}); diff --git a/IOReportSysMP/miniprogram/components/yform/yform.ts b/IOReportSysMP/miniprogram/components/yform/yform.ts index b3d6b81..579384c 100644 --- a/IOReportSysMP/miniprogram/components/yform/yform.ts +++ b/IOReportSysMP/miniprogram/components/yform/yform.ts @@ -3,6 +3,7 @@ import yfieldsControls from "../yfieldsControls" Component({ properties: { rules: Object, + bindsubmit:String }, data: { form: {} as any, @@ -49,6 +50,7 @@ Component({ return true; }, onSubmit: function () { + console.log("ddddd") if (!this.validate()) return; this.triggerEvent("onSubmit",this.data.form,{}) }, diff --git a/IOReportSysMP/miniprogram/components/yform/yform.wxml b/IOReportSysMP/miniprogram/components/yform/yform.wxml index 7b09407..530483d 100644 --- a/IOReportSysMP/miniprogram/components/yform/yform.wxml +++ b/IOReportSysMP/miniprogram/components/yform/yform.wxml @@ -1,3 +1,3 @@ - +
- \ No newline at end of file +
\ No newline at end of file diff --git a/IOReportSysMP/miniprogram/pages/index/index.js b/IOReportSysMP/miniprogram/pages/index/index.js index 456fb07..bb66a8d 100644 --- a/IOReportSysMP/miniprogram/pages/index/index.js +++ b/IOReportSysMP/miniprogram/pages/index/index.js @@ -80,27 +80,24 @@ Page({ }, onLoad: function () { return __awaiter(this, void 0, void 0, function () { - var roles, res, user; + var user, res, user_1, roles; return __generator(this, function (_a) { switch (_a.label) { case 0: - roles = wx.getStorageSync(constant_1.default.ROLE_LIST); - if (!!roles) return [3 /*break*/, 2]; + user = wx.getStorageSync(constant_1.default.USER_INFO); + if (!!user) return [3 /*break*/, 2]; util_1.wxLogin(); return [4 /*yield*/, index_1.default.API.user.getCurrentUser.request()]; case 1: res = _a.sent(); - user = void 0; if (res && res.data) { - user = res.data; - console.log("aaaaa", roles); - wx.setStorageSync(constant_1.default.USER_INFO, user); - roles = user === null || user === void 0 ? void 0 : user.roles; - wx.setStorageSync(constant_1.default.ROLE_LIST, roles); + user_1 = res.data; + console.log("aaaaa", user_1); + wx.setStorageSync(constant_1.default.USER_INFO, user_1); } _a.label = 2; case 2: - console.log("sssss", roles); + roles = user === null || user === void 0 ? void 0 : user.roles; this.onLoadGetUserRole(roles); return [2 /*return*/]; } diff --git a/IOReportSysMP/miniprogram/pages/index/index.ts b/IOReportSysMP/miniprogram/pages/index/index.ts index 9250324..7aedc05 100644 --- a/IOReportSysMP/miniprogram/pages/index/index.ts +++ b/IOReportSysMP/miniprogram/pages/index/index.ts @@ -1,6 +1,5 @@ import constant from "../../utils/constant" import services from "../../services/index" -import { UserInfoVO } from "../../services/baseClass" import { wxLogin } from "../../utils/util" Page({ @@ -45,21 +44,20 @@ Page({ onLoad:async function () { // TODO 报备历史获取 by userinfo // 会设置this.data.role = 2 | 6 | 10 => 门卫 | 老师 | 管理 - let roles = wx.getStorageSync(constant.ROLE_LIST); + let user = wx.getStorageSync(constant.USER_INFO); //roles = null; - if (!roles) { + if (!user) { wxLogin(); let res = await services.API.user.getCurrentUser.request(); let user; if(res&&res.data){ user = res.data; - console.log("aaaaa",roles); + console.log("aaaaa",user); wx.setStorageSync(constant.USER_INFO, user); - roles = user?.roles; - wx.setStorageSync(constant.ROLE_LIST,roles); + } } - console.log("sssss",roles); + let roles = user?.roles; this.onLoadGetUserRole(roles) }, diff --git a/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.js b/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.js index eb48e68..2997ab0 100644 --- a/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.js +++ b/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.js @@ -60,10 +60,12 @@ Page({ */ onLoad: function () { return __awaiter(this, void 0, void 0, function () { + var record; return __generator(this, function (_a) { // TODO orderinfo by orderID - //const reportID = wx.getStorageSync("myReport/myReport") + // const reportID = wx.getStorageSync("myReport/myReport") this.getRecordDetail(); + record = this.data.ioRecord; this.startInter(); return [2 /*return*/]; }); @@ -75,7 +77,7 @@ Page({ return __generator(this, function (_a) { switch (_a.label) { case 0: - reportID = 4; + reportID = wx.getStorageSync("myReport/myReport"); return [4 /*yield*/, index_1.default.API.iORecords.getIORecordByID.request({ ID: reportID })]; case 1: res = _a.sent(); @@ -88,6 +90,9 @@ Page({ this.drawQrcode(qrToken); wx.setStorageSync("QRCODE_EXPIRE", qrToken === null || qrToken === void 0 ? void 0 : qrToken.expireTime); } + else { + this.endInterval(); + } this.setData({ ioRecord: record ? record : null }); } return [2 /*return*/]; @@ -97,7 +102,7 @@ Page({ }, startInter: function () { var that = this; - setInterval(function () { + var interval = setInterval(function () { // TODO 你需要无限循环执行的任务 var expire = wx.getStorageSync("QRCODE_EXPIRE"); var now = Date.parse(new Date().toString()); @@ -106,11 +111,18 @@ Page({ that.getRecordDetail(); } }, 1000); + wx.setStorageSync("interval", interval); + }, + endInterval: function () { + var interval = wx.getStorageSync("interval"); + if (interval) { + clearInterval(interval); + } }, drawQrcode: function (qrCode) { if (qrCode) { console.log("cccc", qrCode); - this.setData({ expireTime: util_1.formatDateStr(qrCode.expireTime) }); + this.setData({ expireTime: util_1.formatDateTimeStr(qrCode.expireTime) }); var qrcodeStr = JSON.stringify(qrCode); var qrSrc = weapp_qrcode_1.default.drawImg(qrcodeStr, { typeNumber: 4, @@ -134,11 +146,13 @@ Page({ * 生命周期函数--监听页面隐藏 */ onHide: function () { + console.log("onhide"); }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { + this.endInterval(); }, /** * 页面相关事件处理函数--监听用户下拉动作 diff --git a/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.ts b/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.ts index eda1ade..395a4cb 100644 --- a/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.ts +++ b/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.ts @@ -1,13 +1,14 @@ import { IORecords, QRToken } from '../../../services/baseClass' import QR from '../../../utils/weapp-qrcode/weapp-qrcode' import services from "../../../services/index" -import { formatDateStr } from '../../../utils/util' +import { formatDateTimeStr } from '../../../utils/util' Page({ /** * 页面的初始数据 */ + data: { showQrcode: false, ioRecord : IORecords, @@ -21,17 +22,18 @@ Page({ */ onLoad:async function() { // TODO orderinfo by orderID - //const reportID = wx.getStorageSync("myReport/myReport") + // const reportID = wx.getStorageSync("myReport/myReport") this.getRecordDetail(); + let record = this.data.ioRecord; this.startInter(); }, getRecordDetail : async function(){ - // const reportID = wx.getStorageSync("myReport/myReport") - const reportID = 4; - let res = await services.API.iORecords.getIORecordByID.request({ID:reportID}); - + const reportID = wx.getStorageSync("myReport/myReport") + // const reportID = 4; + let res = await services.API.iORecords.getIORecordByID.request({ID:reportID}); if(res&&res.data){ let record = res.data; + if (record.status == 'SCHOOL_PASS') { console.log(record); this.setData({ showQrcode: true }) @@ -39,14 +41,15 @@ Page({ this.drawQrcode(qrToken); wx.setStorageSync("QRCODE_EXPIRE",qrToken?.expireTime); + }else{ + this.endInterval(); } this.setData({ioRecord:record?record:null}); } }, startInter : function(){ - let that = this; - - setInterval( + let that = this; + let interval = setInterval( function () { // TODO 你需要无限循环执行的任务 const expire = wx.getStorageSync("QRCODE_EXPIRE"); @@ -56,12 +59,19 @@ Page({ that.getRecordDetail(); } }, 1000); + wx.setStorageSync("interval",interval); }, + endInterval(){ + let interval = wx.getStorageSync("interval"); + if(interval){ + clearInterval(interval); + } + }, drawQrcode:function(qrCode){ if(qrCode){ console.log("cccc",qrCode); - this.setData({expireTime: formatDateStr(qrCode.expireTime)}); + this.setData({expireTime: formatDateTimeStr(qrCode.expireTime)}); let qrcodeStr = JSON.stringify(qrCode); const qrSrc = QR.drawImg(qrcodeStr, { typeNumber: 4, @@ -88,14 +98,14 @@ Page({ * 生命周期函数--监听页面隐藏 */ onHide() { - + console.log("onhide"); }, /** * 生命周期函数--监听页面卸载 */ onUnload() { - + this.endInterval(); }, /** diff --git a/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.wxml b/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.wxml index d80258f..6f25600 100644 --- a/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.wxml +++ b/IOReportSysMP/miniprogram/pages/report/detail/reportDetail.wxml @@ -13,7 +13,7 @@
- + diff --git a/IOReportSysMP/miniprogram/pages/report/enter/enterReport.js b/IOReportSysMP/miniprogram/pages/report/enter/enterReport.js index d9a37e6..80b3782 100644 --- a/IOReportSysMP/miniprogram/pages/report/enter/enterReport.js +++ b/IOReportSysMP/miniprogram/pages/report/enter/enterReport.js @@ -10,37 +10,128 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -var orderApi_1 = __importDefault(require("../../../api/orderApi/orderApi")); var constant_1 = __importDefault(require("../../../utils/constant")); +var util_1 = require("../../../utils/util"); +var index_1 = __importDefault(require("../../../services/index")); +var today = util_1.formatDateStr(); // pages/enterReport/enterReport.ts Page({ /** * 页面的初始数据 */ data: { - rules: { - enterDate: { require: { value: true, } }, - innerLocation: { require: { value: true, } }, - outerLocation: { require: { value: true, } }, - reason: { require: { value: true, } }, - } + startDate: today, + applyDate: today, + applyTime: '08:30', + ioTypesArray: ['进校', '出校'], + ioRecord: {}, + ioType: '进校' + }, + bindDateChange: function (e) { + this.setData({ + applyDate: e.detail.value, + }); + }, + bindTimeChange: function (e) { + this.setData({ + applyTime: e.detail.value, + }); + }, + ioTypeChange: function (e) { + this.setData({ + ioType: this.data.ioTypesArray[e.detail.value], + }); + }, + // 获取文本框字数 + inputs: function (e) { + var _a; + var value = e.detail.value; + this.setData((_a = { + text_len: value.length, + detail: value + }, + _a["formData.detail"] = value, + _a)); }, onSubmit: function (_a) { var detail = _a.detail; - // TODO gen order - var submitDate = __assign(__assign({}, detail), { reportDateTime: detail.enterDate + ' ' + detail.enterTime }); - console.log(this.data); - orderApi_1.default.submitOrder(submitDate); + return __awaiter(this, void 0, void 0, function () { + var submitRecord, res, reportid; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + // TODO gen order + if (!this.data.teacherID) { + wx.showToast({ + title: '提交失败,缺少用户信息', + icon: 'none' + }); + } + submitRecord = __assign(__assign({}, detail.value), { ioType: this.data.ioTypesArray.indexOf(this.data.ioType), teacherID: this.data.teacherID, commitTime: this.data.applyDate + ' ' + this.data.applyTime + ":00" }); + return [4 /*yield*/, index_1.default.API.iORecords.addIORecord.request(submitRecord)]; + case 1: + res = _b.sent(); + console.log(res); + if (res && res.data) { + reportid = res.data; + wx.setStorageSync("myReport/myReport", reportid); + wx.navigateTo({ url: "../detail/reportDetail" }); + } + return [2 /*return*/]; + } + }); + }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { - this.setData(__assign(__assign({}, this.data), wx.getStorageSync(constant_1.default.USER_INFO))); + // wx.removeStorageSync(constant.USER_INFO); + var user = wx.getStorageSync(constant_1.default.USER_INFO); + if (!user) { + wx.navigateTo({ url: "../../index/index" }); + } + this.setData(__assign(__assign({}, this.data), user)); }, /** * 生命周期函数--监听页面初次渲染完成 diff --git a/IOReportSysMP/miniprogram/pages/report/enter/enterReport.scss b/IOReportSysMP/miniprogram/pages/report/enter/enterReport.scss index ea98b4f..5817a58 100644 --- a/IOReportSysMP/miniprogram/pages/report/enter/enterReport.scss +++ b/IOReportSysMP/miniprogram/pages/report/enter/enterReport.scss @@ -10,6 +10,7 @@ } .input-container { + padding-bottom: 80rpx; .card-col-1 { display: flex; margin: 0 2px; @@ -20,9 +21,11 @@ } .submit-button { - position: absolute; + position: fixed; bottom: 0; left: 0; - right: 0; - display: flex; + background-color: var(--color-primary); + color: white; + width: 100%; + border-radius: 0; } \ No newline at end of file diff --git a/IOReportSysMP/miniprogram/pages/report/enter/enterReport.ts b/IOReportSysMP/miniprogram/pages/report/enter/enterReport.ts index 9f644b0..514d2ca 100644 --- a/IOReportSysMP/miniprogram/pages/report/enter/enterReport.ts +++ b/IOReportSysMP/miniprogram/pages/report/enter/enterReport.ts @@ -1,40 +1,100 @@ -import orderApi from "../../../api/orderApi/orderApi" import constant from "../../../utils/constant" - +import { IORecords, User } from '../../../services/baseClass' +import { formatDateStr} from "../../../utils/util" +import services from "../../../services/index" +const today = formatDateStr(); +interface IPageData { + ioTypesArray:any[], + ioRecord:IORecords, + startDate:String, + applyDate:String, + applyTime:String, + ioType:String +} +interface IPage { + +} // pages/enterReport/enterReport.ts -Page({ +Page({ /** * 页面的初始数据 */ data: { - rules: { - enterDate: { require: { value: true, } }, - innerLocation: { require: { value: true, } }, - outerLocation: { require: { value: true, } }, - reason: { require: { value: true, } }, - } + startDate:today, + applyDate:today, + applyTime:'08:30', + ioTypesArray:['进校','出校'], + ioRecord:{}, + ioType:'进校' }, - - onSubmit({ detail }: { detail: Order.submitEventDetail }) { + bindDateChange(e:any) { + this.setData({ + applyDate: e.detail.value, + }); + }, + bindTimeChange(e:any) { + this.setData({ + applyTime: e.detail.value, + }); + }, + ioTypeChange (e:any) { + this.setData({ + ioType:this.data.ioTypesArray[e.detail.value], + }); + }, + // 获取文本框字数 + inputs: function (e: any) { + var value = e.detail.value; + this.setData({ + text_len: value.length, + detail: value, + [`formData.detail`]: value + }) + }, + + + onSubmit:async function({ detail }: { detail: any}) { // TODO gen order - const submitDate: Order.submitDetail = { - ...detail, - reportDateTime: detail.enterDate + ' ' + detail.enterTime, + if(!this.data.teacherID){ + wx.showToast({ + title: '提交失败,缺少用户信息', + icon: 'none' + }); + } + const submitRecord: IORecords = { + ...detail.value, + ioType:this.data.ioTypesArray.indexOf(this.data.ioType), + teacherID:this.data.teacherID, + commitTime: this.data.applyDate + ' ' + this.data.applyTime+":00", + } + let res = await services.API.iORecords.addIORecord.request(submitRecord); + console.log(res); + + if(res&&res.data){ + + let reportid = res.data; + wx.setStorageSync("myReport/myReport", reportid) + wx.navigateTo({url:"../detail/reportDetail"}); } - console.log(this.data) - orderApi.submitOrder(submitDate) }, /** * 生命周期函数--监听页面加载 */ onLoad() { + // wx.removeStorageSync(constant.USER_INFO); + let user = wx.getStorageSync(constant.USER_INFO); + if(!user){ + wx.navigateTo({url:"../../index/index"}) + } this.setData({ ...this.data, - ...(wx.getStorageSync(constant.USER_INFO) as User.userInfo) + ...(user as User) }) }, + + /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/IOReportSysMP/miniprogram/pages/report/enter/enterReport.wxml b/IOReportSysMP/miniprogram/pages/report/enter/enterReport.wxml index 4482af5..ca3df90 100644 --- a/IOReportSysMP/miniprogram/pages/report/enter/enterReport.wxml +++ b/IOReportSysMP/miniprogram/pages/report/enter/enterReport.wxml @@ -1,22 +1,73 @@ - - - - + + + - - - - - - - - + + + + +
+ + 进出校报备信息填写 + + + + + + + + {{ioType}} + + + + + + + + + + {{applyDate}} + + + + + + + + + + {{applyTime}} + + + + + + + + + + + + + + + + + + + + + + + + 已输入{{text_len?text_len:0}}字/50 + + + + - - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/IOReportSysMP/miniprogram/pages/report/enter/enterReport.wxss b/IOReportSysMP/miniprogram/pages/report/enter/enterReport.wxss deleted file mode 100644 index 11b5d36..0000000 --- a/IOReportSysMP/miniprogram/pages/report/enter/enterReport.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/report/enter/enterReport.wxss */ \ No newline at end of file diff --git a/IOReportSysMP/miniprogram/pages/report/list/myReport.ts b/IOReportSysMP/miniprogram/pages/report/list/myReport.ts index a359102..f98ca71 100644 --- a/IOReportSysMP/miniprogram/pages/report/list/myReport.ts +++ b/IOReportSysMP/miniprogram/pages/report/list/myReport.ts @@ -2,7 +2,6 @@ import { QRecord } from "../../../services/baseClass" import services from "../../../services/index" import constant from "../../../utils/constant" -import { formatDateStr } from '../../../utils/util' Page({ diff --git a/IOReportSysMP/miniprogram/services/api-lock.json b/IOReportSysMP/miniprogram/services/api-lock.json index 29b4f7c..1e51d3a 100644 --- a/IOReportSysMP/miniprogram/services/api-lock.json +++ b/IOReportSysMP/miniprogram/services/api-lock.json @@ -5,6 +5,51 @@ "description": "出入校报备记录控制器", "name": "iORecords", "interfaces": [ + { + "consumes": [ + "application/json" + ], + "description": "根据记录ID获取记录详细信息", + "name": "addIORecord", + "method": "post", + "path": "/api/records/add", + "response": { + "typeArgs": [ + { + "typeArgs": [], + "typeName": "IORecords", + "isDefsType": true, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + } + ], + "typeName": "ResultVO", + "isDefsType": true, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + }, + "parameters": [ + { + "in": "body", + "description": "param", + "name": "param", + "required": true, + "dataType": { + "typeArgs": [], + "typeName": "IORecords", + "isDefsType": true, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + } + } + ] + }, { "description": "根据记录ID获取记录详细信息", "name": "getIORecordByID", @@ -212,7 +257,7 @@ "path": "/test/user/detail1", "response": { "typeArgs": [], - "typeName": "UserInfoVO", + "typeName": "User", "isDefsType": true, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", @@ -262,7 +307,7 @@ "path": "/test/user/detail11", "response": { "typeArgs": [], - "typeName": "UserInfoVO", + "typeName": "User", "isDefsType": true, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", @@ -309,7 +354,7 @@ "path": "/test/user/detail2", "response": { "typeArgs": [], - "typeName": "UserInfoVO", + "typeName": "User", "isDefsType": true, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", @@ -344,7 +389,7 @@ "path": "/test/user/detail22", "response": { "typeArgs": [], - "typeName": "UserInfoVO", + "typeName": "User", "isDefsType": true, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", @@ -376,7 +421,7 @@ "path": "/test/user/detail3", "response": { "typeArgs": [], - "typeName": "UserInfoVO", + "typeName": "User", "isDefsType": true, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", @@ -411,7 +456,7 @@ "path": "/test/user/detail4", "response": { "typeArgs": [], - "typeName": "UserInfoVO", + "typeName": "User", "isDefsType": true, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", @@ -496,7 +541,7 @@ "typeArgs": [ { "typeArgs": [], - "typeName": "UserInfoVO", + "typeName": "User", "isDefsType": true, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", @@ -584,6 +629,41 @@ } ], "baseClasses": [ + { + "description": "二级学院", + "name": "Department", + "templateArgs": [], + "properties": [ + { + "dataType": { + "typeArgs": [], + "typeName": "string", + "isDefsType": false, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + }, + "name": "department", + "description": "部门名称", + "required": false + }, + { + "dataType": { + "typeArgs": [], + "typeName": "string", + "isDefsType": false, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + }, + "name": "departmentID", + "description": "部门编码", + "required": false + } + ] + }, { "name": "GrantedAuthority", "templateArgs": [], @@ -636,6 +716,20 @@ "description": "院级审核时间", "required": false }, + { + "dataType": { + "typeArgs": [], + "typeName": "User", + "isDefsType": true, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + }, + "name": "deptAuditor", + "description": "院级审核人", + "required": false + }, { "dataType": { "typeArgs": [], @@ -681,7 +775,7 @@ { "dataType": { "typeArgs": [], - "typeName": "number", + "typeName": "string", "isDefsType": false, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", @@ -748,6 +842,20 @@ "description": "校级审核时间", "required": false }, + { + "dataType": { + "typeArgs": [], + "typeName": "User", + "isDefsType": true, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + }, + "name": "schoolAuditor", + "description": "校级审核人", + "required": false + }, { "dataType": { "typeArgs": [], @@ -776,6 +884,20 @@ "description": "单据状态:0-保存;1-提交待审核;2-院级审核通过;3-校级审核通过;4-核验通过;9-院级审核不通过;8-校级审核不通过;7-核验不通过", "required": false }, + { + "dataType": { + "typeArgs": [], + "typeName": "User", + "isDefsType": true, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + }, + "name": "teacher", + "description": "教师", + "required": false + }, { "dataType": { "typeArgs": [], @@ -804,6 +926,20 @@ "description": "核验时间", "required": false }, + { + "dataType": { + "typeArgs": [], + "typeName": "User", + "isDefsType": true, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + }, + "name": "validator", + "description": "核验人", + "required": false + }, { "dataType": { "typeArgs": [], @@ -920,19 +1056,6 @@ "name": "expireTime", "required": false }, - { - "dataType": { - "typeArgs": [], - "typeName": "number", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "randomKey", - "required": false - }, { "dataType": { "typeArgs": [], @@ -1017,6 +1140,7 @@ "typeProperties": [] }, "name": "teacherID", + "description": "教师工号", "required": false }, { @@ -1371,20 +1495,6 @@ "name": "authorities", "required": false }, - { - "dataType": { - "typeArgs": [], - "typeName": "string", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "createTime", - "description": "创建时间", - "required": false - }, { "dataType": { "typeArgs": [], @@ -1395,36 +1505,22 @@ "enum": [], "typeProperties": [] }, - "name": "createUserId", - "description": "创建人", - "required": false - }, - { - "dataType": { - "typeArgs": [], - "typeName": "string", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "deleteTime", - "description": "删除时间", + "name": "departmentID", + "description": "所属单位", "required": false }, { "dataType": { "typeArgs": [], - "typeName": "number", - "isDefsType": false, + "typeName": "Department", + "isDefsType": true, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", "enum": [], "typeProperties": [] }, - "name": "deleteUserId", - "description": "删除者", + "name": "dept", + "description": "角色列表", "required": false }, { @@ -1437,8 +1533,7 @@ "enum": [], "typeProperties": [] }, - "name": "enable", - "description": "是否启用 1:启用 0:禁用", + "name": "enabled", "required": false }, { @@ -1451,7 +1546,8 @@ "enum": [], "typeProperties": [] }, - "name": "enabled", + "name": "isInSchool", + "description": "是否在校 1:在校 0:未在", "required": false }, { @@ -1464,22 +1560,8 @@ "enum": [], "typeProperties": [] }, - "name": "fullName", - "description": "用户真实名", - "required": false - }, - { - "dataType": { - "typeArgs": [], - "typeName": "number", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "id", - "description": "用户id", + "name": "mobile", + "description": "手机号", "required": false }, { @@ -1492,22 +1574,8 @@ "enum": [], "typeProperties": [] }, - "name": "lastModifyTime", - "description": "最后更新时间", - "required": false - }, - { - "dataType": { - "typeArgs": [], - "typeName": "number", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "lastModifyUserId", - "description": "最后更新者", + "name": "name", + "description": "用户姓名", "required": false }, { @@ -1521,21 +1589,7 @@ "typeProperties": [] }, "name": "password", - "description": "用户密码", - "required": false - }, - { - "dataType": { - "typeArgs": [], - "typeName": "string", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "phone", - "description": "手机号", + "description": "密码", "required": false }, { @@ -1562,69 +1616,6 @@ "description": "角色列表", "required": false }, - { - "dataType": { - "typeArgs": [], - "typeName": "number", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "unitId", - "description": "所属单位", - "required": false - }, - { - "dataType": { - "typeArgs": [], - "typeName": "string", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "username", - "description": "用户名", - "required": false - }, - { - "dataType": { - "typeArgs": [], - "typeName": "number", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "wechatId", - "description": "微信小程序id", - "required": false - } - ] - }, - { - "description": "用户信息", - "name": "UserInfoVO", - "templateArgs": [], - "properties": [ - { - "dataType": { - "typeArgs": [], - "typeName": "string", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "address", - "description": "地址信息", - "required": false - }, { "dataType": { "typeArgs": [], @@ -1635,8 +1626,8 @@ "enum": [], "typeProperties": [] }, - "name": "fullName", - "description": "真实名", + "name": "teacherID", + "description": "教师工号", "required": false }, { @@ -1649,7 +1640,7 @@ "enum": [], "typeProperties": [] }, - "name": "id", + "name": "userID", "description": "用户id", "required": false }, @@ -1663,46 +1654,7 @@ "enum": [], "typeProperties": [] }, - "name": "phone", - "description": "手机号", - "required": false - }, - { - "dataType": { - "typeArgs": [ - { - "typeArgs": [], - "typeName": "string", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - } - ], - "typeName": "Array", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "roles", - "description": "角色列表", - "required": false - }, - { - "dataType": { - "typeArgs": [], - "typeName": "string", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, - "name": "teacherID", - "description": "教师工号", + "name": "username", "required": false }, { @@ -1715,22 +1667,8 @@ "enum": [], "typeProperties": [] }, - "name": "unitId", - "description": "所属单位", - "required": false - }, - { - "dataType": { - "typeArgs": [], - "typeName": "string", - "isDefsType": false, - "templateIndex": -1, - "compileTemplateKeyword": "#/definitions/", - "enum": [], - "typeProperties": [] - }, "name": "wechatID", - "description": "微信id", + "description": "微信小程序id", "required": false } ] diff --git a/IOReportSysMP/miniprogram/services/api.d.ts b/IOReportSysMP/miniprogram/services/api.d.ts index f3efad8..97a1352 100644 --- a/IOReportSysMP/miniprogram/services/api.d.ts +++ b/IOReportSysMP/miniprogram/services/api.d.ts @@ -3,6 +3,14 @@ type ObjectMap = { }; declare namespace defs { + export class Department { + /** 部门名称 */ + department?: string; + + /** 部门编码 */ + departmentID?: string; + } + export class GrantedAuthority { /** authority */ authority?: string; @@ -15,6 +23,9 @@ declare namespace defs { /** 院级审核时间 */ deptAuditTime?: string; + /** 院级审核人 */ + deptAuditor?: defs.User; + /** 院级审核人 */ deptAuditorID?: number; @@ -25,7 +36,7 @@ declare namespace defs { innerResidence?: string; /** 报备单类型:1-出;0-入 */ - ioType?: number; + ioType?: string; /** 校外居住地 */ outerResidence?: string; @@ -39,18 +50,27 @@ declare namespace defs { /** 校级审核时间 */ schoolAuditTime?: string; + /** 校级审核人 */ + schoolAuditor?: defs.User; + /** 校级审核人 */ schoolAuditorID?: number; /** 单据状态:0-保存;1-提交待审核;2-院级审核通过;3-校级审核通过;4-核验通过;9-院级审核不通过;8-校级审核不通过;7-核验不通过 */ status?: string; + /** 教师 */ + teacher?: defs.User; + /** 教师工号 */ teacherID?: string; /** 核验时间 */ validateTime?: string; + /** 核验人 */ + validator?: defs.User; + /** 核验人 */ validatorID?: number; } @@ -73,9 +93,6 @@ declare namespace defs { /** expireTime */ expireTime?: string; - /** randomKey */ - randomKey?: number; - /** recordID */ recordID?: number; } @@ -93,7 +110,7 @@ declare namespace defs { /** 记录状态 */ status?: string; - /** teacherID */ + /** 教师工号 */ teacherID?: string; /** 记录类型 */ @@ -169,67 +186,26 @@ declare namespace defs { /** authorities */ authorities?: Array; - /** 创建时间 */ - createTime?: string; - - /** 创建人 */ - createUserId?: number; - - /** 删除时间 */ - deleteTime?: string; - - /** 删除者 */ - deleteUserId?: number; + /** 所属单位 */ + departmentID?: number; - /** 是否启用 1:启用 0:禁用 */ - enable?: boolean; + /** 角色列表 */ + dept?: defs.Department; /** enabled */ enabled?: boolean; - /** 用户真实名 */ - fullName?: string; - - /** 用户id */ - id?: number; - - /** 最后更新时间 */ - lastModifyTime?: string; - - /** 最后更新者 */ - lastModifyUserId?: number; - - /** 用户密码 */ - password?: string; + /** 是否在校 1:在校 0:未在 */ + isInSchool?: boolean; /** 手机号 */ - phone?: string; - - /** 角色列表 */ - roles?: Array; - - /** 所属单位 */ - unitId?: number; - - /** 用户名 */ - username?: string; - - /** 微信小程序id */ - wechatId?: number; - } - - export class UserInfoVO { - /** 地址信息 */ - address?: string; - - /** 真实名 */ - fullName?: string; + mobile?: string; - /** 用户id */ - id?: number; + /** 用户姓名 */ + name?: string; - /** 手机号 */ - phone?: string; + /** 密码 */ + password?: string; /** 角色列表 */ roles?: Array; @@ -237,11 +213,14 @@ declare namespace defs { /** 教师工号 */ teacherID?: string; - /** 所属单位 */ - unitId?: number; + /** 用户id */ + userID?: number; - /** 微信id */ - wechatID?: string; + /** username */ + username?: string; + + /** 微信小程序id */ + wechatID?: number; } } @@ -250,6 +229,21 @@ declare namespace API { * 出入校报备记录控制器 */ export namespace iORecords { + /** + * 根据记录ID获取记录详细信息 + * /api/records/add + */ + export namespace addIORecord { + export type ResponseType = Promise>; + + export const URL: string; + + export function request( + bodyParams: defs.IORecords, + options?: WechatMiniprogram.RequestOption, + ): ResponseType; + } + /** * 根据记录ID获取记录详细信息 * /api/records/detail @@ -346,7 +340,7 @@ declare namespace API { phone?: string; } - export type ResponseType = Promise; + export type ResponseType = Promise; export const URL: string; @@ -368,7 +362,7 @@ declare namespace API { phone?: string; } - export type ResponseType = Promise; + export type ResponseType = Promise; export const URL: string; @@ -388,7 +382,7 @@ declare namespace API { param: string; } - export type ResponseType = Promise; + export type ResponseType = Promise; export const URL: string; @@ -408,7 +402,7 @@ declare namespace API { param: string; } - export type ResponseType = Promise; + export type ResponseType = Promise; export const URL: string; @@ -423,7 +417,7 @@ declare namespace API { * /test/user/detail3 */ export namespace getUserInfo3 { - export type ResponseType = Promise; + export type ResponseType = Promise; export const URL: string; @@ -438,7 +432,7 @@ declare namespace API { * /test/user/detail4 */ export namespace getUserInfo4 { - export type ResponseType = Promise; + export type ResponseType = Promise; export const URL: string; @@ -473,7 +467,7 @@ declare namespace API { * /api/user/current */ export namespace getCurrentUser { - export type ResponseType = Promise>; + export type ResponseType = Promise>; export const URL: string; diff --git a/IOReportSysMP/miniprogram/services/baseClass.js b/IOReportSysMP/miniprogram/services/baseClass.js index 4133dc0..d978841 100644 --- a/IOReportSysMP/miniprogram/services/baseClass.js +++ b/IOReportSysMP/miniprogram/services/baseClass.js @@ -1,6 +1,16 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.UserInfoVO = exports.User = exports.ResultVO = exports.ResponseEntity = exports.Resource = exports.QUser = exports.QRecord = exports.QRToken = exports.ListResultVO = exports.IORecords = exports.GrantedAuthority = void 0; +exports.User = exports.ResultVO = exports.ResponseEntity = exports.Resource = exports.QUser = exports.QRecord = exports.QRToken = exports.ListResultVO = exports.IORecords = exports.GrantedAuthority = exports.Department = void 0; +var Department = /** @class */ (function () { + function Department() { + /** 部门名称 */ + this.department = ''; + /** 部门编码 */ + this.departmentID = ''; + } + return Department; +}()); +exports.Department = Department; var GrantedAuthority = /** @class */ (function () { function GrantedAuthority() { /** authority */ @@ -16,13 +26,15 @@ var IORecords = /** @class */ (function () { /** 院级审核时间 */ this.deptAuditTime = ''; /** 院级审核人 */ + this.deptAuditor = new User(); + /** 院级审核人 */ this.deptAuditorID = undefined; /** 报备记录ID */ this.id = undefined; /** 校内居住地 */ this.innerResidence = ''; /** 报备单类型:1-出;0-入 */ - this.ioType = undefined; + this.ioType = ''; /** 校外居住地 */ this.outerResidence = ''; /** 二维码token */ @@ -32,14 +44,20 @@ var IORecords = /** @class */ (function () { /** 校级审核时间 */ this.schoolAuditTime = ''; /** 校级审核人 */ + this.schoolAuditor = new User(); + /** 校级审核人 */ this.schoolAuditorID = undefined; /** 单据状态:0-保存;1-提交待审核;2-院级审核通过;3-校级审核通过;4-核验通过;9-院级审核不通过;8-校级审核不通过;7-核验不通过 */ this.status = ''; + /** 教师 */ + this.teacher = new User(); /** 教师工号 */ this.teacherID = ''; /** 核验时间 */ this.validateTime = ''; /** 核验人 */ + this.validator = new User(); + /** 核验人 */ this.validatorID = undefined; } return IORecords; @@ -63,8 +81,6 @@ var QRToken = /** @class */ (function () { function QRToken() { /** expireTime */ this.expireTime = ''; - /** randomKey */ - this.randomKey = undefined; /** recordID */ this.recordID = undefined; } @@ -81,7 +97,7 @@ var QRecord = /** @class */ (function () { this.sorter = ''; /** 记录状态 */ this.status = ''; - /** teacherID */ + /** 教师工号 */ this.teacherID = ''; /** 记录类型 */ this.type = ''; @@ -155,61 +171,31 @@ var User = /** @class */ (function () { this.address = ''; /** authorities */ this.authorities = []; - /** 创建时间 */ - this.createTime = ''; - /** 创建人 */ - this.createUserId = undefined; - /** 删除时间 */ - this.deleteTime = ''; - /** 删除者 */ - this.deleteUserId = undefined; - /** 是否启用 1:启用 0:禁用 */ - this.enable = false; + /** 所属单位 */ + this.departmentID = undefined; + /** 角色列表 */ + this.dept = new Department(); /** enabled */ this.enabled = false; - /** 用户真实名 */ - this.fullName = ''; - /** 用户id */ - this.id = undefined; - /** 最后更新时间 */ - this.lastModifyTime = ''; - /** 最后更新者 */ - this.lastModifyUserId = undefined; - /** 用户密码 */ - this.password = ''; + /** 是否在校 1:在校 0:未在 */ + this.isInSchool = false; /** 手机号 */ - this.phone = ''; + this.mobile = ''; + /** 用户姓名 */ + this.name = ''; + /** 密码 */ + this.password = ''; /** 角色列表 */ this.roles = []; - /** 所属单位 */ - this.unitId = undefined; - /** 用户名 */ + /** 教师工号 */ + this.teacherID = ''; + /** 用户id */ + this.userID = undefined; + /** username */ this.username = ''; /** 微信小程序id */ - this.wechatId = undefined; + this.wechatID = undefined; } return User; }()); exports.User = User; -var UserInfoVO = /** @class */ (function () { - function UserInfoVO() { - /** 地址信息 */ - this.address = ''; - /** 真实名 */ - this.fullName = ''; - /** 用户id */ - this.id = undefined; - /** 手机号 */ - this.phone = ''; - /** 角色列表 */ - this.roles = []; - /** 教师工号 */ - this.teacherID = ''; - /** 所属单位 */ - this.unitId = undefined; - /** 微信id */ - this.wechatID = ''; - } - return UserInfoVO; -}()); -exports.UserInfoVO = UserInfoVO; diff --git a/IOReportSysMP/miniprogram/services/baseClass.ts b/IOReportSysMP/miniprogram/services/baseClass.ts index 01fc8d6..a03b179 100644 --- a/IOReportSysMP/miniprogram/services/baseClass.ts +++ b/IOReportSysMP/miniprogram/services/baseClass.ts @@ -1,3 +1,11 @@ +export class Department { + /** 部门名称 */ + department = ''; + + /** 部门编码 */ + departmentID = ''; +} + export class GrantedAuthority { /** authority */ authority = ''; @@ -10,6 +18,9 @@ export class IORecords { /** 院级审核时间 */ deptAuditTime = ''; + /** 院级审核人 */ + deptAuditor = new User(); + /** 院级审核人 */ deptAuditorID = undefined; @@ -20,7 +31,7 @@ export class IORecords { innerResidence = ''; /** 报备单类型:1-出;0-入 */ - ioType = undefined; + ioType = ''; /** 校外居住地 */ outerResidence = ''; @@ -34,18 +45,27 @@ export class IORecords { /** 校级审核时间 */ schoolAuditTime = ''; + /** 校级审核人 */ + schoolAuditor = new User(); + /** 校级审核人 */ schoolAuditorID = undefined; /** 单据状态:0-保存;1-提交待审核;2-院级审核通过;3-校级审核通过;4-核验通过;9-院级审核不通过;8-校级审核不通过;7-核验不通过 */ status = ''; + /** 教师 */ + teacher = new User(); + /** 教师工号 */ teacherID = ''; /** 核验时间 */ validateTime = ''; + /** 核验人 */ + validator = new User(); + /** 核验人 */ validatorID = undefined; } @@ -68,9 +88,6 @@ export class QRToken { /** expireTime */ expireTime = ''; - /** randomKey */ - randomKey = undefined; - /** recordID */ recordID = undefined; } @@ -88,7 +105,7 @@ export class QRecord { /** 记录状态 */ status = ''; - /** teacherID */ + /** 教师工号 */ teacherID = ''; /** 记录类型 */ @@ -164,67 +181,26 @@ export class User { /** authorities */ authorities = []; - /** 创建时间 */ - createTime = ''; - - /** 创建人 */ - createUserId = undefined; - - /** 删除时间 */ - deleteTime = ''; - - /** 删除者 */ - deleteUserId = undefined; + /** 所属单位 */ + departmentID = undefined; - /** 是否启用 1:启用 0:禁用 */ - enable = false; + /** 角色列表 */ + dept = new Department(); /** enabled */ enabled = false; - /** 用户真实名 */ - fullName = ''; - - /** 用户id */ - id = undefined; - - /** 最后更新时间 */ - lastModifyTime = ''; - - /** 最后更新者 */ - lastModifyUserId = undefined; - - /** 用户密码 */ - password = ''; + /** 是否在校 1:在校 0:未在 */ + isInSchool = false; /** 手机号 */ - phone = ''; + mobile = ''; - /** 角色列表 */ - roles = []; - - /** 所属单位 */ - unitId = undefined; - - /** 用户名 */ - username = ''; - - /** 微信小程序id */ - wechatId = undefined; -} - -export class UserInfoVO { - /** 地址信息 */ - address = ''; - - /** 真实名 */ - fullName = ''; - - /** 用户id */ - id = undefined; + /** 用户姓名 */ + name = ''; - /** 手机号 */ - phone = ''; + /** 密码 */ + password = ''; /** 角色列表 */ roles = []; @@ -232,9 +208,12 @@ export class UserInfoVO { /** 教师工号 */ teacherID = ''; - /** 所属单位 */ - unitId = undefined; + /** 用户id */ + userID = undefined; - /** 微信id */ - wechatID = ''; + /** username */ + username = ''; + + /** 微信小程序id */ + wechatID = undefined; } diff --git a/IOReportSysMP/miniprogram/services/mods/iORecords/addIORecord.js b/IOReportSysMP/miniprogram/services/mods/iORecords/addIORecord.js new file mode 100644 index 0000000..4309bc7 --- /dev/null +++ b/IOReportSysMP/miniprogram/services/mods/iORecords/addIORecord.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.request = exports.URL = void 0; +var util_1 = require("../../../utils/util"); +exports.URL = '/api/records/add'; +/** + * @desc 根据记录ID获取记录详细信息 + */ +function request(bodyParams, options) { + var url = '/api/records/add'; + var fetchOption = Object.assign({ + url: url, + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: bodyParams, + }, options); + return util_1.fetch(fetchOption); +} +exports.request = request; diff --git a/IOReportSysMP/miniprogram/services/mods/iORecords/addIORecord.ts b/IOReportSysMP/miniprogram/services/mods/iORecords/addIORecord.ts new file mode 100644 index 0000000..03b3f39 --- /dev/null +++ b/IOReportSysMP/miniprogram/services/mods/iORecords/addIORecord.ts @@ -0,0 +1,29 @@ +import { fetch } from '../../../utils/util'; + +export type ResponseType = Promise>; + +export const URL = '/api/records/add'; + +/** + * @desc 根据记录ID获取记录详细信息 + */ +export function request( + bodyParams: defs.IORecords, + options?: WechatMiniprogram.RequestOption, +): ResponseType { + let url = '/api/records/add'; + + const fetchOption = Object.assign( + { + url: url, + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + + data: bodyParams, + }, + options, + ); + return fetch(fetchOption); +} diff --git a/IOReportSysMP/miniprogram/services/mods/iORecords/index.js b/IOReportSysMP/miniprogram/services/mods/iORecords/index.js index 1fa2ce7..aaabfa7 100644 --- a/IOReportSysMP/miniprogram/services/mods/iORecords/index.js +++ b/IOReportSysMP/miniprogram/services/mods/iORecords/index.js @@ -19,10 +19,12 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getIORecordsList = exports.getIORecordByID = void 0; +exports.getIORecordsList = exports.getIORecordByID = exports.addIORecord = void 0; /** * @description 出入校报备记录控制器 */ +var addIORecord = __importStar(require("./addIORecord")); +exports.addIORecord = addIORecord; var getIORecordByID = __importStar(require("./getIORecordByID")); exports.getIORecordByID = getIORecordByID; var getIORecordsList = __importStar(require("./getIORecordsList")); diff --git a/IOReportSysMP/miniprogram/services/mods/iORecords/index.ts b/IOReportSysMP/miniprogram/services/mods/iORecords/index.ts index 9e068cf..eef71a8 100644 --- a/IOReportSysMP/miniprogram/services/mods/iORecords/index.ts +++ b/IOReportSysMP/miniprogram/services/mods/iORecords/index.ts @@ -1,7 +1,8 @@ /** * @description 出入校报备记录控制器 */ +import * as addIORecord from './addIORecord'; import * as getIORecordByID from './getIORecordByID'; import * as getIORecordsList from './getIORecordsList'; -export { getIORecordByID, getIORecordsList }; +export { addIORecord, getIORecordByID, getIORecordsList }; diff --git a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo1.ts b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo1.ts index b6b3f9e..aeb2e87 100644 --- a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo1.ts +++ b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo1.ts @@ -8,7 +8,7 @@ export class Params { phone?: string; } -export type ResponseType = Promise; +export type ResponseType = Promise; export const URL = '/test/user/detail1'; diff --git a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo11.ts b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo11.ts index 58e5c5a..b33277b 100644 --- a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo11.ts +++ b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo11.ts @@ -8,7 +8,7 @@ export class Params { phone?: string; } -export type ResponseType = Promise; +export type ResponseType = Promise; export const URL = '/test/user/detail11'; diff --git a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo2.ts b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo2.ts index 07cc36f..dc36402 100644 --- a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo2.ts +++ b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo2.ts @@ -5,7 +5,7 @@ export class Params { param?: string; } -export type ResponseType = Promise; +export type ResponseType = Promise; export const URL = '/test/user/detail2'; diff --git a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo22.ts b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo22.ts index ea8239f..db80473 100644 --- a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo22.ts +++ b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo22.ts @@ -5,7 +5,7 @@ export class Params { param?: string; } -export type ResponseType = Promise; +export type ResponseType = Promise; export const URL = '/test/user/detail22'; diff --git a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo3.ts b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo3.ts index 3631d11..0dbae0a 100644 --- a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo3.ts +++ b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo3.ts @@ -1,6 +1,6 @@ import { fetch } from '../../../utils/util'; -export type ResponseType = Promise; +export type ResponseType = Promise; export const URL = '/test/user/detail3'; diff --git a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo4.ts b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo4.ts index c69e3ba..47d1399 100644 --- a/IOReportSysMP/miniprogram/services/mods/test/getUserInfo4.ts +++ b/IOReportSysMP/miniprogram/services/mods/test/getUserInfo4.ts @@ -1,6 +1,6 @@ import { fetch } from '../../../utils/util'; -export type ResponseType = Promise; +export type ResponseType = Promise; export const URL = '/test/user/detail4'; diff --git a/IOReportSysMP/miniprogram/services/mods/user/getCurrentUser.ts b/IOReportSysMP/miniprogram/services/mods/user/getCurrentUser.ts index b06165f..2e16ac0 100644 --- a/IOReportSysMP/miniprogram/services/mods/user/getCurrentUser.ts +++ b/IOReportSysMP/miniprogram/services/mods/user/getCurrentUser.ts @@ -1,6 +1,6 @@ import { fetch } from '../../../utils/util'; -export type ResponseType = Promise>; +export type ResponseType = Promise>; export const URL = '/api/user/current'; diff --git a/IOReportSysMP/miniprogram/utils/constant.js b/IOReportSysMP/miniprogram/utils/constant.js index 239f39e..75493d2 100644 --- a/IOReportSysMP/miniprogram/utils/constant.js +++ b/IOReportSysMP/miniprogram/utils/constant.js @@ -4,9 +4,16 @@ var ROLE_LIST = "ROLE_LIST"; var SYS_TOKEN = "SYS_TOKEN"; var USER_INFO = "USER_INFO"; var REPORT_INFO = "REPORT_INFO"; +var RecordType = { + "SUBMIT": "院级待审", + "DEPT_PASS": "校级待审", + "SCHOOL_PASS": "审核通过", + "VALIDATED": "核验完成", + "DENY": "退回" +}; exports.default = { - ROLE_LIST: ROLE_LIST, SYS_TOKEN: SYS_TOKEN, USER_INFO: USER_INFO, - REPORT_INFO: REPORT_INFO + REPORT_INFO: REPORT_INFO, + RecordType: RecordType }; diff --git a/IOReportSysMP/miniprogram/utils/constant.ts b/IOReportSysMP/miniprogram/utils/constant.ts index 2f65b2f..dc2e26e 100644 --- a/IOReportSysMP/miniprogram/utils/constant.ts +++ b/IOReportSysMP/miniprogram/utils/constant.ts @@ -2,9 +2,16 @@ const ROLE_LIST = "ROLE_LIST" const SYS_TOKEN = "SYS_TOKEN" const USER_INFO = "USER_INFO" const REPORT_INFO = "REPORT_INFO" +const RecordType : {[key:string]:String}={ + "SUBMIT":"院级待审", + "DEPT_PASS":"校级待审", + "SCHOOL_PASS":"审核通过", + "VALIDATED":"核验完成", + "DENY":"退回" +} export default { - ROLE_LIST, SYS_TOKEN, USER_INFO, - REPORT_INFO + REPORT_INFO, + RecordType } \ No newline at end of file diff --git a/IOReportSysMP/miniprogram/utils/util.js b/IOReportSysMP/miniprogram/utils/util.js index d8afe9e..2a83438 100644 --- a/IOReportSysMP/miniprogram/utils/util.js +++ b/IOReportSysMP/miniprogram/utils/util.js @@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () { return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.wxLogin = exports.fetch = exports.buttonClicked = exports.BASE_URL = exports.formatTimeMills = exports.formatTime = exports.formatDateStr = void 0; +exports.wxLogin = exports.fetch = exports.buttonClicked = exports.BASE_URL = exports.formatTimeStr = exports.formatDateStr = exports.formatTime = exports.formatDateTimeStr = void 0; // 日期格式化 /** * 格式化时间 @@ -19,7 +19,7 @@ exports.wxLogin = exports.fetch = exports.buttonClicked = exports.BASE_URL = exp * @param strDate(中国标准时间、时间戳等) * @param strFormat(返回格式) */ -var formatDateStr = function (strDate, strFormat) { +var formatDateTimeStr = function (strDate, strFormat) { if (!strDate) { return; } @@ -53,7 +53,7 @@ var formatDateStr = function (strDate, strFormat) { }); } }; -exports.formatDateStr = formatDateStr; +exports.formatDateTimeStr = formatDateTimeStr; var formatTime = function (date) { var year = date.getFullYear(); var month = date.getMonth() + 1; @@ -66,8 +66,11 @@ var formatTime = function (date) { [hour, minute, second].map(formatNumber).join(':')); }; exports.formatTime = formatTime; -var formatTimeMills = function (date) { - var year = date.getTime(); +var formatDateStr = function (date) { + if (!date) { + date = new Date(); + } + var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); // return ( @@ -75,9 +78,27 @@ var formatTimeMills = function (date) { // ' ' + // [hour, minute, second].map(formatNumber).join(':') // ) - return ([year, month, day].map(formatNumber).join('-')); + var datestr = [year, month, day].map(formatNumber).join('-'); + console.log(datestr); + return datestr; +}; +exports.formatDateStr = formatDateStr; +var formatTimeStr = function (date) { + if (!date) { + date = new Date(); + } + var hour = date.getHours(); + var minute = 0; + // return ( + // [year, month, day].map(formatNumber).join('/') + + // ' ' + + // [hour, minute, second].map(formatNumber).join(':') + // ) + var datestr = [hour, minute].map(formatNumber).join(':'); + console.log(datestr); + return datestr; }; -exports.formatTimeMills = formatTimeMills; +exports.formatTimeStr = formatTimeStr; // 数字格式化 var formatNumber = function (n) { var s = n.toString(); diff --git a/IOReportSysMP/miniprogram/utils/util.ts b/IOReportSysMP/miniprogram/utils/util.ts index 2323448..e597767 100644 --- a/IOReportSysMP/miniprogram/utils/util.ts +++ b/IOReportSysMP/miniprogram/utils/util.ts @@ -6,7 +6,7 @@ * @param strDate(中国标准时间、时间戳等) * @param strFormat(返回格式) */ -export const formatDateStr=(strDate: any, strFormat?: any)=>{ +export const formatDateTimeStr=(strDate: any, strFormat?: any)=>{ if (!strDate){ return; } if (!strFormat){ strFormat = 'yyyy-MM-dd HH:mm:ss'; } switch (typeof strDate) { @@ -53,21 +53,38 @@ export const formatTime = (date: Date) => { } -export const formatTimeMills = (date: Date) => { - const year = date.getTime(); - const month = date.getMonth() + 1 - const day = date.getDate() - +export const formatDateStr = (date?: Date) => { + if(!date){ + date = new Date(); + } + const year = date.getFullYear(); + const month = date.getMonth() + 1; + const day = date.getDate(); // return ( // [year, month, day].map(formatNumber).join('/') + // ' ' + // [hour, minute, second].map(formatNumber).join(':') // ) - return ( - [year, month, day].map(formatNumber).join('-') - ) + let datestr = [year, month, day].map(formatNumber).join('-'); + console.log(datestr); + return datestr; } +export const formatTimeStr = (date?: Date) => { + if(!date){ + date = new Date(); + } + const hour = date.getHours(); + const minute = 0; + // return ( + // [year, month, day].map(formatNumber).join('/') + + // ' ' + + // [hour, minute, second].map(formatNumber).join(':') + // ) + let datestr = [hour, minute].map(formatNumber).join(':'); + console.log(datestr); + return datestr; +} // 数字格式化 const formatNumber = (n: number) => { const s = n.toString()