| | |
| | | import java.awt.peer.LabelPeer; |
| | | import java.util.*; |
| | | |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ltkj.common.annotation.RepeatSubmit; |
| | | import com.ltkj.common.core.domain.entity.SysDept; |
| | | import com.ltkj.common.core.domain.entity.SysRole; |
| | | import com.ltkj.common.core.redis.RedisCache; |
| | | import com.ltkj.common.exception.CustomException; |
| | | import com.ltkj.common.exception.user.SecretKeyException; |
| | | import com.ltkj.common.utils.StringUtils; |
| | | import com.ltkj.framework.config.UserHoder; |
| | | import com.ltkj.hosp.domain.DictHosp; |
| | | import com.ltkj.hosp.domain.TjCustomer; |
| | | import com.ltkj.hosp.service.IDictHospService; |
| | | import com.ltkj.hosp.service.ITjCustomerService; |
| | | import com.ltkj.system.domain.SysPost; |
| | | import com.ltkj.system.domain.SysRoleMenu; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ltkj.common.constant.Constants; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | |
| | | private ISysRoleMenuService roleMenuService; |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | @Resource |
| | | private IDictHospService hospService; |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | @Value("${token.secret_key}") |
| | | private String secret; |
| | | |
| | | @Value("${token.secret_key_login}") |
| | | private boolean secretKeyLogin; |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * 登录方法 |
| | |
| | | @GetMapping("getInfo") |
| | | public AjaxResult getInfo() { |
| | | AjaxResult ajax = success(); |
| | | SysUser user = Objects.requireNonNull(SecurityUtils.getLoginUser()).getUser(); |
| | | SysUser user = UserHoder.getLoginUser().getUser(); |
| | | if (null != user.getUserId()) { |
| | | if (secretKeyLogin) |
| | | { |
| | | if(null !=user.getDeptId()){ |
| | | if(!SecurityUtils.isAdmin(user.getUserId())){ |
| | | SysDept sysDept = deptService.getById(user.getDeptId()); |
| | | if (null != sysDept) { |
| | | DictHosp dictHosp = hospService.getById(sysDept.getHospId()); |
| | | if(null !=dictHosp && dictHosp.getSecretKey() !=null && dictHosp.getExpirationTime() !=null){ |
| | | if (!SecurityUtils.matchesMallMerchantSecretKey(secret,dictHosp.getHospAreaId(),dictHosp.getAreaid(), |
| | | dictHosp.getExpirationTime(),dictHosp.getSecretKey())) { |
| | | |
| | | String userIdKey = Constants.LOGIN_USERID_KEY + user.getUserId(); |
| | | String userKey = redisCache.getCacheObject(userIdKey); |
| | | if (org.apache.commons.lang3.StringUtils.isNotEmpty(userKey)) |
| | | { |
| | | redisCache.deleteObject(userIdKey); |
| | | redisCache.deleteObject(userKey); |
| | | } |
| | | throw new SecretKeyException("商家已过期请续费使用"); |
| | | } |
| | | long between = DateUtil.between(new Date(), DateUtil.endOfDay(dictHosp.getExpirationTime()), DateUnit.DAY); |
| | | if(between<=30){ |
| | | UserHoder.getLoginUser().setMessage("还有 "+between+" 天到期 请注意续费! 以免影响正常使用!"); |
| | | } |
| | | }else { |
| | | throw new SecretKeyException("请缴费使用"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | Set<String> roles = permissionService.getRolePermission(user); |
| | | Set<String> permissions = permissionService.getMenuPermission(user); |
| | | ajax.put("user", user); |
| | | ajax.put("roles", roles); |
| | | ajax.put("permissions", permissions); |
| | | ajax.put("securitMessage",UserHoder.getLoginUser().getMessage()); |
| | | ajax.put("hospName",UserHoder.getLoginUser().getHospName()); |
| | | } else { |
| | | Set<String> roles = new HashSet<>(); |
| | | LambdaQueryWrapper<SysRole> wq = new LambdaQueryWrapper<>(); |
| | |
| | | ajax.put("roles", roles); |
| | | ajax.put("permissions", permissions); |
| | | ajax.put("post",null); |
| | | ajax.put("securitMessage",null); |
| | | ajax.put("hospName",UserHoder.getLoginUser().getHospName()); |
| | | } |
| | | return ajax; |
| | | } |