|
@@ -2,21 +2,27 @@ package cn.com.ctop.alarm.modules.controller;
|
|
|
|
|
|
import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
|
|
|
import cn.com.ctop.alarm.modules.entity.RuleTemplate;
|
|
|
+import cn.com.ctop.alarm.modules.entity.vo.TemplateAppliedVo;
|
|
|
import cn.com.ctop.alarm.modules.service.IRuleAccountTemplateService;
|
|
|
import cn.com.ctop.alarm.modules.service.IRuleAccountThresholdService;
|
|
|
import cn.com.ctop.alarm.modules.service.IRuleTemplateService;
|
|
|
import cn.com.ctop.common.module.annotation.AutoLog;
|
|
|
+import cn.com.ctop.common.module.service.ISysRoleExtService;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
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.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
@@ -58,6 +64,51 @@ public class RuleAccountTemplateController {
|
|
|
@Autowired
|
|
|
private IRuleAccountThresholdService accountThresholdService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysRoleExtService sysRoleService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询账户下关联的模板
|
|
|
+ *
|
|
|
+ * @param page
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/getTemplateApplied")
|
|
|
+ public Result<PageInfo<TemplateAppliedVo>> getTemplateApplied(int page, int pageSize, Long accountId, String projectName, String userName) {
|
|
|
+ Result<PageInfo<TemplateAppliedVo>> result = new Result<>();
|
|
|
+ try {
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ String roleCode = sysRoleService.getRoleCodeByUserId(sysUser.getId());
|
|
|
+ Map<String, Object> requestMap = new JSONObject();
|
|
|
+ if (!"admin".equals(roleCode)) {
|
|
|
+ requestMap.put("userId", sysUser.getId());
|
|
|
+ }
|
|
|
+ if (!Check.isNull(accountId)) {
|
|
|
+ requestMap.put("accountId", accountId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Check.isNull(projectName)) {
|
|
|
+ requestMap.put("projectName", projectName);
|
|
|
+ }
|
|
|
+ if (!Check.isNull(userName)) {
|
|
|
+ requestMap.put("userName", userName);
|
|
|
+ }
|
|
|
+ PageHelper.startPage(page, pageSize);
|
|
|
+ List<TemplateAppliedVo> list = ruleAccountTemplateService.getTemplateApplied(requestMap);
|
|
|
+
|
|
|
+ PageInfo<TemplateAppliedVo> pageInfo = new PageInfo<>(list);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(pageInfo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ result.setSuccess(false);
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@GetMapping(value = "/checkAccountTemplate")
|
|
|
public Result<JSONObject> checkAccountTemplate(Long accountId) {
|
|
|
Result<JSONObject> result = new Result<>();
|