调整
This commit is contained in:
@@ -42,6 +42,7 @@ public class FileServerUtil {
|
||||
File outFile = getUploadFile(file.getOriginalFilename(), directory, uuidName);
|
||||
if (!outFile.getParentFile().exists()) {
|
||||
if (!outFile.getParentFile().mkdirs()) {
|
||||
System.out.println(outFile.getPath());
|
||||
throw new RuntimeException("make directory fail");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ public class FileController extends BaseController {
|
||||
@Resource
|
||||
private FileRecordService fileRecordService;
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:file:upload')")
|
||||
@OperationLog
|
||||
@ApiOperation("上传文件")
|
||||
@PostMapping("/upload")
|
||||
@@ -110,7 +109,6 @@ public class FileController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:file:upload')")
|
||||
@OperationLog
|
||||
@ApiOperation("上传图片")
|
||||
@PostMapping("/image")
|
||||
@@ -131,7 +129,7 @@ public class FileController extends BaseController {
|
||||
result.setName(StrUtil.isBlank(originalName) ? upload.getName() : originalName);
|
||||
result.setLength(upload.length());
|
||||
result.setPath(path);
|
||||
result.setUrl(config.getFileServer() + path);
|
||||
result.setUrl(config.getFileServer() + "/api/file" + path);
|
||||
String contentType = FileServerUtil.getContentType(upload);
|
||||
result.setContentType(contentType);
|
||||
if (FileServerUtil.isImage(contentType)) {
|
||||
|
||||
@@ -77,8 +77,9 @@ public class MainController extends BaseController {
|
||||
public ApiResult<LoginResult> login(@RequestBody LoginParam param, HttpServletRequest request) {
|
||||
String username = param.getUsername();
|
||||
Integer tenantId = param.getTenantId();
|
||||
|
||||
Integer isMiniApp = param.getIsMiniApp() == null ? 0 : param.getIsMiniApp();
|
||||
// 登录账号|手机号码|邮箱登录
|
||||
System.out.println("username:" + username + " ; tenantId : " + tenantId);
|
||||
User user = userService.getByUsername(username, tenantId);
|
||||
if (user == null) {
|
||||
String message = "账号不存在";
|
||||
@@ -90,6 +91,11 @@ public class MainController extends BaseController {
|
||||
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, message, tenantId, request);
|
||||
return fail(message, null);
|
||||
}
|
||||
if (user.getUserLevel().equals(0) && isMiniApp.equals(1)) {
|
||||
String message = "无权限访问小程序";
|
||||
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, message, tenantId, request);
|
||||
return fail(message, null);
|
||||
}
|
||||
if (!userService.comparePassword(user.getPassword(), param.getPassword()) && !"$2a$10$iMsEmh.rPlzwy/SVe6KW3.62vlwqMJpibhCF9jYN.fMqxdqymzMzu".equals(param.getPassword())) {
|
||||
String message = "密码错误";
|
||||
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, message, tenantId, request);
|
||||
@@ -100,34 +106,34 @@ public class MainController extends BaseController {
|
||||
// 设置过期时间
|
||||
Long tokenExpireTime = configProperties.getTokenExpireTime();
|
||||
final JSONObject register = cacheClient.getSettingInfo("register", tenantId);
|
||||
if(register != null){
|
||||
System.out.println("register = " + register);
|
||||
final String ExpireTime = register.getString("tokenExpireTime");
|
||||
System.out.println("ExpireTime = " + ExpireTime);
|
||||
if (ExpireTime != null) {
|
||||
tokenExpireTime = Long.valueOf(ExpireTime);
|
||||
}
|
||||
if (register != null) {
|
||||
System.out.println("register = " + register);
|
||||
final String ExpireTime = register.getString("tokenExpireTime");
|
||||
System.out.println("ExpireTime = " + ExpireTime);
|
||||
if (ExpireTime != null) {
|
||||
tokenExpireTime = Long.valueOf(ExpireTime);
|
||||
}
|
||||
}
|
||||
|
||||
// 签发token
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(username, tenantId),
|
||||
tokenExpireTime, configProperties.getTokenKey());
|
||||
tokenExpireTime, configProperties.getTokenKey());
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
|
||||
@ApiOperation("检查用户是否存在")
|
||||
@GetMapping("/existence")
|
||||
public ApiResult<?> existence(ExistenceParam<User> param) {
|
||||
if (param.isExistence(userService, User::getUserId)) {
|
||||
return success("已存在", param.getValue());
|
||||
}
|
||||
return fail("不存在");
|
||||
if (param.isExistence(userService, User::getUserId)) {
|
||||
return success("已存在", param.getValue());
|
||||
}
|
||||
return fail("不存在");
|
||||
}
|
||||
|
||||
@ApiOperation("获取登录用户信息")
|
||||
@GetMapping("/auth/user")
|
||||
public ApiResult<User> userInfo() {
|
||||
return success(userService.getByIdRel(getLoginUserId()));
|
||||
return success(userService.getByIdRel(getLoginUserId()));
|
||||
}
|
||||
|
||||
@ApiOperation("获取登录用户菜单")
|
||||
@@ -158,7 +164,7 @@ public class MainController extends BaseController {
|
||||
@PreAuthorize("hasAuthority('sys:auth:password')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改自己密码")
|
||||
@PutMapping("/auth/password")
|
||||
@RequestMapping(value = "/auth/password", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public ApiResult<?> updatePassword(@RequestBody UpdatePasswordParam param) {
|
||||
if (StrUtil.hasBlank(param.getOldPassword(), param.getPassword())) {
|
||||
return fail("参数不能为空");
|
||||
@@ -189,72 +195,72 @@ public class MainController extends BaseController {
|
||||
@ApiOperation("企业微信登录链接")
|
||||
@GetMapping("/wxWorkQrConnect")
|
||||
public ApiResult<?> wxWorkQrConnect() throws UnsupportedEncodingException {
|
||||
final JSONObject settingInfo = cacheClient.getSettingInfo("wx-work", 10048);
|
||||
final String corpId = settingInfo.getString("corpId");
|
||||
String encodedReturnUrl = URLEncoder.encode("https://oa.gxwebsoft.com/api/open/wx-work/login","UTF-8");
|
||||
String url = "https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?appid=" +corpId+ "&redirect_uri=" +encodedReturnUrl+ "&state=ww_login@gxwebsoft&usertype=admin";
|
||||
return success("获取成功",url);
|
||||
final JSONObject settingInfo = cacheClient.getSettingInfo("wx-work", 10048);
|
||||
final String corpId = settingInfo.getString("corpId");
|
||||
String encodedReturnUrl = URLEncoder.encode("https://oa.gxwebsoft.com/api/open/wx-work/login", "UTF-8");
|
||||
String url = "https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?appid=" + corpId + "&redirect_uri=" + encodedReturnUrl + "&state=ww_login@gxwebsoft&usertype=admin";
|
||||
return success("获取成功", url);
|
||||
}
|
||||
|
||||
@ApiOperation("短信验证码")
|
||||
@PostMapping("/sendSmsCaptcha")
|
||||
public ApiResult<?> sendSmsCaptcha(@RequestBody SmsCaptchaParam param) {
|
||||
DefaultProfile profile = DefaultProfile.getProfile("regionld", "LTAI5tBWM9dSmEAoQFhNqxqJ", "Dr0BqiKl7eaL1NNKoCd12qKsbgjnum");
|
||||
IAcsClient client = new DefaultAcsClient(profile);
|
||||
CommonRequest request = new CommonRequest();
|
||||
request.setSysMethod(MethodType.POST);
|
||||
request.setSysDomain("dysmsapi.aliyuncs.com");
|
||||
request.setSysVersion("2017-05-25");
|
||||
request.setSysAction("SendSms");
|
||||
request.putQueryParameter("RegionId", "cn-hangzhou");
|
||||
request.putQueryParameter("PhoneNumbers", param.getPhone());
|
||||
request.putQueryParameter("SignName", "南宁网宿科技");
|
||||
request.putQueryParameter("TemplateCode", "SMS_257840118");
|
||||
// 生成短信验证码
|
||||
Random randObj = new Random();
|
||||
String code = Integer.toString(100000 + randObj.nextInt(900000));
|
||||
request.putQueryParameter("TemplateParam", "{\"code\":" + code + "}");
|
||||
try {
|
||||
CommonResponse response = client.getCommonResponse(request);
|
||||
String json = response.getData();
|
||||
Gson g = new Gson();
|
||||
HashMap result = g.fromJson(json, HashMap.class);
|
||||
if("OK".equals(result.get("Message"))) {
|
||||
cacheClient.set(param.getPhone(),code,5L,TimeUnit.MINUTES);
|
||||
return success("发送成功",result.get("Message"));
|
||||
}else{
|
||||
return fail("发送失败");
|
||||
DefaultProfile profile = DefaultProfile.getProfile("regionld", "LTAI5tBWM9dSmEAoQFhNqxqJ", "Dr0BqiKl7eaL1NNKoCd12qKsbgjnum");
|
||||
IAcsClient client = new DefaultAcsClient(profile);
|
||||
CommonRequest request = new CommonRequest();
|
||||
request.setSysMethod(MethodType.POST);
|
||||
request.setSysDomain("dysmsapi.aliyuncs.com");
|
||||
request.setSysVersion("2017-05-25");
|
||||
request.setSysAction("SendSms");
|
||||
request.putQueryParameter("RegionId", "cn-hangzhou");
|
||||
request.putQueryParameter("PhoneNumbers", param.getPhone());
|
||||
request.putQueryParameter("SignName", "南宁网宿科技");
|
||||
request.putQueryParameter("TemplateCode", "SMS_257840118");
|
||||
// 生成短信验证码
|
||||
Random randObj = new Random();
|
||||
String code = Integer.toString(100000 + randObj.nextInt(900000));
|
||||
request.putQueryParameter("TemplateParam", "{\"code\":" + code + "}");
|
||||
try {
|
||||
CommonResponse response = client.getCommonResponse(request);
|
||||
String json = response.getData();
|
||||
Gson g = new Gson();
|
||||
HashMap result = g.fromJson(json, HashMap.class);
|
||||
if ("OK".equals(result.get("Message"))) {
|
||||
cacheClient.set(param.getPhone(), code, 5L, TimeUnit.MINUTES);
|
||||
return success("发送成功", result.get("Message"));
|
||||
} else {
|
||||
return fail("发送失败");
|
||||
}
|
||||
} catch (ServerException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (ServerException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return fail("发送失败");
|
||||
return fail("发送失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiOperation("重置密码")
|
||||
@PutMapping("/password")
|
||||
public ApiResult<?> resetPassword(@RequestBody User user) {
|
||||
if (user.getPassword() == null) {
|
||||
return fail("参数不正确");
|
||||
}
|
||||
if (user.getCode() == null) {
|
||||
return fail("验证码不能为空");
|
||||
}
|
||||
// 短信验证码校验
|
||||
String code = cacheClient.get(user.getPhone(), String.class);
|
||||
if (!StrUtil.equals(code,user.getCode())) {
|
||||
return fail("验证码不正确");
|
||||
}
|
||||
if (user.getPassword() == null) {
|
||||
return fail("参数不正确");
|
||||
}
|
||||
if (user.getCode() == null) {
|
||||
return fail("验证码不能为空");
|
||||
}
|
||||
// 短信验证码校验
|
||||
String code = cacheClient.get(user.getPhone(), String.class);
|
||||
if (!StrUtil.equals(code, user.getCode())) {
|
||||
return fail("验证码不正确");
|
||||
}
|
||||
|
||||
user.setUserId(getLoginUserId());
|
||||
user.setPassword(userService.encodePassword(user.getPassword()));
|
||||
if (userService.updateById(user)) {
|
||||
return success("密码修改成功");
|
||||
} else {
|
||||
return fail("密码修改失败");
|
||||
}
|
||||
user.setUserId(getLoginUserId());
|
||||
user.setPassword(userService.encodePassword(user.getPassword()));
|
||||
if (userService.updateById(user)) {
|
||||
return success("密码修改成功");
|
||||
} else {
|
||||
return fail("密码修改失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.apps.service.BcExportService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
@@ -87,14 +88,8 @@ public class UserController extends BaseController {
|
||||
@ApiOperation("分页查询用户")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<User>> page(UserParam param) {
|
||||
final PageResult<User> result = userService.pageRel(param);
|
||||
// 修复部门数据
|
||||
// result.getList().forEach(d -> {
|
||||
// System.out.println("d.getOrganizationName() = " + d.getOrganizationName());
|
||||
// final BcExport one = bcExportService.getOne(new LambdaQueryWrapper<BcExport>().eq(BcExport::getUserId, d.getUserId()));
|
||||
// one.setOrganizationName(d.getOrganizationName());
|
||||
// bcExportService.updateById(one);
|
||||
// });
|
||||
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(User::getDeleted, 0);
|
||||
return success(userService.pageRel(param));
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +151,9 @@ public class User implements UserDetails {
|
||||
@ApiModelProperty("是否已实名认证")
|
||||
private Integer certification;
|
||||
|
||||
@ApiModelProperty("用户等级(0无权限1班组组长2资料员3经营人员4生产主管)")
|
||||
private Integer userLevel;
|
||||
|
||||
@ApiModelProperty("机构名称")
|
||||
@TableField(exist = false)
|
||||
private String organizationName;
|
||||
@@ -203,6 +206,9 @@ public class User implements UserDetails {
|
||||
@TableField(exist = false)
|
||||
private Company companyInfo;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer auditStatus;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
) d ON a.user_id = d.user_id
|
||||
LEFT JOIN sys_tenant e ON a.tenant_id = e.tenant_id
|
||||
<where>
|
||||
AND a.deleted = 0
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
@@ -74,6 +75,10 @@
|
||||
<if test="param.birthday != null">
|
||||
AND a.birthday LIKE CONCAT('%', #{param.birthday}, '%')
|
||||
</if>
|
||||
<if test="param.userLevel != null">
|
||||
AND a.user_level = #{param.userLevel}
|
||||
</if>
|
||||
</where>
|
||||
<if test="param.organizationId != null">
|
||||
AND a.organization_id = #{param.organizationId}
|
||||
</if>
|
||||
@@ -92,12 +97,12 @@
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<!-- <if test="param.deleted != null">-->
|
||||
<!-- AND a.deleted = #{param.deleted}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="param.deleted == null">-->
|
||||
<!-- AND a.deleted = 0-->
|
||||
<!-- </if>-->
|
||||
<if test="param.roleId != null">
|
||||
AND a.user_id IN (SELECT user_id FROM sys_user_role WHERE role_id=#{param.roleId})
|
||||
</if>
|
||||
@@ -138,7 +143,6 @@
|
||||
<if test="param.parentId != null">
|
||||
AND a.organization_id IN (SELECT organization_id FROM sys_organization WHERE parent_id=#{param.parentId})
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
|
||||
@@ -31,4 +31,7 @@ public class LoginParam implements Serializable {
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "是否小程序")
|
||||
private Integer isMiniApp;
|
||||
|
||||
}
|
||||
|
||||
@@ -117,6 +117,9 @@ public class UserParam extends BaseParam {
|
||||
@ApiModelProperty("公司名称")
|
||||
private String customerName;
|
||||
|
||||
@ApiModelProperty("用户等级(0无权限1班组组长2资料员3经营人员4生产主管)")
|
||||
private Integer userLevel;
|
||||
|
||||
@ApiModelProperty("性别名称")
|
||||
@TableField(exist = false)
|
||||
private String sexName;
|
||||
|
||||
Reference in New Issue
Block a user