对比新文件 |
| | |
| | | package com.gkhy.assess.admin.config; |
| | | |
| | | import com.gkhy.assess.common.config.BaseSwaggerConfig; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; |
| | | |
| | | @Configuration |
| | | @EnableSwagger2WebMvc |
| | | public class SwaggerConfig extends BaseSwaggerConfig { |
| | | |
| | | } |
| | |
| | | @Autowired |
| | | private SysCommonService commonService; |
| | | |
| | | @ApiOperation(value = "上传头像") |
| | | @PostMapping("/uploadIcon") |
| | | public CommonResult<UploadObjectVO> uploadIcon(MultipartFile file){ |
| | | @ApiOperation(value = "上传图片/文件") |
| | | @PostMapping("/uploadFile") |
| | | public CommonResult<UploadObjectVO> uploadFile(MultipartFile file){ |
| | | return CommonResult.success(commonService.uploadFile(file)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "删除图片") |
| | | @DeleteMapping("/removeFile") |
| | | public CommonResult removeFile(@RequestParam(required = true) String path){ |
| | | return CommonResult.success(commonService.removeFile(path)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | return CommonResult.success(lawService.getLawById(lawId)); |
| | | } |
| | | |
| | | @RequiresPermissions("system:assess:monitor") |
| | | @ApiOperation(value = "新增法律法规") |
| | | @PostMapping("/addLaw") |
| | | public CommonResult addLaw(@Validated @RequestBody SysLaw law){ |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions("system:assess:monitor") |
| | | @ApiOperation(value = "编辑法律法规") |
| | | @PutMapping("/editLaw") |
| | | public CommonResult editLaw(@Validated @RequestBody SysLaw law){ |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions("system:assess:monitor") |
| | | @ApiOperation(value = "删除法律法规") |
| | | @PutMapping("/remove/{lawId}") |
| | | public CommonResult removeLaw(@PathVariable(name = "lawId")Long lawId){ |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions("system:assess:monitor") |
| | | @ApiOperation(value = "法律法规状态修改,停用/启用") |
| | | @PostMapping("/changeStatus") |
| | | public CommonResult changeStatus(SysLaw law) |
| | |
| | | import com.gkhy.assess.common.api.CommonResult; |
| | | import com.gkhy.assess.common.domain.vo.LoginBody; |
| | | import com.gkhy.assess.system.service.SysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | * @author kzy |
| | | * @since 2023-10-17 14:26:29 |
| | | */ |
| | | @Api(tags = "用户登录前端控制器") |
| | | @RestController |
| | | @RequestMapping("/account") |
| | | public class SysLoginController { |
| | | @Autowired |
| | | private SysUserService sysUserService; |
| | | |
| | | @ApiOperation(value = "用户登录") |
| | | @PostMapping("/login") |
| | | public CommonResult login(@RequestBody LoginBody loginBody){ |
| | | return CommonResult.success(sysUserService.login(loginBody)); |
| | | } |
| | | |
| | | @ApiOperation(value = "用户退出") |
| | | @PostMapping("/logout") |
| | | public CommonResult logout(){ |
| | | sysUserService.logout(); |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | return CommonResult.success(noticeService.getNoticeById(noticeId)); |
| | | } |
| | | |
| | | @RequiresPermissions("system:assess:monitor") |
| | | @ApiOperation(value = "新增通知") |
| | | @PostMapping("/addNotice") |
| | | public CommonResult addNotice(@Validated @RequestBody SysNotice notice){ |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions("system:assess:monitor") |
| | | @ApiOperation(value = "编辑通知") |
| | | @PutMapping("/editNotice") |
| | | public CommonResult editNotice(@Validated @RequestBody SysNotice notice){ |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions("system:assess:monitor") |
| | | @ApiOperation(value = "删除通知") |
| | | @PutMapping("/remove/{noticeId}") |
| | | public CommonResult removeNotice(@PathVariable(name = "noticeId")Long noticeId){ |
| | | return CommonResult.success(noticeService.deleteNoticeById(noticeId)); |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions("system:assess:monitor") |
| | | @ApiOperation(value = "通知状态修改,停用/启用") |
| | | @PostMapping("/changeStatus") |
| | | public CommonResult changeStatus(SysNotice notice) |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.shiro.authz.annotation.Logical; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | public class SysUserController { |
| | | @Autowired |
| | | private SysUserService sysUserService; |
| | | |
| | | |
| | | @ApiOperation(value = "监管用户列表(分页)") |
| | | @ApiImplicitParams({ |
| | |
| | | return CommonResult.success(sysUserService.agencyRegister(user)); |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value={"system:assess:monitor","system:assess:agency"},logical = Logical.OR) |
| | | @ApiOperation(value = "创建专家") |
| | | @PostMapping("/addExpert") |
| | | public CommonResult addExpert(@Validated(ExpertGroup.class) @RequestBody SysUser user){ |
| | | return CommonResult.success(sysUserService.addExpert(user)); |
| | | } |
| | | |
| | | @RequiresPermissions("system:assess:monitor") |
| | | @ApiOperation(value = "编辑机构") |
| | | @PutMapping("/editAgency") |
| | | public CommonResult editAgency(@Validated(ExpertGroup.class) @RequestBody SysUser user){ |
| | | return CommonResult.success(sysUserService.editAgency(user)); |
| | | } |
| | | |
| | | @RequiresPermissions(value={"system:assess:monitor","system:assess:agency"},logical = Logical.OR) |
| | | @ApiOperation(value = "编辑专家") |
| | | @PutMapping("/editExpert") |
| | | public CommonResult editExpert(@Validated(ExpertGroup.class) @RequestBody SysUser user){ |
| | |
| | | /** |
| | | * 用户状态修改 |
| | | */ |
| | | @RequiresPermissions(value={"system:assess:monitor","system:assess:agency"},logical = Logical.OR) |
| | | @ApiOperation(value = "用户状态修改,停用/启用") |
| | | @PostMapping("/changeStatus") |
| | | public CommonResult changeStatus(SysUser user) |
| | |
| | | return CommonResult.success(sysUserService.changeUserStatus(user)); |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions("system:assess:monitor") |
| | | @ApiOperation(value = "审批状态修改,停用/启用") |
| | | @PostMapping("/changeApprove") |
| | | public CommonResult changeApprove(SysUser user) |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value={"system:assess:monitor","system:assess:agency"},logical = Logical.OR) |
| | | @ApiOperation(value = "根据id删除用户") |
| | | @DeleteMapping("/remove/{userId}") |
| | | public CommonResult removeUser(@PathVariable(name = "userId") Long userId) |
| | |
| | | // 用ApiInfoBuilder进行定制 |
| | | return new ApiInfoBuilder() |
| | | // 设置标题 |
| | | .title("xx系统单机版API文档") |
| | | .title("智慧安评系统API文档") |
| | | // 描述 |
| | | .description("描述:xx系统单机版API文档") |
| | | .description("描述:智慧安评系统API文档") |
| | | // 作者信息 |
| | | .contact(new Contact("nms", null, null)) |
| | | .contact(new Contact("gkhy", null, null)) |
| | | // 版本 |
| | | .version("版本号:1.0") |
| | | .build(); |
对比新文件 |
| | |
| | | package com.gkhy.assess.common.enums; |
| | | |
| | | /** |
| | | * 附件类型 |
| | | * |
| | | */ |
| | | public enum AttachTypeEnum |
| | | { |
| | | SOCIAL(1, "社保"), MEDICAL(2, "医保"),SALARY(3, "工资单"); |
| | | |
| | | private final Integer code; |
| | | private final String info; |
| | | |
| | | AttachTypeEnum(Integer code, String info) |
| | | { |
| | | this.code = code; |
| | | this.info = info; |
| | | } |
| | | |
| | | public Integer getCode() |
| | | { |
| | | return code; |
| | | } |
| | | |
| | | public String getInfo() |
| | | { |
| | | return info; |
| | | } |
| | | } |
| | |
| | | chain.addPathDefinition("/swagger/**","anon"); |
| | | chain.addPathDefinition("/webjars/**", "anon"); |
| | | chain.addPathDefinition("/swagger-resources/**","anon"); |
| | | chain.addPathDefinition("/doc.html", "anon"); |
| | | chain.addPathDefinition("/v2/api-docs", "anon"); |
| | | chain.addPathDefinition("/static/**", "anon"); |
| | | chain.addPathDefinition("/error", "anon"); |
| | | |
| | | chain.addPathDefinition("/account/login","anon"); |
| | | // chain.addPathDefinition("/api/account/login","anon"); |
| | |
| | | package com.gkhy.assess.framework.shiro.realm; |
| | | |
| | | import com.gkhy.assess.common.enums.UserIdentityEnum; |
| | | import com.gkhy.assess.common.utils.RequestUtil; |
| | | import com.gkhy.assess.common.utils.SpringContextUtils; |
| | | import com.gkhy.assess.framework.shiro.JwtToken; |
| | |
| | | Set<String> roles=new HashSet<>(); |
| | | Set<String> menus=new HashSet<>(); |
| | | SimpleAuthorizationInfo info=new SimpleAuthorizationInfo(); |
| | | info.addRole("admin"); |
| | | info.addStringPermission("*:*:*"); |
| | | if(sysUser.getIdentity().equals(UserIdentityEnum.MONITOR.getCode())){ |
| | | info.addRole("monitor"); |
| | | info.addStringPermission("system:assess:monitor"); |
| | | }else if(sysUser.getIdentity().equals(UserIdentityEnum.AGENCY.getCode())){ |
| | | info.addRole("agency"); |
| | | info.addStringPermission("system:assess:agency"); |
| | | }else{ |
| | | info.addRole("expert"); |
| | | info.addStringPermission("system:assess:expert"); |
| | | } |
| | | |
| | | return info; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { |
| | | HttpServletRequest req = SpringContextUtils.getHttpServletRequest(); |
| | | SysUser sysUser=null; |
| | | if(authenticationToken instanceof JwtToken){ |
| | | String token= (String) authenticationToken.getCredentials(); |
| | | if(token==null){ |
| | | HttpServletRequest req = SpringContextUtils.getHttpServletRequest(); |
| | | |
| | | log.info("————————身份认证失败——————————IP地址: "+ RequestUtil.getRequestIp(req) +",URL:"+req.getRequestURI()); |
| | | throw new AuthenticationException("token为空!"); |
| | | } |
| | |
| | | import com.gkhy.assess.system.domain.SysAttach; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Mapper |
| | | public interface SysAttachMapper extends BaseMapper<SysAttach> { |
| | | |
| | | /** |
| | | * 根据用户id获取附件 |
| | | * @param userId |
| | | * @param type |
| | | * @return |
| | | */ |
| | | List<SysAttach> getAttachsByUserId(@Param("userId") Long userId, @Param("type") Integer type); |
| | | |
| | | /** |
| | | * 根据用户id删除数据 |
| | | * @param userId |
| | | * @param type |
| | | * @return |
| | | */ |
| | | int deleteAttachsByUserId(Long userId, Integer type); |
| | | } |
| | |
| | | import com.gkhy.assess.system.domain.SysAttach; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 系统配置表 服务类 |
| | |
| | | */ |
| | | public interface SysAttachService extends IService<SysAttach> { |
| | | |
| | | /** |
| | | * 根据用户id获取附件 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | List<SysAttach> getAttachsByUserId(Long userId,Integer type); |
| | | |
| | | /** |
| | | * 根据用户id删除附件 |
| | | * @param userId |
| | | * @param type |
| | | * @return |
| | | */ |
| | | int deleteAttachsByUserId(Long userId,Integer type); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | public UploadObjectVO uploadFile(MultipartFile file); |
| | | |
| | | |
| | | public boolean removeFile(String path); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 系统配置表 服务实现类 |
| | |
| | | @Service |
| | | public class SysAttachServiceImpl extends ServiceImpl<SysAttachMapper, SysAttach> implements SysAttachService { |
| | | |
| | | @Override |
| | | public List<SysAttach> getAttachsByUserId(Long userId, Integer type) { |
| | | return baseMapper.getAttachsByUserId(userId,type); |
| | | } |
| | | |
| | | @Override |
| | | public int deleteAttachsByUserId(Long userId, Integer type) { |
| | | return baseMapper.deleteAttachsByUserId(userId,type); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | return uploadObjectVO; |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeFile(String path) { |
| | | String systemDir=System.getProperty("user.dir"); |
| | | String filePath=systemDir+File.separator+path; |
| | | File dirFile=new File(filePath); |
| | | if(!dirFile.isFile()){ |
| | | throw new ApiException("非文件,不能删除"); |
| | | } |
| | | if(!dirFile.exists()){ |
| | | throw new ApiException("文件不存在"); |
| | | } |
| | | dirFile.delete(); |
| | | return true; |
| | | } |
| | | |
| | | public UploadObjectVO doUpload(MultipartFile file){ |
| | | String filename=file.getOriginalFilename(); |
| | | String subfix=filename.substring(filename.lastIndexOf(".")); |
| | |
| | | import com.gkhy.assess.common.constant.CacheConstant; |
| | | import com.gkhy.assess.common.domain.vo.AccountVO; |
| | | import com.gkhy.assess.common.domain.vo.LoginBody; |
| | | import com.gkhy.assess.common.enums.AttachTypeEnum; |
| | | import com.gkhy.assess.common.enums.UserIdentityEnum; |
| | | import com.gkhy.assess.common.enums.UserTypeEnum; |
| | | import com.gkhy.assess.common.exception.ApiException; |
| | |
| | | import com.gkhy.assess.system.domain.*; |
| | | import com.gkhy.assess.system.mapper.SysAgencyMapper; |
| | | import com.gkhy.assess.system.mapper.SysUserMapper; |
| | | import com.gkhy.assess.system.service.SysAttachService; |
| | | import com.gkhy.assess.system.service.SysConfigService; |
| | | import com.gkhy.assess.system.utils.ShiroUtils; |
| | | import com.gkhy.assess.system.service.SysUserService; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.validation.Validator; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | |
| | |
| | | @Autowired |
| | | private SysAgencyMapper agencyMapper; |
| | | |
| | | @Autowired |
| | | private SysAttachService attachService; |
| | | |
| | | |
| | | @Override |
| | | public AccountVO login(LoginBody loginBody) { |
| | | // 验证码校验 |
| | | validateCaptcha(loginBody.getUsername(), loginBody.getCode(), loginBody.getUuid()); |
| | | // validateCaptcha(loginBody.getUsername(), loginBody.getCode(), loginBody.getUuid()); |
| | | UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(loginBody.getUsername(), loginBody.getPassword(), false); |
| | | Subject subject= SecurityUtils.getSubject(); |
| | | String msg ; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = RuntimeException.class) |
| | | public int addExpert(SysUser user) { |
| | | //校验用户信息 |
| | | if(!checkUsernameUnique(new SysUser().setUsername(user.getUsername()))){ |
| | |
| | | if(!b){ |
| | | throw new ApiException("创建专家信息失败"); |
| | | } |
| | | List<SysAttach> socialAttach=user.getSocialAttach(); |
| | | List<SysAttach> medicalAttach=user.getMedicalAttach(); |
| | | List<SysAttach> salaryAttach=user.getSalaryAttach(); |
| | | List<SysAttach> attaches=new ArrayList<>(); |
| | | for(SysAttach attach:socialAttach){ |
| | | attach.setType(AttachTypeEnum.SOCIAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | for(SysAttach attach:medicalAttach){ |
| | | attach.setType(AttachTypeEnum.MEDICAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | for(SysAttach attach:salaryAttach){ |
| | | attach.setType(AttachTypeEnum.SALARY.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | attachService.saveBatch(attaches); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | if(!b){ |
| | | throw new ApiException("更新专家信息失败"); |
| | | } |
| | | //刪除旧数据 |
| | | attachService.deleteAttachsByUserId(user.getId(),null); |
| | | |
| | | List<SysAttach> socialAttach=user.getSocialAttach(); |
| | | List<SysAttach> medicalAttach=user.getMedicalAttach(); |
| | | List<SysAttach> salaryAttach=user.getSalaryAttach(); |
| | | List<SysAttach> attaches=new ArrayList<>(); |
| | | for(SysAttach attach:socialAttach){ |
| | | attach.setType(AttachTypeEnum.SOCIAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | for(SysAttach attach:medicalAttach){ |
| | | attach.setType(AttachTypeEnum.MEDICAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | for(SysAttach attach:salaryAttach){ |
| | | attach.setType(AttachTypeEnum.SALARY.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | attachService.saveBatch(attaches); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | |
| | | <?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.gkhy.assess.system.mapper.SysAttachMapper"> |
| | | <delete id="deleteAttachsByUserId"> |
| | | delete from sys_attach |
| | | <where> |
| | | and user_id=#{user_id} |
| | | <if test="type!=null and type!=''"> |
| | | and type=#{type} |
| | | </if> |
| | | <if test="type==null"> |
| | | and type in (1,2,3) |
| | | </if> |
| | | </where> |
| | | </delete> |
| | | |
| | | <select id="getAttachsByUserId" resultType="com.gkhy.assess.system.domain.SysAttach"> |
| | | select * from sys_attach |
| | | <where> |
| | | and user_id=#{userId} |
| | | <if test="type!=null and type!=''"> |
| | | and type=#{type} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | </mapper> |
| | |
| | | </delete> |
| | | |
| | | <select id="getUserByUsername" resultMap="SysUserResult"> |
| | | select id,username,name,password,salt,status,del_flag from sys_user |
| | | select id,username,name,password,salt,identity,status,del_flag from sys_user |
| | | where username=#{username} and del_flag=0 |
| | | </select> |
| | | |
| | |
| | | |
| | | |
| | | <select id="getUserByPhone" resultMap="SysUserResult"> |
| | | select id,username,name,password,salt,status,del_flag from sys_user |
| | | select id,username,name,password,salt,identity,status,del_flag from sys_user |
| | | where phone=#{phone} and del_flag=0 |
| | | </select> |
| | | |
| | | <select id="getUserByEmail" resultMap="SysUserResult"> |
| | | select id,username,name,password,salt,status,del_flag from sys_user |
| | | select id,username,name,password,salt,identity,status,del_flag from sys_user |
| | | where email=#{email} and del_flag=0 |
| | | </select> |
| | | |
| | | <select id="getUserById" resultMap="SysUserResult"> |
| | | select id,username,name,password,salt,status,del_flag from sys_user |
| | | select id,username,name,password,salt,identity,status,del_flag from sys_user |
| | | where id=#{userId} |
| | | </select> |
| | | |
| | |
| | | </select> |
| | | |
| | | <select id="getUserByUsernamePhone" resultType="com.gkhy.assess.system.domain.SysUser"> |
| | | select id,username,name,password,salt,status,del_flag from sys_user |
| | | select id,username,name,password,salt,identity,status,del_flag from sys_user |
| | | where (username=#{username} or phone=#{username}) and del_flag=0 |
| | | </select> |
| | | |