Commit a9761422 authored by ma's avatar ma

完善查询应用列表

parent 6ac67a3d
......@@ -46,7 +46,7 @@ public class AuthManager {
public void initApps() {
allApply = new HashMap<>();
PageInfoModel<AppVo> records = applyService.getAppList(1, 10000, "");
PageInfoModel<AppVo> records = applyService.getAppList(1, 10000, null, "");
List<AppVo> appList = records.getResult();
for (Apply apply : appList) {
String appId = apply.getAppId();
......
......@@ -9,6 +9,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.handler.IotLicenseException;
import iot.sixiang.license.jwt.UserUtils;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.BaseResult;
......@@ -17,6 +19,7 @@ import iot.sixiang.license.model.PageResult;
import iot.sixiang.license.model.vo.AppVo;
import iot.sixiang.license.service.ApplyService;
import iot.sixiang.license.xss.XssUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.WebDataBinder;
......@@ -90,7 +93,11 @@ public class ApplyController {
@RequestParam(value = "pageSize", defaultValue = "0") int pageSize,
@RequestParam(value = "appName", required = false) String appName) {
appName = XssUtil.checkXSS(appName);
PageInfoModel<AppVo> records = applyService.getAppList(pageNo, pageSize, appName);
String userId = UserUtils.getLoginUserId();
if (StringUtils.isEmpty(userId)) {
throw new IotLicenseException(403, "请重新登录");
}
PageInfoModel<AppVo> records = applyService.getAppList(pageNo, pageSize, Integer.parseInt(userId), appName);
int total = records.getTotal();
int pages = total / pageSize;//pages为总页数
int mod = total % pageSize;
......
......@@ -18,7 +18,7 @@ public interface ApplyMapper extends BaseMapper<Apply> {
boolean addApply(String appId, String appName, String appKey, int userId);
List<AppVo> getAppList(String appName);
List<AppVo> getAppList(Integer userId, String appName);
Apply getApplyByAppName(String appName);
}
......@@ -17,5 +17,5 @@ public interface ApplyService extends IService<Apply> {
boolean addApply(String appName, String appKey, int userId);
PageInfoModel<AppVo> getAppList(int pageNo, int pageSize, String appName);
PageInfoModel<AppVo> getAppList(int pageNo, int pageSize, Integer userId, String appName);
}
......@@ -54,11 +54,11 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements
}
@Override
public PageInfoModel<AppVo> getAppList(int pageNo, int pageSize, String appName) {
public PageInfoModel<AppVo> getAppList(int pageNo, int pageSize, Integer userId, String appName) {
if(pageNo == 0 || pageSize == 0) {
throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg());
}
List<AppVo> records = applyMapper.getAppList(appName);
List<AppVo> records = applyMapper.getAppList(userId, appName);
records = records.stream().sorted(Comparator.comparing(AppVo::getCreateTime, Comparator.reverseOrder())).collect(Collectors.toList());
List<AppVo> result = new ArrayList<>();
int begin = (pageNo - 1) * pageSize;
......
......@@ -14,8 +14,11 @@
FROM apply AS app LEFT JOIN device AS de ON app.app_id = de.app_id
LEFT JOIN user AS us ON us.user_id = app.user_id
where 1=1
<if test="null != _parameter and '' != _parameter">
and app_name like concat('%',#{_parameter},'%')
<if test="null != userId">
and us.user_id = #{userId}
</if>
<if test="null != appName and '' != appName">
and app_name like concat('%',#{appName},'%')
</if>
GROUP BY app.app_id
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment