ycl-common/src/main/java/com/ycl/api/BaseEntity.java
New file @@ -0,0 +1,25 @@ package com.ycl.api; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; import java.util.Date; /** * @author Lyq * @version 1.0 * @date 2022/9/7 */ public class BaseEntity { @ApiModelProperty("创建时间") @TableField(fill = FieldFill.INSERT) private Date createTime; /** * 上一次修改时间 */ @ApiModelProperty("修改时间") @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; } ycl-common/src/main/java/com/ycl/api/BasePageVO.java
New file @@ -0,0 +1,23 @@ package com.ycl.api; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import java.io.Serializable; @Data @ApiModel public class BasePageVO implements Serializable { @ApiModelProperty(value = "当前页",example = "1") @Min(value = 1, message = "最小页数1") private int current = 1; @ApiModelProperty(value = "条数",example = "1~100") @Min(value = 1, message = "最小条数1") @Max(value = 100, message = "最大条数100") private int pageSize = 20; } ycl-common/src/main/java/com/ycl/config/MetaObjectConfig.java
New file @@ -0,0 +1,48 @@ package com.ycl.config; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import com.ycl.enums.common.DelType; import com.ycl.utils.common.DateUtil; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.reflection.MetaObject; import org.springframework.context.annotation.Configuration; import java.util.Date; /** * 自动填充 createTime 和 updateTime 数据 * * @author lyq * @since 2022/9/7 */ @Slf4j @Configuration public class MetaObjectConfig implements MetaObjectHandler { /** * 自动插入数据 * * @param metaObject */ @Override public void insertFill(MetaObject metaObject) { log.info("start insert fill ...."); // 起始版本 3.3.0(推荐使用) this.setFieldValByName("createTime", new Date(), metaObject); this.setFieldValByName("updateTime", new Date(), metaObject); this.setFieldValByName("isDeleted", DelType.NORMAL.getCode(), metaObject); } /** * 自动更新数据 * * @param metaObject */ @Override public void updateFill(MetaObject metaObject) { log.info("start update fill ...."); // 起始版本 3.3.0(推荐使用) this.setFieldValByName("updateTime", new Date(), metaObject); } } ycl-common/src/main/java/com/ycl/dto/UmsAdminParam.java
@@ -37,13 +37,14 @@ @ApiModelProperty(value = "备注") private String note; @ApiModelProperty(value = "是否党员,0:否,1:是") @ApiModelProperty(value = "是否党员,0:否,1:是",example = "0") private byte isDy; @ApiModelProperty(value = "职务") private String jobTitle; @ApiModelProperty(value = "部门id") @NotNull(message = "部门不能为空") private Long departmentId; @ApiModelProperty(value = "用户类型") ycl-common/src/main/java/com/ycl/entity/depart/SccgDepart.java
New file @@ -0,0 +1,61 @@ package com.ycl.entity.depart; import com.baomidou.mybatisplus.annotation.*; import com.ycl.api.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; import java.io.Serializable; import java.util.Date; import java.util.List; /** * <p> * 部门表 * </p> * * @author lyq * @since 2022-09-07 */ @Getter @Setter @TableName("sccg_depart") @ApiModel(value = "SccgDepart对象", description = "部门表") public class SccgDepart extends BaseEntity implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty("主键") @TableId(value = "id", type = IdType.AUTO) private Long id; @ApiModelProperty("部门名称") private String departName; @ApiModelProperty("部门描述") private String departDes; @ApiModelProperty("部门类型") private byte departType; @ApiModelProperty("父级id,默认0") private Long parentId; @ApiModelProperty("停用状态,0->false,1->true,默认停用") private byte status; /** * 逻辑删除 0:false 1:true 默认0 */ @ApiModelProperty(value = "是否删除", hidden = true) @TableField(select = false) @TableLogic() private byte isDeleted; @TableField(exist = false) private List<SccgDepart> children; } ycl-common/src/main/java/com/ycl/entity/user/UmsAdmin.java
@@ -1,6 +1,7 @@ package com.ycl.entity.user; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -30,6 +31,7 @@ @TableId(value = "id", type = IdType.AUTO) private Long id; @ApiModelProperty(value = "用户姓名") private String username; private String password; @@ -70,14 +72,15 @@ @ApiModelProperty(value = "部门id") private Long departmentId; @ApiModelProperty(value = "部门名称") @TableField(exist = false) private String departName; @ApiModelProperty(value = "用户类型") private byte userType; @ApiModelProperty(value = "座机/分机") private String zj; @ApiModelProperty(value = "用户名") private String realName; @ApiModelProperty(value = "手机号码") private String mobile; ycl-common/src/main/java/com/ycl/enums/common/DelType.java
New file @@ -0,0 +1,48 @@ package com.ycl.enums.common; /** * 伪删除 * @author lyq * @since 2022-09-07 * @Description */ public enum DelType { /***/ NORMAL((byte) 0, "正常状态"), IS_DEL((byte) 1, "伪删除状态"); private byte code; private String name; DelType(byte code, String name) { this.code = code; this.name = name; } public static String getName(byte code) { for (DelType del : DelType.values()) { if (del.code == code) { return del.name; } } return null; } public byte getCode() { return code; } public void setCode(byte code) { this.code = code; } public String getName() { return name; } public void setName(String name) { this.name = name; } } ycl-common/src/main/java/com/ycl/enums/common/ResultCode.java
@@ -4,13 +4,22 @@ /** * 枚举了一些常用API操作码 * * @author lyq * @since 2022-09-06 */ public enum ResultCode implements IErrorCode { SUCCESS(200, "操作成功"), FAILED(500, "操作失败"), VALIDATE_FAILED(404, "参数检验失败"), UNAUTHORIZED(401, "暂未登录或token已经过期"), FORBIDDEN(403, "没有相关权限"); FORBIDDEN(403, "没有相关权限"), RECORD_ALREADY_EXISTS(2001, "记录已存在"), RECORD_SAVE_FAIL(2002, "记录保存失败"), RECORD_UPDATE_FAIL(2003, "记录更新失败"), RECORD_DELETE_FAIL(2004, "记录删除失败"), RECORD_NOT_EXISTS(2005, "记录不存在"); private long code; private String message; ycl-common/src/main/java/com/ycl/mapper/depart/SccgDepartMapper.java
New file @@ -0,0 +1,16 @@ package com.ycl.mapper.depart; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ycl.entity.depart.SccgDepart; /** * <p> * 部门表 Mapper 接口 * </p> * * @author lyq * @since 2022-09-07 */ public interface SccgDepartMapper extends BaseMapper<SccgDepart> { } ycl-common/src/main/java/com/ycl/service/depart/SccgDepartService.java
New file @@ -0,0 +1,66 @@ package com.ycl.service.depart; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.ycl.entity.depart.SccgDepart; import com.ycl.vo.depart.DepartVO; import org.apache.catalina.LifecycleState; import java.util.List; /** * <p> * 部门表 服务类 * </p> * * @author lyq * @since 2022-09-07 */ public interface SccgDepartService extends IService<SccgDepart> { /** * 新增 * * @param addDepartVO */ void create(DepartVO.AddDepartVO addDepartVO); /** * 详情 * * @param id * @return */ SccgDepart loadDepartById(long id); /** * 修改 * * @param updateDepartVO */ void update(DepartVO.UpdateDepartVO updateDepartVO); /** * 删除 * @param id */ void delete(long id); /** * 树形 * @return */ List<SccgDepart> tree(); /** * 分页 * @param params * @return */ IPage<SccgDepart> pageDepart(DepartVO.PageDepartVO params); /** * 修改状态 * @param params */ void updateStatus(DepartVO.StatusDepartVO params); } ycl-common/src/main/java/com/ycl/service/depart/impl/SccgDepartServiceImpl.java
New file @@ -0,0 +1,159 @@ package com.ycl.service.depart.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.api.CommonResult; import com.ycl.entity.depart.SccgDepart; import com.ycl.enums.common.ResultCode; import com.ycl.exception.ApiException; import com.ycl.mapper.depart.SccgDepartMapper; import com.ycl.service.depart.SccgDepartService; import com.ycl.vo.depart.DepartVO; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.xml.transform.Result; import java.util.List; import java.util.stream.Collectors; /** * <p> * 部门表 服务实现类 * </p> * * @author lyq * @since 2022-09-07 */ @Service public class SccgDepartServiceImpl extends ServiceImpl<SccgDepartMapper, SccgDepart> implements SccgDepartService { @Resource private SccgDepartMapper sccgDepartMapper; @Override @Transactional(rollbackFor = Exception.class) public void create(DepartVO.AddDepartVO addDepartVO) { SccgDepart sccgDepart = this.queryByName(addDepartVO.getDepartName()); if (null != sccgDepart) { throw new ApiException(ResultCode.RECORD_ALREADY_EXISTS); } SccgDepart depart = new SccgDepart(); BeanUtils.copyProperties(addDepartVO, depart); if (sccgDepartMapper.insert(depart) <= 0) { throw new ApiException(ResultCode.RECORD_SAVE_FAIL); } } @Override public SccgDepart loadDepartById(long id) { SccgDepart sccgDepart = sccgDepartMapper.selectById(id); if (null == sccgDepart) { throw new ApiException(ResultCode.RECORD_NOT_EXISTS); } return sccgDepart; } @Override @Transactional(rollbackFor = Exception.class) public void update(DepartVO.UpdateDepartVO updateDepartVO) { SccgDepart sccgDepart = this.queryByName(updateDepartVO.getDepartName()); if (null != sccgDepart && sccgDepart.getId() != updateDepartVO.getId()) { throw new ApiException(ResultCode.RECORD_ALREADY_EXISTS); } BeanUtils.copyProperties(updateDepartVO, sccgDepart); if (sccgDepartMapper.updateById(sccgDepart) <= 0) { throw new ApiException(ResultCode.RECORD_UPDATE_FAIL); } } @Override public void delete(long id) { if (sccgDepartMapper.deleteById(id) <= 0) { throw new ApiException(ResultCode.RECORD_DELETE_FAIL); } } @Override public List<SccgDepart> tree() { // 1.查出所有网格 List<SccgDepart> list = list(); // 2.组装成父子的树型结构 // 2.1、找到所有的一级网格:使用jdk8的stream流进行过滤 List<SccgDepart> collect = list.stream().filter(griddingEntity -> { //分类父id为0就表示该网格为 一级网格 return griddingEntity.getParentId() == 0; }).map(item -> { // 找到子网格 set进children属性中 item.setChildren(getChildrens(item, list)); return item; }).collect(Collectors.toList()); List<SccgDepart> treeData = getTreeData(collect); return treeData; } @Override public IPage<SccgDepart> pageDepart(DepartVO.PageDepartVO params) { return null; } @Override public void updateStatus(DepartVO.StatusDepartVO params) { SccgDepart sccgDepart = this.loadDepartById(params.getId()); BeanUtils.copyProperties(params, sccgDepart); if (sccgDepartMapper.updateById(sccgDepart) <= 0) { throw new ApiException(ResultCode.RECORD_UPDATE_FAIL); } } /** * 利用递归将最后一级空集合变为null,前端联级选择器最后才不会出现 暂无数据的bug * * @return */ public List<SccgDepart> getTreeData(List<SccgDepart> griddingEntities) { for (int i = 0; i < griddingEntities.size(); i++) { //如果Children的size小于1就说明为空,设置为null if (griddingEntities.get(i).getChildren().size() < 1) { griddingEntities.get(i).setChildren(null); } else { //子网格有数据就递归 getTreeData(griddingEntities.get(i).getChildren()); } } return griddingEntities; } /** * 递归查找所有网格的子网格 * * @param root 当前网格 * @param all 所有网格 * @return */ public List<SccgDepart> getChildrens(SccgDepart root, List<SccgDepart> all) { List<SccgDepart> collect = all.stream().filter(griddingEntity -> { return griddingEntity.getParentId().equals(root.getId()); }).map(item -> { item.setChildren(getChildrens(item, all)); return item; }).collect(Collectors.toList()); return collect; } /** * 根据名字查询 * * @param name * @return */ private SccgDepart queryByName(String name) { LambdaQueryWrapper<SccgDepart> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(SccgDepart::getDepartName, name); SccgDepart sccgDepart = this.sccgDepartMapper.selectOne(queryWrapper); return sccgDepart; } } ycl-common/src/main/java/com/ycl/service/user/UmsAdminService.java
@@ -1,5 +1,6 @@ package com.ycl.service.user; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.ycl.dto.UmsAdminParam; @@ -7,6 +8,7 @@ import com.ycl.entity.user.UmsAdmin; import com.ycl.entity.user.UmsResource; import com.ycl.entity.user.UmsRole; import com.ycl.vo.user.UserVO; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.transaction.annotation.Transactional; @@ -86,4 +88,11 @@ * 获取缓存服务 */ UmsAdminCacheService getCacheService(); /** * 分页 * @param pageUserVO * @return */ IPage<UmsAdmin> pageUser(UserVO.PageUserVO pageUserVO); } ycl-common/src/main/java/com/ycl/service/user/impl/UmsAdminServiceImpl.java
@@ -4,22 +4,30 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.bo.AdminUserDetails; import com.ycl.dto.UmsAdminParam; import com.ycl.dto.UpdateAdminPasswordParam; import com.ycl.entity.depart.SccgDepart; import com.ycl.entity.user.*; import com.ycl.exception.Asserts; import com.ycl.mapper.user.UmsAdminLoginLogMapper; import com.ycl.mapper.user.UmsAdminMapper; import com.ycl.mapper.user.UmsResourceMapper; import com.ycl.mapper.user.UmsRoleMapper; import com.ycl.service.depart.SccgDepartService; import com.ycl.service.user.UmsAdminCacheService; import com.ycl.service.user.UmsAdminRoleRelationService; import com.ycl.service.user.UmsAdminService; import com.ycl.utils.JwtTokenUtil; import com.ycl.utils.SpringUtil; import com.ycl.utils.common.MacUtils; import com.ycl.utils.common.PojoUtils; import com.ycl.utils.common.RandomUtils; import com.ycl.vo.user.UserVO; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -31,6 +39,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -60,13 +69,15 @@ private UmsRoleMapper umsRoleMapper; @Resource private UmsResourceMapper umsResourceMapper; @Resource private SccgDepartService sccgDepartService; @Override public UmsAdmin getAdminByUsername(String username) { UmsAdmin admin = getCacheService().getAdmin(username); if(admin!=null) return admin; if (admin != null) return admin; QueryWrapper<UmsAdmin> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UmsAdmin::getUsername,username); wrapper.lambda().eq(UmsAdmin::getUsername, username); List<UmsAdmin> adminList = list(wrapper); if (adminList != null && adminList.size() > 0) { admin = adminList.get(0); @@ -77,15 +88,17 @@ } @Override @Transactional(rollbackFor = Exception.class) public UmsAdmin register(UmsAdminParam umsAdminParam) { UmsAdmin umsAdmin = new UmsAdmin(); //TODO mac,ip,职务,用户类型 BeanUtils.copyProperties(umsAdminParam, umsAdmin); umsAdmin.setCreateTime(new Date()); umsAdmin.setStatus(1); umsAdmin.setMacAddress(MacUtils.getMac()); //查询是否有相同用户名的用户 QueryWrapper<UmsAdmin> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UmsAdmin::getUsername,umsAdmin.getUsername()); wrapper.lambda().eq(UmsAdmin::getUsername, umsAdmin.getUsername()); List<UmsAdmin> umsAdminList = list(wrapper); if (umsAdminList.size() > 0) { return null; @@ -94,6 +107,8 @@ String encodePassword = passwordEncoder.encode(umsAdmin.getPassword()); umsAdmin.setPassword(encodePassword); baseMapper.insert(umsAdmin); umsAdmin.setNickName(RandomUtils.getUserId(umsAdmin.getId())); baseMapper.updateById(umsAdmin); return umsAdmin; } @@ -103,10 +118,10 @@ //密码需要客户端加密后传递 try { UserDetails userDetails = loadUserByUsername(username); if(!passwordEncoder.matches(password,userDetails.getPassword())){ if (!passwordEncoder.matches(password, userDetails.getPassword())) { Asserts.fail("密码不正确"); } if(!userDetails.isEnabled()){ if (!userDetails.isEnabled()) { Asserts.fail("帐号已被禁用"); } UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); @@ -122,11 +137,12 @@ /** * 添加登录记录 * * @param username 用户名 */ private void insertLoginLog(String username) { UmsAdmin admin = getAdminByUsername(username); if(admin==null) return; if (admin == null) return; UmsAdminLoginLog loginLog = new UmsAdminLoginLog(); loginLog.setAdminId(admin.getId()); loginLog.setCreateTime(new Date()); @@ -143,8 +159,8 @@ UmsAdmin record = new UmsAdmin(); record.setLoginTime(new Date()); QueryWrapper<UmsAdmin> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UmsAdmin::getUsername,username); update(record,wrapper); wrapper.lambda().eq(UmsAdmin::getUsername, username); update(record, wrapper); } @Override @@ -154,28 +170,28 @@ @Override public Page<UmsAdmin> list(String keyword, Integer pageSize, Integer pageNum) { Page<UmsAdmin> page = new Page<>(pageNum,pageSize); Page<UmsAdmin> page = new Page<>(pageNum, pageSize); QueryWrapper<UmsAdmin> wrapper = new QueryWrapper<>(); LambdaQueryWrapper<UmsAdmin> lambda = wrapper.lambda(); if(StrUtil.isNotEmpty(keyword)){ lambda.like(UmsAdmin::getUsername,keyword); lambda.or().like(UmsAdmin::getNickName,keyword); if (StrUtil.isNotEmpty(keyword)) { lambda.like(UmsAdmin::getUsername, keyword); lambda.or().like(UmsAdmin::getNickName, keyword); } return page(page,wrapper); return page(page, wrapper); } @Override public boolean update(Long id, UmsAdmin admin) { admin.setId(id); UmsAdmin rawAdmin = getById(id); if(rawAdmin.getPassword().equals(admin.getPassword())){ if (rawAdmin.getPassword().equals(admin.getPassword())) { //与原加密密码相同的不需要修改 admin.setPassword(null); }else{ } else { //与原加密密码不同的需要加密修改 if(StrUtil.isEmpty(admin.getPassword())){ if (StrUtil.isEmpty(admin.getPassword())) { admin.setPassword(null); }else{ } else { admin.setPassword(passwordEncoder.encode(admin.getPassword())); } } @@ -197,7 +213,7 @@ int count = roleIds == null ? 0 : roleIds.size(); //先删除原来的关系 QueryWrapper<UmsAdminRoleRelation> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UmsAdminRoleRelation::getAdminId,adminId); wrapper.lambda().eq(UmsAdminRoleRelation::getAdminId, adminId); umsAdminRoleRelationService.remove(wrapper); //建立新关系 if (!CollectionUtils.isEmpty(roleIds)) { @@ -222,31 +238,31 @@ @Override public List<UmsResource> getResourceList(Long adminId) { List<UmsResource> resourceList = getCacheService().getResourceList(adminId); if(CollUtil.isNotEmpty(resourceList)){ return resourceList; if (CollUtil.isNotEmpty(resourceList)) { return resourceList; } resourceList = umsResourceMapper.getResourceList(adminId); if(CollUtil.isNotEmpty(resourceList)){ getCacheService().setResourceList(adminId,resourceList); if (CollUtil.isNotEmpty(resourceList)) { getCacheService().setResourceList(adminId, resourceList); } return resourceList; } @Override public int updatePassword(UpdateAdminPasswordParam param) { if(StrUtil.isEmpty(param.getUsername()) ||StrUtil.isEmpty(param.getOldPassword()) ||StrUtil.isEmpty(param.getNewPassword())){ if (StrUtil.isEmpty(param.getUsername()) || StrUtil.isEmpty(param.getOldPassword()) || StrUtil.isEmpty(param.getNewPassword())) { return -1; } QueryWrapper<UmsAdmin> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UmsAdmin::getUsername,param.getUsername()); wrapper.lambda().eq(UmsAdmin::getUsername, param.getUsername()); List<UmsAdmin> adminList = list(wrapper); if(CollUtil.isEmpty(adminList)){ if (CollUtil.isEmpty(adminList)) { return -2; } UmsAdmin umsAdmin = adminList.get(0); if(!passwordEncoder.matches(param.getOldPassword(),umsAdmin.getPassword())){ if (!passwordEncoder.matches(param.getOldPassword(), umsAdmin.getPassword())) { return -3; } umsAdmin.setPassword(passwordEncoder.encode(param.getNewPassword())); @@ -256,12 +272,12 @@ } @Override public UserDetails loadUserByUsername(String username){ public UserDetails loadUserByUsername(String username) { //获取用户信息 UmsAdmin admin = getAdminByUsername(username); if (admin != null) { List<UmsResource> resourceList = getResourceList(admin.getId()); return new AdminUserDetails(admin,resourceList); return new AdminUserDetails(admin, resourceList); } throw new UsernameNotFoundException("用户名或密码错误"); } @@ -270,4 +286,32 @@ public UmsAdminCacheService getCacheService() { return SpringUtil.getBean(UmsAdminCacheService.class); } @Override public IPage<UmsAdmin> pageUser(UserVO.PageUserVO pageUserVO) { int pageSize = pageUserVO.getPageSize(); int current = pageUserVO.getCurrent(); Page<UmsAdmin> page = new Page<>(current, pageSize); LambdaQueryWrapper<UmsAdmin> queryWrapper = new LambdaQueryWrapper<>(); if (StringUtils.isNotBlank(pageUserVO.getJobTitle())) { queryWrapper.eq(UmsAdmin::getJobTitle, pageUserVO.getJobTitle()); } if (PojoUtils.Vo.isUsefulSearchParam(pageUserVO.getUserType())) { queryWrapper.eq(UmsAdmin::getUserType, pageUserVO.getUserType()); } if (PojoUtils.Vo.isUsefulSearchParam(pageUserVO.getDepartmentId())) { queryWrapper.eq(UmsAdmin::getDepartmentId, pageUserVO.getDepartmentId()); } Page<UmsAdmin> page1 = baseMapper.selectPage(page, queryWrapper); List<UmsAdmin> records = page1.getRecords(); if (CollUtil.isNotEmpty(records)) { records.forEach(e -> { SccgDepart sccgDepart = sccgDepartService.getById(e.getDepartmentId()); if (null != sccgDepart) { e.setDepartName(sccgDepart.getDepartName()); } }); } return page1; } } ycl-common/src/main/java/com/ycl/utils/common/DatePattern.java
New file @@ -0,0 +1,30 @@ package com.ycl.utils.common; /** * 常用日期格式 */ public enum DatePattern { /** yyyy-MM */ YYYY_MM("yyyyMM"), YYYY_MM_DD("yyyy-MM-dd"), YYMMDD("yyMMdd"), /**YYYYMMDD*/ YYYYMMDD("yyyyMMdd"), /** yyyy-MM-dd HH:mm */ YYYY_MM_DD_HHmm("yyyy-MM-dd HH:mm"), /** yyyy-MM-dd HH:mm:ss */ YYYY_MM_DD_HHmmss("yyyy-MM-dd HH:mm:ss"), /** yyyy-MM-dd HH:mm:sss */ YYYY_MM_DD_HHmmsss("yyyy-MM-dd HH:mm:sss"), /** yyyyMMddHHmmss */ YYYYMMDDHHmmss("yyyyMMddHHmmss"); public String pattern; DatePattern(String pattern) { this.pattern = pattern; } } ycl-common/src/main/java/com/ycl/utils/common/DateUtil.java
New file @@ -0,0 +1,1389 @@ package com.ycl.utils.common; import com.ycl.api.CommonResult; import com.ycl.exception.ApiException; import io.netty.util.internal.StringUtil; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.Instant; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneId; import java.util.Calendar; import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.prefs.BackingStoreException; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * 时间工具 */ public final class DateUtil { private static final Logger LOGGER = LoggerFactory.getLogger(DateUtil.class); /** * 日期时分秒 */ public static final String SF = "\\d{4}-\\d{1,2}-\\d{1,2}\\s\\d{2}:\\d{2}:\\d{2}"; /** * 日期时分 */ public static final String SFM = "\\d{4}-\\d{1,2}-\\d{1,2}\\s\\d{2}:\\d{2}"; //ThreadDateUtil /** * yyyy-MM-dd */ public static final String sf1 = "yyyy-MM-dd"; // new SimpleDateFormat(""); /** * yyyy-MM-dd HH:mm */ public static final String sfm = "yyyy-MM-dd HH:mm"; //new SimpleDateFormat(""); /** * yyyy-MM-dd HH:mm:ss */ public static final String sf = "yyyy-MM-dd HH:mm:ss"; /** * yyyyMMdd 用于带日期的SN生成 */ public static final String sfPreSn = "yyyyMMdd"; /** * HH:mm:ss */ public static final String sfH = "HH:mm:ss"; /** * HH:mm */ public static final String sf2 = "HH:mm"; public DateUtil() { } public static String getNow() { return ThreadDateUtil.getDateFormat(sf).format(new Date()); } public static String getNowDate() { return ThreadDateUtil.getDateFormat(sf1).format(new Date()); } public static String getNowDateForPreSn() { return ThreadDateUtil.getDateFormat(sfPreSn).format(new Date()); } /** * 根据时间类型比较时间大小 * * @param source * @param traget * @param "YYYY-MM-DD" "yyyyMMdd HH:mm:ss" 类型可自定义 * @param * @return 0 :source和traget时间相同 * 1 :source比traget时间大 * -1:source比traget时间小 * @throws Exception */ public static int DateCompare(long source, long traget) throws Exception { if (source == traget) return 0; else if (source > traget) { return 1; } else { return -1; } } /** * 方法名: getTime * 方法描述: 获取当前时间时分 * 修改时间:2016年12月2日 上午10:12:46 * 参数 @return 参数说明 * 返回类型 String 返回类型 */ public static String getTime(long time) { return ThreadDateUtil.getDateFormat("HH:mm").format(time); } /** * 方法名: getTime * 方法描述: 获取当前时间时分 * 修改时间:2016年12月2日 上午10:12:46 * 参数 @return 参数说明 * 返回类型 String 返回类型 */ public static String getTime() { return ThreadDateUtil.getDateFormat("HH:mm").format(getNowTime()); } /** * 方法名: getEndTime * 方法描述: (这里用一句话描述这个方法的作用) * 修改时间:2016年11月24日 下午9:17:18 * 参数 @param date * 参数 @return 参数说明 * 返回类型 Date 返回类型 */ public static Date getEndTime(Date date) { if (date == null) { return null; } Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MILLISECOND, 999); return calendar.getTime(); } public static void main(String[] args) throws ParseException { String date = "2021-08"; System.out.println(getDate(date)); } /** * 方法名: getDate * 方法描述: 将long型的时间 字符串 转换为yyyy-MM-dd格式的日期字符串 * 修改时间:2017年6月19日 下午3:24:45 * 参数 @param str * 参数 @return 参数说明 * 返回类型 String 返回类型 */ public static String getDate(String str) { Date d = new Date(parseLong(str)); return ThreadDateUtil.getDateFormat(sf1).format(d); } /** * 将字符串类型转换为整型 * * @param s * @return */ public static Long parseLong(String s) { if (s != null && s.trim().matches("^(-)?[0-9]+$")) return Long.parseLong(s.trim()); return 0L; } public static Date getSfDate(String str) { Date date; try { if (str.matches(SF)) { date = ThreadDateUtil.getDateFormat(sf).parse(str); } else if (str.matches(SFM)) { date = ThreadDateUtil.getDateFormat(sfm).parse(str); } else date = ThreadDateUtil.getDateFormat(sf1).parse(str); return date; } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } /** * 方法名: getDate * 方法描述: long 转date * 修改时间:2017年6月13日 上午10:50:34 * 参数 @param dateTime * 参数 @return 参数说明 * 返回类型 Date 返回类型 */ public static Date getDate(long dateTime) { String date = getDateTime(dateTime); Date d = null; try { d = ThreadDateUtil.getDateFormat(sf).parse(date); return d; } catch (ParseException e) { e.printStackTrace(); } return null; } /** * 方法名: getDateByLong * 方法描述: long 转成String YYYY-MM-dd * 修改时间:2017年6月13日 上午11:41:43 * 参数 @param dateTime * 参数 @return 参数说明 * 返回类型 String 返回类型 * * @return */ public static String getDateByLong(long dateTime) { Date date = getDate(dateTime); return ThreadDateUtil.getDateFormat(sf1).format(date); } public static String getDateTime(Long date) { if (null == date) { return ""; } try { Date d = new Date(date); return ThreadDateUtil.getDateFormat(sf).format(d); } catch (Exception e) { LOGGER.error(" getTime E: {}", date, e); } return ""; } public static String getTime(Long date) { if (null == date) { return ""; } try { Date d = new Date(date); return ThreadDateUtil.getDateFormat(sf).format(d); } catch (Exception e) { LOGGER.error(" getTime E: {}", date, e); } return ""; } /** * 方法名: getStartTime * 方法描述: 获取当前0点 * 修改时间:2017年5月8日 下午5:03:49 * 参数 @return 参数说明 * 返回类型 Long 返回类型 */ public static long getStartTime() { Calendar todayStart = Calendar.getInstance(); todayStart.set(Calendar.HOUR_OF_DAY, 0); todayStart.set(Calendar.MINUTE, 0); todayStart.set(Calendar.SECOND, 0); todayStart.set(Calendar.MILLISECOND, 0); return todayStart.getTime().getTime(); } /** * 方法名: getEndTime * 方法描述: 获取当天结束时间 * 修改时间:2017年5月8日 下午5:04:12 * 参数 @return 参数说明 * 返回类型 long 返回类型 */ public static long getEndTime() { Calendar todayEnd = Calendar.getInstance(); todayEnd.set(Calendar.HOUR_OF_DAY, 23); todayEnd.set(Calendar.MINUTE, 59); todayEnd.set(Calendar.SECOND, 59); todayEnd.set(Calendar.MILLISECOND, 999); return todayEnd.getTime().getTime(); } /** * 获取某天最大时间 * * @param date * @return */ public static Date getEndOfDay(Date date) { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), ZoneId.systemDefault()); ; LocalDateTime endOfDay = localDateTime.with(LocalTime.MAX); return Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant()); } /** * 获取某天最小时间 * * @param date * @return */ public static Date getStartOfDay(Date date) { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), ZoneId.systemDefault()); LocalDateTime startOfDay = localDateTime.with(LocalTime.MIN); return Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant()); } /** * 方法名: getStartTime * 方法描述: 获取当前0点 * 修改时间:2017年5月8日 下午5:03:49 * 参数 @return 参数说明 * 返回类型 Long 返回类型 * * @throws ParseException */ public static long getStartTime(String dateStr) throws ParseException { if (StringUtils.isBlank(dateStr)) { return 0; } else { Date date = ThreadDateUtil.getDateFormat(sf1).parse(dateStr); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime().getTime(); } } /** * 方法名: getEndTime * 方法描述: 获取当天结束时间 * 修改时间:2017年5月8日 下午5:04:12 * 参数 @return 参数说明 * 返回类型 long 返回类型 * * @throws ParseException */ public static long getEndTime(String dateStr) throws ParseException { if (StringUtils.isBlank(dateStr)) { return 0; } else { Date date = ThreadDateUtil.getDateFormat(sf1).parse(dateStr); Calendar todayEnd = Calendar.getInstance(); todayEnd.setTime(date); todayEnd.set(Calendar.HOUR_OF_DAY, 23); todayEnd.set(Calendar.MINUTE, 59); todayEnd.set(Calendar.SECOND, 59); todayEnd.set(Calendar.MILLISECOND, 999); return todayEnd.getTime().getTime(); } } /** * 获取 指定时间毫秒数的0点 * * @param time * @return */ public static long getStartTime(long time) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime().getTime(); } /** * 获取 指定时间毫秒数的23点59分59秒999毫秒 * * @param time * @return */ public static long getEndTime(long time) { Calendar todayEnd = Calendar.getInstance(); todayEnd.setTimeInMillis(time); todayEnd.set(Calendar.HOUR_OF_DAY, 23); todayEnd.set(Calendar.MINUTE, 59); todayEnd.set(Calendar.SECOND, 59); todayEnd.set(Calendar.MILLISECOND, 999); return todayEnd.getTime().getTime(); } public static String getDatem(Long date) { try { Date d = new Date(date); return ThreadDateUtil.getDateFormat(sfm).format(d); } catch (Exception e) { LOGGER.error(" getDatem E: {}", date, e); } return ""; } public static Long getNowTime() { return System.currentTimeMillis(); } /** * 方法名: getTodayEndTime * 方法描述: 获取当天结束时间 * 修改时间:2016年11月2日 下午6:53:23 * 参数 @return 参数说明 * 返回类型 Long 返回类型 */ public static int getDiffTodayEndTime() { return (int) ((getTodayEndTime() - getNowTime()) / 1000); } /** * 方法名: getStartDateTime * 方法描述: 获取一天开始time * 修改时间:2016年12月5日 上午11:57:01 * 参数 @param time * 参数 @return 参数说明 * 返回类型 String 返回类型 */ public static String getStartDateTime(long time) { Date d = new Date(time); return ThreadDateUtil.getDateFormat(sf).format(d); } /** * 方法名: getTodayEndTime * 方法描述: 获取当天时间差 * 修改时间:2016年11月2日 下午6:53:23 * 参数 @return 参数说明 * 返回类型 Long 返回类型 */ public static Long getTodayEndTime() { Calendar todayEnd = Calendar.getInstance(); todayEnd.set(Calendar.HOUR_OF_DAY, 23); todayEnd.set(Calendar.MINUTE, 59); todayEnd.set(Calendar.SECOND, 59); todayEnd.set(Calendar.MILLISECOND, 999); return todayEnd.getTime().getTime(); } /** * 获取参数时间的开始时间 * * @param time * @return */ public static Date getBeginTimeByDate(long time) { Date d = new Date(time); Calendar todayBegin = Calendar.getInstance(); todayBegin.setTime(d); todayBegin.set(Calendar.HOUR_OF_DAY, 00); todayBegin.set(Calendar.MINUTE, 00); todayBegin.set(Calendar.SECOND, 00); todayBegin.set(Calendar.MILLISECOND, 000); return todayBegin.getTime(); } /** * 获取参数时间的结束时间 * * @param time * @return */ public static Date getEndTimeByDate(long time) { Date d = new Date(time); Calendar todayBegin = Calendar.getInstance(); todayBegin.setTime(d); todayBegin.set(Calendar.HOUR_OF_DAY, 23); todayBegin.set(Calendar.MINUTE, 59); todayBegin.set(Calendar.SECOND, 59); todayBegin.set(Calendar.MILLISECOND, 999); return todayBegin.getTime(); } /** * 判断当前时间是否在[startTime, endTime]区间,注意时间格式要一致 * * @param nowTime 当前时间 * @param startTime 开始时间 * @param endTime 结束时间 * @return */ public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) { if (nowTime.getTime() == startTime.getTime() || nowTime.getTime() == endTime.getTime()) { return true; } Calendar date = Calendar.getInstance(); date.setTime(nowTime); Calendar begin = Calendar.getInstance(); begin.setTime(startTime); Calendar end = Calendar.getInstance(); end.setTime(endTime); if (date.after(begin) && date.before(end)) { return true; } else { return false; } } public static Long getLongTime(String str) { if (StringUtils.isBlank(str)) { return getNowTime(); } Date date = null; try { if (str.matches(SF)) { date = ThreadDateUtil.getDateFormat(sf).parse(str); } else if (str.matches(SFM)) { date = ThreadDateUtil.getDateFormat(sfm).parse(str); } else { date = ThreadDateUtil.getDateFormat(sf1).parse(str); } } catch (ParseException e) { LOGGER.error(" getLongTime E: {}", str, e); } if (null == date) { return 0L; } return date.getTime(); } /** * 把时间参数 转换为 long * * @param dateStr * @return * @throws BackingStoreException */ public static long getTime(String dateStr) throws ApiException { try { Date date = ThreadDateUtil.getDateFormat(sf).parse(dateStr); return date.getTime(); } catch (ParseException e) { LOGGER.error(" getTime E: {}", dateStr, e); throw new ApiException(" time parese error: " + dateStr); } } /** * 把时间参数 转换为 long * * @param dateStr yyyy-MM-dd * @return * @throws BackingStoreException */ public static long getTimeByStringDate(String dateStr) throws ApiException { try { Date date = ThreadDateUtil.getDateFormat(sf1).parse(dateStr); return date.getTime(); } catch (ParseException e) { LOGGER.error(" getTime E: {}", dateStr, e); throw new ApiException(" time parese error: " + dateStr); } } /** * 方法名: getNowYear * 方法描述: 获取当前年份 * 修改时间:2016年6月22日 下午6:52:24 * 参数 @return 参数说明 * 返回类型 String 返回类型 */ public static String getNowYear() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); Date date = new Date(); return sdf.format(date); } /** * 方法名: getNowMonth * 方法描述: 获取当前年月yyyy/MM * 修改时间:2016年6月22日 下午6:52:24 * 参数 @return 参数说明 * 返回类型 String 返回类型 */ public static String getNowMonth() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM"); Date date = new Date(); return sdf.format(date); } /** * 方法名: getNowMonthDaySn * 方法描述: 获取当前年月yyyyMMdd * 修改时间:2017年6月28日 上午10:52:24 * 参数 @return 参数说明 * 返回类型 String 返回类型 */ public static String getNowMonthDay() { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); Date date = new Date(); return sdf.format(date); } /** * 获取明天的日期字符串 * * @return */ public static String tomorrowDateStr(int day) { Date date = new Date();//取时间 Calendar calendar = Calendar.getInstance(); calendar.setTime(date); //把日期往后增加一天.整数往后推,负数往前移动 calendar.add(calendar.DATE, day); //这个时间就是日期往后推一天的结果 date = calendar.getTime(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String tomorrowStr = formatter.format(date); return tomorrowStr; } /** * dq * 获取指定年月yyyyMMddHHmmss * * @param dateTime * @return */ public static String getNowMonthDay(long dateTime) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); Date date = new Date(dateTime); return sdf.format(date); } public static String getAge(String birthDate) { if (null == birthDate) { throw new RuntimeException("出生日期不能为null"); } int age = 0; String[] str = birthDate.split("-"); if (str.length == 3) { Date now = new Date(); SimpleDateFormat format_y = new SimpleDateFormat("yyyy"); SimpleDateFormat format_M = new SimpleDateFormat("MM"); String birth_year = str[0]; String this_year = format_y.format(now); String birth_month = str[1]; String this_month = format_M.format(now); // 初步,估算 age = Integer.parseInt(this_year) - Integer.parseInt(birth_year); // 如果未到出生月份,则age - 1 if (this_month.compareTo(birth_month) < 0) { age -= 1; } if (age < 0) { age = 0; } return age + "." + (parseInt(this_month) - parseInt(this_month)); } return "0"; } /** * 将字符串类型转换为整型 * * @param s * @return */ public static Integer parseInt(String s) { if (s != null && s.trim().matches("^(-)?[0-9]+$")) return Integer.parseInt(s.trim()); return 0; } /** * 查询前一天 * * @param date * @return */ public static String getPreDay(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.DAY_OF_MONTH, -1); date = calendar.getTime(); return ThreadDateUtil.getDateFormat(sf1).format(date); } /** * 方法名: isBirthday * 方法描述: 判断输入的字符串是否是合法的生日 生日不能大于当前日期 * 修改时间:2017年3月22日 上午9:16:09 * 参数 @param birthday * 参数 @return 参数说明 * 返回类型 boolean 返回类型 */ public static boolean isBirthday(String birthday) { if (StringUtils.isBlank(birthday)) { return false; } if (birthday.length() != 10) { return false; } Pattern pattern = Pattern .compile("^[1,2]\\d{3}(-){1}(0[1-9]||1[0-2])(-){1}(0[1-9]||[1,2][0-9]||3[0,1])$"); Matcher matcher = pattern.matcher(birthday); if (!matcher.matches()) { return false; } Date birth = null; try { birth = new SimpleDateFormat("yyyy-MM-dd").parse(birthday); } catch (ParseException e) { e.printStackTrace(); } if (!new SimpleDateFormat("yyyy-MM-dd").format(birth).equals(birthday)) { return false; } // 获取当前日期的毫秒数 long currentTime = System.currentTimeMillis(); // 获取生日的毫秒数 long birthTime = birth.getTime(); // 如果当前时间小于生日,生日不合法。反之合法 if (birthTime > currentTime) { return false; } return true; } /** * 方法名: isAfterHour * 方法描述: 当前时间7点之后可以显示 * 修改时间:2017年5月11日 下午3:39:34 * 参数 @return 参数说明 * 返回类型 boolean 返回类型 */ public static boolean isAfterHour() { Calendar todayStart = Calendar.getInstance(); //用d.getHour()可以获取当前小时数。 int hour = todayStart.get(Calendar.HOUR_OF_DAY); return hour >= 7; } /** * wye * 获取某天开始时间0:0:0:0 * * @param date * @param addDay * @return */ public static long getStartTime(Date date, int addDay) { Calendar dayTimeStart = Calendar.getInstance(); dayTimeStart.setTime(date); if (addDay != 0) { dayTimeStart.add(Calendar.DATE, addDay); } dayTimeStart.set(Calendar.HOUR_OF_DAY, 0); dayTimeStart.set(Calendar.MINUTE, 0); dayTimeStart.set(Calendar.SECOND, 0); dayTimeStart.set(Calendar.MILLISECOND, 0); return dayTimeStart.getTime().getTime(); } /** * wye * 获取某天结束时间23:59:59:999 * * @param date * @param addDay * @return */ public static long getEndTime(Date date, int addDay) { Calendar dayTimeEnd = Calendar.getInstance(); dayTimeEnd.setTime(date); if (addDay != 0) { dayTimeEnd.add(Calendar.DATE, addDay); } dayTimeEnd.set(Calendar.HOUR_OF_DAY, 23); dayTimeEnd.set(Calendar.MINUTE, 59); dayTimeEnd.set(Calendar.SECOND, 59); dayTimeEnd.set(Calendar.MILLISECOND, 999); return dayTimeEnd.getTime().getTime(); } /** * wye * 获取当前时间 之后或之前的几天 * * @param * @return * @throws ParseException */ public static long getLongTimeByDay(long dateTime, int day) { Calendar start = Calendar.getInstance(); start.setTimeInMillis(dateTime); start.add(Calendar.DAY_OF_MONTH, day); return start.getTime().getTime(); } /** * 日期格式化字符串 * 默认格式 yyyy-MM-dd HH:mm:ss */ public static String format(Date date) { if (date == null) { return null; } return format(date, DatePattern.YYYY_MM_DD_HHmmss); } /** * 日期格式化字符串 */ public static String format(Date date, DatePattern datePattern) { if (date == null || datePattern == null) { return null; } return format(date, datePattern.pattern); } /** * 日期格式化字符串 * * @param date 日期对象 * @param pattern 日期格式 * @return */ public static String format(Date date, String pattern) { if (date == null) { return null; } return ThreadDateUtil.getDateFormat(pattern).format(date); } /** * 日期字符串 转换为日期 * 默认格式 yyyy-MM-dd HH:mm:ss * * @throws ParseException */ public static Date parse(String source) throws ParseException { return parse(source, DatePattern.YYYY_MM_DD_HHmmss); } /** * 日期格式化字符串 * * @param source 时间字符串 * @param datePattern 日期格式 * @return * @throws ParseException */ public static Date parse(String source, DatePattern datePattern) throws ParseException { return parse(source, datePattern.pattern); } /** * 日期字符串 转换为日期 * * @param source 时间字符串 * @param pattern 日期格式 * @return * @throws ParseException */ public static Date parse(String source, String pattern) throws ParseException { return ThreadDateUtil.getDateFormat(pattern).parse(source); } /** * 日期字符串 转换为日期毫秒数 * 默认格式 yyyy-MM-dd HH:mm:ss * * @throws ParseException */ public static Long parseToLong(String source) throws ParseException { return parse(source, DatePattern.YYYY_MM_DD_HHmmss).getTime(); } /** * 日期字符串 转换为日期毫秒数 * * @param source 时间字符串 * @param datePattern 日期格式 * @return * @throws ParseException */ public static Long parseToLong(String source, DatePattern datePattern) throws ParseException { return parse(source, datePattern.pattern).getTime(); } /** * 日期字符串 转换为日期毫秒数 * * @param source 时间字符串 * @param pattern 日期格式 * @return * @throws ParseException */ public static Long parseToLong(String source, String pattern) throws ParseException { return ThreadDateUtil.getDateFormat(pattern).parse(source).getTime(); } /** * 获取日期年份 * * @param date 日期 * @return */ public static String getYear(Date date) { return format(date).substring(0, 4); } /** * 功能描述:返回月 * * @param date Date 日期 * @return 返回月份 */ public static int getMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar.get(Calendar.MONTH) + 1; } /** * 功能描述:返回日 * * @param date Date 日期 * @return 返回日份 */ public static int getDay(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar.get(Calendar.DAY_OF_MONTH); } /** * 功能描述:返回小 * * @param date 日期 * @return 返回小时 */ public static int getHour(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar.get(Calendar.HOUR_OF_DAY); } /** * 功能描述:返回分 * * @param date 日期 * @return 返回分钟 */ public static int getMinute(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar.get(Calendar.MINUTE); } /** * 返回秒钟 * * @param date Date 日期 * @return 返回秒钟 */ public static int getSecond(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar.get(Calendar.SECOND); } /** * 功能描述:返回毫 * * @param date 日期 * @return 返回毫 */ public static long getMillis(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar.getTimeInMillis(); } /** * 验证请求是否在合法时间内 * * @param timestamp * @return */ public static boolean verifyRequestTime(long timestamp) { long now = System.currentTimeMillis(); long time = now - timestamp; System.out.println(now); System.out.println(time); System.out.println(time / 1000); if (time / 1000 > 60) { return false; } return true; } public static String formatDate(String format) { return formatDate(new Date(), format); } public static String formatDate(Date date, String format) { if ((null == date) || (StringUtils.isEmpty(format))) { return null; } return new SimpleDateFormat(format).format(date); } public static long getYesterDay() { Date date = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(calendar.DATE, -1); date = calendar.getTime(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); String dateString = format.format(date); long time = 0; try { time = format.parse(dateString).getTime(); } catch (ParseException e) { e.printStackTrace(); } return time; } public static long get1MonthByNow() { Calendar c = Calendar.getInstance(); //过去一月 c.setTime(new Date()); c.add(Calendar.MONTH, -1); Date m = c.getTime(); long time = m.getTime(); // String mon = format.format(m); return time; } public static int dateDiff(Date date1, Date date2) { int days = (int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)); return days; } public static int dateDiff(Long date1, Long date2) { int days = (int) ((date2 - date1) / (1000 * 3600 * 24)); return days; } public static List te() { List<String> list = new LinkedList<>(); Calendar calendar = Calendar.getInstance(); int month = calendar.get(Calendar.MONTH) + 1; int year = calendar.get(Calendar.YEAR); for (int i = 1; i <= 12; i++) { if (month == 1) { list.add(year + "-" + month); break; } list.add(year + "-" + month); month--; } return list; } /** * 获取上个月的第一天 * * @return */ public static long getLastMonthStart() { //获取前月的第一天 Calendar start = Calendar.getInstance(); //获取当前日期 start.add(Calendar.MONTH, -1); //设置为1号,当前日期既为本月第一天 start.set(Calendar.DAY_OF_MONTH, 1); return DateUtil.getStartTime(start.getTimeInMillis()); } /** * 获取本月第一天 * * @return */ public static long getCurrentMonthStart() { //获取前月的第一天 Calendar start = Calendar.getInstance(); //设置为1号,当前日期既为本月第一天 start.set(Calendar.DAY_OF_MONTH, 1); return DateUtil.getStartTime(start.getTimeInMillis()); } /** * 获取月份开始时间 * * @param date * @return */ public static long getMonthStart(Date date) { //获取前月的第一天 Calendar start = Calendar.getInstance(); start.setTime(date); //设置为1号,当前日期既为本月第一天 start.set(Calendar.DAY_OF_MONTH, 1); return DateUtil.getStartTime(start.getTimeInMillis()); } /** * 获取月份结束时间 * * @param date * @return */ public static long getMonthEnd(Date date) { Calendar end = Calendar.getInstance(); end.setTime(date); end.set(Calendar.DAY_OF_MONTH, end.getActualMaximum(Calendar.DAY_OF_MONTH)); return DateUtil.getEndTime(end.getTimeInMillis()); } /** * 获取上个月的最后一天 * * @return */ public static long getLastMonthEnd() { Calendar cale = Calendar.getInstance(); cale.set(Calendar.DAY_OF_MONTH, 0); return DateUtil.getEndTime(cale.getTimeInMillis()); } /** * 上个月 * * @return */ public static String getLastMonth() { SimpleDateFormat format = new SimpleDateFormat("yyyyMM"); Date date = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); // 设置为当前时间 calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); // 设置为上一个月 date = calendar.getTime(); String accDate = format.format(date); return accDate; } /** * 前2个月 * * @return */ public static String getLast2Month() { SimpleDateFormat format = new SimpleDateFormat("yyyyMM"); Date date = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); // 设置为当前时间 calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 2); // 设置为上一个月 date = calendar.getTime(); String accDate = format.format(date); return accDate; } public static String getYearMoney(Date date) { SimpleDateFormat format = new SimpleDateFormat("yyyyMM"); String format1 = format.format(date); return format1; } /** * 获取精确到秒的时间戳 * * @param date * @return */ public static int getSecondTimestamp(Date date) { if (null == date) { return 0; } String timestamp = String.valueOf(date.getTime() / 1000); return Integer.valueOf(timestamp); } /** * 获取门店营业时间 * * @param storeLocalTime 门店时间 * @param date * @return */ public static Date getStoreDate(Long storeLocalTime, Date date) { Date storeDate = getDate(storeLocalTime); String format = ThreadDateUtil.getDateFormat(sfH).format(storeDate); String dateStr = ThreadDateUtil.getDateFormat(sf1).format(date); // Date userDate = getDate(receiveTime); // String nowDate = ThreadDateUtil.getDateFormat(sf1).format(userDate); String concat = dateStr.concat(" ").concat(format); Date newDate = null; try { newDate = ThreadDateUtil.getDateFormat(sf).parse(concat); } catch (ParseException e) { e.printStackTrace(); } return newDate; } /** * 获取指定年月的第一天 * * @param year * @param month * @return */ public static String getFirstDayOfMonth(int year, int month) { Calendar cal = Calendar.getInstance(); //设置年份 cal.set(Calendar.YEAR, year); //设置月份 cal.set(Calendar.MONTH, month - 1); //获取某月最小天数 int firstDay = cal.getMinimum(Calendar.DATE); //设置日历中月份的最小天数 cal.set(Calendar.DAY_OF_MONTH, firstDay); //格式化日期 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(cal.getTime()); } /** * 获取指定年月的最后一天 * * @param year * @param month * @return */ public static String getLastDayOfMonth(int year, int month) { Calendar cal = Calendar.getInstance(); //设置年份 cal.set(Calendar.YEAR, year); //设置月份 cal.set(Calendar.MONTH, month - 1); //获取某月最大天数 int lastDay = cal.getActualMaximum(Calendar.DATE); //设置日历中月份的最大天数 cal.set(Calendar.DAY_OF_MONTH, lastDay); //格式化日期 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd "); return sdf.format(cal.getTime()); } /** * 计算时间相差多少天 * * @param startDate * @param endDate * @return * @throws ParseException */ public static int getDayDiffer(Date startDate, Date endDate) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); long startDateTime = dateFormat.parse(dateFormat.format(startDate)).getTime(); long endDateTime = dateFormat.parse(dateFormat.format(endDate)).getTime(); return (int) ((endDateTime - startDateTime) / (1000 * 3600 * 24)); } /** * 计算时间差 * * @param startDate * @param endDate * @return */ public static int getOrderDayDiffer(Date startDate, Date endDate) { int dayDiffer = 0; try { dayDiffer = getDayDiffer(startDate, endDate); if (dayDiffer < 0) { throw new ApiException(CommonResult.failed().getMessage()); } if (dayDiffer == 0) { dayDiffer = 1; } } catch (ParseException e) { e.printStackTrace(); throw new ApiException(e); } return dayDiffer; } /** * 获取时分 * * @param date * @return */ public static String getHm(Date date) { DateFormat dateFormat = ThreadDateUtil.getDateFormat(sf2); return dateFormat.format(date); } /** * 获取年月日 * * @param date * @return */ public static String getYmd(Date date) { DateFormat dateFormat = ThreadDateUtil.getDateFormat(sf1); return dateFormat.format(date); } public static long swapYmd(Long localTime, Long receiveTime) { Date localDate = DateUtil.getDate(localTime); String hms = ThreadDateUtil.getDateFormat(sfH).format(localDate); Date receiveDate = DateUtil.getDate(receiveTime); String ymd = ThreadDateUtil.getDateFormat(sf1).format(receiveDate); String concat = ymd.concat(" ").concat(hms); Date newDate = null; try { newDate = ThreadDateUtil.getDateFormat(sf).parse(concat); } catch (ParseException e) { e.printStackTrace(); } return newDate.getTime(); } /** * * 获取指定日期所在周的周一 * <p> * * * <p> * * @param date 日期 * <p> * */ public static Date getFirstDayOfWeek(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); if (c.get(Calendar.DAY_OF_WEEK) == 1) { c.add(Calendar.DAY_OF_MONTH, -1); } c.add(Calendar.DATE, c.getFirstDayOfWeek() - c.get(Calendar.DAY_OF_WEEK) + 1); return c.getTime(); } /** * * 获取指定日期所在周的周日 * <p> * * * <p> * * @param date 日期 * <p> * */ public static Date getLastDayOfWeek(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);// 如果是周日直接返回 if (c.get(Calendar.DAY_OF_WEEK) == 1) { return date; } System.out.println(c.get(Calendar.DAY_OF_WEEK)); c.add(Calendar.DATE, 7 - c.get(Calendar.DAY_OF_WEEK) + 1); return c.getTime(); } } ycl-common/src/main/java/com/ycl/utils/common/PojoUtils.java
@@ -31,5 +31,4 @@ return n != null && n.intValue() != SysConst.COMBOBOX_ALL; } } } ycl-common/src/main/java/com/ycl/utils/common/RandomUtils.java
@@ -6,4 +6,62 @@ * @date 2022/9/7 */ public class RandomUtils { /** * 用户名 */ private static final String NICK_NAME = "NK"; /** * 标记长度 */ public static final int SIGN_LENGTH = 6; /** * 标记格式化格式化字符串 */ private static final String FORMT_STRING = "888888"; /** * 获取用户名 * * @param userId * @return */ public static String getUserId(long userId) { return NICK_NAME + formatSign(userId) + generateRandomInt(SIGN_LENGTH); } /** * 格式化标记 * * @return4 */ private static String formatSign(long param) { String str = Long.toString(param); int length = str.length() - SIGN_LENGTH; if (length == 0) { return str; } else if (length < 0) { str = "0" + str; return FORMT_STRING.substring(0, Math.abs(length) - 1) + str; } else { return str.substring(length); } } /** * 获取指定长度(1位到9位)的随机数字字符串 * * @param length 大于1 小于9 * @return */ public static String generateRandomInt(int length) { length = length < 1 ? 1 : length; length = length > 9 ? 9 : length; int max = ((int) Math.pow(10, length)) - 1; int min = (int) Math.pow(10, length - 1); return String.valueOf((int) (Math.random() * (max - min) + min)); } } ycl-common/src/main/java/com/ycl/utils/common/ThreadDateUtil.java
New file @@ -0,0 +1,79 @@ package com.ycl.utils.common; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * 日期线程类 */ public final class ThreadDateUtil { /** * 日期格式1 */ public static final String yyyyMMddHHmmsss = "yyyyMMddHHmmsss"; /** * 日期格式2 */ public static final String yyMMddHHmmsss = "yyMMddHHmmsss"; /** * 默认格式 */ private static final String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss"; /** * 格式化 线程集 */ private static Map<String, ThreadLocal<DateFormat>> threadLocalMap = new HashMap<>(); /** * 获取日期格式化工具对象 * 线程安全 * @return */ public static DateFormat getDateFormat() { return getDateFormat(DEFAULT_FORMAT); } /** * 获取日期格式化工具对象 * 线程安全 * @param format 格式 可取些工具类中的常量格式,默认为yyyy-MM-dd HH:mm:ss * @return */ public static DateFormat getDateFormat(String format) { ThreadLocal<DateFormat> threadLocal = threadLocalMap.get(format); DateFormat df = null; if (threadLocal == null) { threadLocal = new ThreadLocal<DateFormat>(); df = new SimpleDateFormat(format); threadLocal.set(df); threadLocalMap.put(format, threadLocal); } else { df = threadLocal.get(); if (df == null) { df = new SimpleDateFormat(format); threadLocal.set(df); threadLocalMap.put(format, threadLocal); } } return df; } public static String formatDate(Date date) throws ParseException { return getDateFormat().format(date); } public static Date parse(String strDate) throws ParseException { return getDateFormat().parse(strDate); } } ycl-common/src/main/java/com/ycl/vo/depart/DepartVO.java
New file @@ -0,0 +1,80 @@ package com.ycl.vo.depart; import com.ycl.api.BasePageVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; /** * @author Lyq * @version 1.0 * @date 2022/9/7 */ public class DepartVO { @Data @ApiModel public static class AddDepartVO { @ApiModelProperty("部门名称") private String departName; @ApiModelProperty("部门描述") private String departDes; @ApiModelProperty("部门类型") private Integer departType; @ApiModelProperty("父级id,默认0") private Long parentId; @ApiModelProperty("停用状态,0->false,1->true,默认停用") private byte status; } @ApiModel @Data public static class IdDepartVO { @ApiModelProperty(value = "部门id") @NotNull(message = "部门id不能为空") private Long id; } @ApiModel @Data public static class StatusDepartVO { @ApiModelProperty(value = "部门id") @NotNull(message = "部门id不能为空") private Long id; @ApiModelProperty("停用状态,0->false,1->true,默认停用") private byte status; } @ApiModel @Data public static class UpdateDepartVO { @ApiModelProperty(value = "部门id") @NotNull(message = "部门id不能为空") private Long id; @ApiModelProperty("部门名称") private String departName; @ApiModelProperty("部门描述") private String departDes; @ApiModelProperty("部门类型") private Integer departType; @ApiModelProperty("父级id,默认0") private Long parentId; @ApiModelProperty("停用状态,0->false,1->true,默认停用") private byte status; } @ApiModel @Data public static class PageDepartVO extends BasePageVO { } } ycl-common/src/main/java/com/ycl/vo/user/UserVO.java
New file @@ -0,0 +1,28 @@ package com.ycl.vo.user; import com.ycl.api.BasePageVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author Lyq * @version 1.0 * @date 2022/9/7 */ public class UserVO { @Data @ApiModel public static class PageUserVO extends BasePageVO { @ApiModelProperty(value = "部门id,0即为查询全部,默认0",example = "0") private Long departmentId; @ApiModelProperty(value = "用户类型,0即为查询全部,默认0",example = "0") private byte userType; @ApiModelProperty(value = "职务") private String jobTitle; } } ycl-common/src/main/resources/mapper/depart/SccgDepartMapper.xml
New file @@ -0,0 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ycl.depart.mapper.SccgDepartMapper"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.ycl.entity.depart.SccgDepart"> <id column="id" property="id" /> <result column="depart_name" property="departName" /> <result column="depart_des" property="departDes" /> <result column="depart_type" property="departType" /> <result column="parent_id" property="parentId" /> <result column="status" property="status" /> <result column="create_time" property="createTime" /> <result column="update_time" property="updateTime" /> <result column="is_deleted" property="isDeleted" /> </resultMap> </mapper> ycl-common/src/main/resources/mapper/user/UmsAdminMapper.xml
@@ -4,25 +4,31 @@ <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.ycl.entity.user.UmsAdmin"> <id column="id" property="id" /> <result column="username" property="username" /> <result column="password" property="password" /> <result column="icon" property="icon" /> <result column="email" property="email" /> <result column="nick_name" property="nickName" /> <result column="note" property="note" /> <result column="create_time" property="createTime" /> <result column="login_time" property="loginTime" /> <result column="status" property="status" /> <id column="id" property="id"/> <result column="username" property="username"/> <result column="password" property="password"/> <result column="icon" property="icon"/> <result column="email" property="email"/> <result column="nick_name" property="nickName"/> <result column="note" property="note"/> <result column="create_time" property="createTime"/> <result column="login_time" property="loginTime"/> <result column="status" property="status"/> <result column="mac_address" property="macAddress"/> <result column="ip_address" property="ipAddress"/> <result column="is_dy" property="isDy"/> <result column="job_title" property="jobTitle"/> <result column="department_id" property="departmentId"/> <result column="user_type" property="userType"/> <result column="zj" property="zj"/> <result column="mobile" property="mobile"/> </resultMap> <select id="getAdminIdList" resultType="java.lang.Long"> SELECT DISTINCT ar.admin_id FROM ums_role_resource_relation rr LEFT JOIN ums_admin_role_relation ar ON rr.role_id = ar.role_id WHERE rr.resource_id=#{resourceId} SELECT DISTINCT ar.admin_id FROM ums_role_resource_relation rr LEFT JOIN ums_admin_role_relation ar ON rr.role_id = ar.role_id WHERE rr.resource_id = #{resourceId} </select> </mapper> ycl-platform/src/main/java/com/ycl/controller/depart/DepartController.java
New file @@ -0,0 +1,71 @@ package com.ycl.controller.depart; import com.ycl.api.CommonResult; import com.ycl.entity.depart.SccgDepart; import com.ycl.entity.user.UmsMenu; import com.ycl.service.depart.SccgDepartService; import com.ycl.service.user.UmsMenuService; import com.ycl.vo.depart.DepartVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; /** * <p> * 部门表 前端控制器 * </p> * * @author lyq * @since 2022-09-07 */ @RestController @Api(tags = "部门管理模块") @RequestMapping("/depart") public class DepartController { @Autowired private SccgDepartService departService; @ApiOperation("添加部门") @PostMapping(value = "/create") public CommonResult<Void> create(@Validated @RequestBody DepartVO.AddDepartVO addDepartVO) { departService.create(addDepartVO); return CommonResult.success(null); } @ApiOperation("删除") @PostMapping(value = "/delete") public CommonResult<Void> delete(@Validated @RequestBody DepartVO.IdDepartVO params) { departService.delete(params.getId()); return CommonResult.success(null); } @ApiOperation("详情") @PostMapping(value = "/detail") public CommonResult<SccgDepart> detail(@Validated @RequestBody DepartVO.IdDepartVO params) { SccgDepart sccgDepart = departService.loadDepartById(params.getId()); return CommonResult.success(sccgDepart); } @ApiOperation("树结构") @GetMapping(value = "/tree") public CommonResult<List<SccgDepart>> tree() { List<SccgDepart> tree = departService.tree(); return CommonResult.success(tree); } @ApiOperation("修改部门状态") @PostMapping(value = "/status") public CommonResult<Void> status(@Validated @RequestBody DepartVO.StatusDepartVO params) { departService.updateStatus(params); return CommonResult.success(null); } } ycl-platform/src/main/java/com/ycl/controller/user/UmsAdminController.java
File was renamed from ycl-platform/src/main/java/com/ycl/controller/UmsAdminController.java @@ -1,6 +1,7 @@ package com.ycl.controller; package com.ycl.controller.user; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ycl.api.CommonPage; import com.ycl.api.CommonResult; @@ -11,6 +12,7 @@ import com.ycl.entity.user.UmsRole; import com.ycl.service.user.UmsAdminService; import com.ycl.service.user.UmsRoleService; import com.ycl.vo.user.UserVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -87,7 +89,7 @@ @RequestMapping(value = "/info", method = RequestMethod.GET) @ResponseBody public CommonResult getAdminInfo(Principal principal) { if(principal==null){ if (principal == null) { return CommonResult.unauthorized(null); } String username = principal.getName(); @@ -97,9 +99,9 @@ data.put("menus", roleService.getMenuList(umsAdmin.getId())); data.put("icon", umsAdmin.getIcon()); List<UmsRole> roleList = adminService.getRoleList(umsAdmin.getId()); if(CollUtil.isNotEmpty(roleList)){ if (CollUtil.isNotEmpty(roleList)) { List<String> roles = roleList.stream().map(UmsRole::getName).collect(Collectors.toList()); data.put("roles",roles); data.put("roles", roles); } return CommonResult.success(data); } @@ -111,14 +113,12 @@ return CommonResult.success(null); } @ApiOperation("根据用户名或姓名分页获取用户列表") @RequestMapping(value = "/list", method = RequestMethod.GET) @ApiOperation("分页") @RequestMapping(value = "/page", method = RequestMethod.GET) @ResponseBody public CommonResult<CommonPage<UmsAdmin>> list(@RequestParam(value = "keyword", required = false) String keyword, @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) { Page<UmsAdmin> adminList = adminService.list(keyword, pageSize, pageNum); return CommonResult.success(CommonPage.restPage(adminList)); public CommonResult<IPage<UmsAdmin>> list(@Validated UserVO.PageUserVO pageUserVO) { IPage<UmsAdmin> page = adminService.pageUser(pageUserVO); return CommonResult.success(page); } @ApiOperation("获取指定用户信息") @@ -172,10 +172,10 @@ @ApiOperation("修改帐号状态") @RequestMapping(value = "/updateStatus/{id}", method = RequestMethod.POST) @ResponseBody public CommonResult updateStatus(@PathVariable Long id,@RequestParam(value = "status") Integer status) { public CommonResult updateStatus(@PathVariable Long id, @RequestParam(value = "status") Integer status) { UmsAdmin umsAdmin = new UmsAdmin(); umsAdmin.setStatus(status); boolean success = adminService.update(id,umsAdmin); boolean success = adminService.update(id, umsAdmin); if (success) { return CommonResult.success(null); } ycl-platform/src/main/java/com/ycl/controller/user/UmsMenuController.java
File was renamed from ycl-platform/src/main/java/com/ycl/controller/UmsMenuController.java @@ -1,4 +1,4 @@ package com.ycl.controller; package com.ycl.controller.user; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ycl.api.CommonPage; ycl-platform/src/main/java/com/ycl/controller/user/UmsResourceCategoryController.java
File was renamed from ycl-platform/src/main/java/com/ycl/controller/UmsResourceCategoryController.java @@ -1,4 +1,4 @@ package com.ycl.controller; package com.ycl.controller.user; import com.ycl.api.CommonResult; import com.ycl.entity.user.UmsResourceCategory; ycl-platform/src/main/java/com/ycl/controller/user/UmsResourceController.java
File was renamed from ycl-platform/src/main/java/com/ycl/controller/UmsResourceController.java @@ -1,4 +1,4 @@ package com.ycl.controller; package com.ycl.controller.user; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ycl.api.CommonPage; ycl-platform/src/main/java/com/ycl/controller/user/UmsRoleController.java
File was renamed from ycl-platform/src/main/java/com/ycl/controller/UmsRoleController.java @@ -1,4 +1,4 @@ package com.ycl.controller; package com.ycl.controller.user; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ycl.api.CommonPage;