Commit e09dc598 authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd commit

parent 54b93bfe
No preview for this file type
[main] 19/08/2019 17:50:53 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 19/08/2019 17:53:34 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 21/08/2019 15:54:32 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 21/08/2019 15:57:26 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 21/08/2019 15:59:04 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 21/08/2019 16:01:09 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 21/08/2019 16:54:17 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 21/08/2019 17:01:34 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 21/08/2019 17:06:33 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 21/08/2019 17:45:13 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 21/08/2019 22:29:55 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 21/08/2019 22:31:17 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
......@@ -49,8 +49,8 @@
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath>
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath>-->
<version>1.0</version>
</dependency>
<dependency>
......
......@@ -31,27 +31,27 @@ public class CorsFilter implements Filter {
HttpServletRequest request = (HttpServletRequest) req;
// chain.doFilter(req, resp);
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
chain.doFilter(req, resp);
return;
}
if ("/".equals(request.getRequestURI())) {
chain.doFilter(req, resp);
return;
}
String xAuthToken = request.getHeader("X-Auth-Token");
if (xAuthToken == null || "".equals(xAuthToken)) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is null.");
return;
}
Object obj = RedisUtil.getInstance().get(xAuthToken);
if (obj instanceof UserSession) {
chain.doFilter(req, resp);
} else {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is invalid.");
}
chain.doFilter(req, resp);
// if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
// chain.doFilter(req, resp);
// return;
// }
// if ("/".equals(request.getRequestURI())) {
// chain.doFilter(req, resp);
// return;
// }
// String xAuthToken = request.getHeader("X-Auth-Token");
// if (xAuthToken == null || "".equals(xAuthToken)) {
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is null.");
// return;
// }
// Object obj = RedisUtil.getInstance().get(xAuthToken);
// if (obj instanceof UserSession) {
// chain.doFilter(req, resp);
// } else {
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is invalid.");
// }
}
@Override
......
......@@ -24,4 +24,7 @@ public interface ScenarioAnswerRepository extends JpaRepository<ScenarioAnswer,
Integer deleteScenarioAnswersByScenarioQuestionId(Long scenarioQuestionId);
ScenarioAnswer findScenarioAnswerByScenarioAnswerId(Long scenarioAnswerId);
@Query(value = "SELECT COUNT(1) FROM ScenarioAnswer WHERE 1 = 1 AND code = :code AND scenarioQuestionId = :scenarioQuestionId AND scenarioAnswerId <> :scenarioAnswerId")
Integer countDuplicateScenarioCode(@Param("code") String code, @Param("scenarioQuestionId") Long scenarioQuestionId, @Param("scenarioAnswerId") Long scenarioAnswerId);
}
......@@ -2,7 +2,9 @@ package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.model.ccms_full.Scenario;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.data.repository.query.Param;
/**
* @author anhvd_itsol
......@@ -11,4 +13,7 @@ import org.springframework.stereotype.Repository;
@Repository
public interface ScenarioRepository extends JpaRepository<Scenario, Long> {
Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
@Query(value = "SELECT COUNT(1) FROM Scenario WHERE 1 = 1 AND companySiteId = :companySiteId AND code = :code AND scenarioId <> :scenarioId")
Integer countDuplicateScenarioCode(@Param("companySiteId") Long companySiteId, @Param("code") String code, @Param("scenarioId") Long scenarioId);
}
......@@ -13,4 +13,6 @@ public interface ScenarioAnswerService {
Long getMaxAnswerOrderId(Long scenarioQuestionId, Long companySiteId);
ResultDTO delete(ScenarioAnswerDTO scenarioAnswerDTO);
Integer countDuplicateScenarioCode(String code, Long scenarioQuestionId, Long scenarioAnswerId);
}
......@@ -17,4 +17,6 @@ public interface ScenarioService {
ResultDTO update(ScenarioDTO scenario);
ResultDTO sortQuestionAndAnswer(ScenarioDTO scenarioDTO);
Integer countDuplicateScenarioCode(Long companySiteId, String code, Long scenarioId);
}
......@@ -113,4 +113,15 @@ public class ScenarioAnswerServiceImpl implements ScenarioAnswerService {
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Integer countDuplicateScenarioCode(String code, Long scenarioQuestionId, Long scenarioAnswerId) {
try {
return scenarioAnswerRepository.countDuplicateScenarioCode(code, scenarioQuestionId, scenarioAnswerId);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return null;
}
}
......@@ -117,4 +117,15 @@ public class ScenarioServiceImpl implements ScenarioService {
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Integer countDuplicateScenarioCode(Long companySiteId, String code, Long scenarioId) {
try {
return scenarioRepository.countDuplicateScenarioCode(companySiteId, code, scenarioId);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return null;
}
}
......@@ -37,4 +37,10 @@ public class ScenarioAnswerController {
ResultDTO resultDTO = scenarioAnswerService.delete(answerDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/count-duplicate-code", method = RequestMethod.GET)
ResponseEntity<Integer> countDuplicateCode(@RequestParam String code, @RequestParam Long scenarioQuestionId, @RequestParam Long scenarioAnswerId) {
Integer count = scenarioAnswerService.countDuplicateScenarioCode(code, scenarioQuestionId, scenarioAnswerId);
return new ResponseEntity<>(count, HttpStatus.OK);
}
}
......@@ -23,7 +23,7 @@ public class ScenarioController {
@Autowired
ScenarioService scenarioService;
@RequestMapping(value="/findOneByCampaignIdAndCompanyId", method = RequestMethod.GET)
@RequestMapping(value = "/findOneByCampaignIdAndCompanyId", method = RequestMethod.GET)
Scenario findOneByCampaignIdAndCompanyId(@RequestParam Long campaignId, @RequestParam Long companySiteId) {
return scenarioService.findScenarioByCampaignIdAndCompanySiteId(campaignId, companySiteId);
}
......@@ -39,4 +39,10 @@ public class ScenarioController {
ResultDTO resultDTO = scenarioService.sortQuestionAndAnswer(scenarioDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/count-duplicate-code", method = RequestMethod.GET)
ResponseEntity<Integer> countDuplicateCode(@RequestParam String code, @RequestParam Long scenarioId, @RequestParam Long companySiteId) {
Integer count = scenarioService.countDuplicateScenarioCode(companySiteId, code, scenarioId);
return new ResponseEntity<>(count, HttpStatus.OK);
}
}
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