use of com.ngtesting.platform.entity.TestCustomFieldOption in project ngtesting-platform by aaronchen2k.
the class CustomFieldOptionServiceImpl method genVos.
@Override
public List<CustomFieldOptionVo> genVos(List<TestCustomFieldOption> pos) {
List<CustomFieldOptionVo> vos = new LinkedList<>();
for (TestCustomFieldOption po : pos) {
CustomFieldOptionVo vo = genVo(po);
vos.add(vo);
}
return vos;
}
use of com.ngtesting.platform.entity.TestCustomFieldOption in project ngtesting-platform by aaronchen2k.
the class CustomFieldOptionAction method save.
@AuthPassport(validate = true)
@RequestMapping(value = "save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> save(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
CustomFieldOptionVo option = JSON.parseObject(JSON.toJSONString(json.getJSONObject("model")), CustomFieldOptionVo.class);
TestCustomFieldOption po = customFieldOptionService.save(option);
List<CustomFieldOptionVo> vos = customFieldOptionService.listVos(po.getFieldId());
ret.put("data", vos);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.entity.TestCustomFieldOption in project ngtesting-platform by aaronchen2k.
the class CustomFieldOptionServiceImpl method changeOrderPers.
@Override
public boolean changeOrderPers(Long id, String act, Long fieldId) {
TestCustomFieldOption opt = (TestCustomFieldOption) get(TestCustomFieldOption.class, id);
String hql = "from TestCustomFieldOption opt where opt.fieldId=? and opt.deleted = false and opt.disabled = false ";
if ("up".equals(act)) {
hql += "and opt.ordr < ? order by ordr desc";
} else if ("down".equals(act)) {
hql += "and opt.ordr > ? order by ordr asc";
} else {
return false;
}
TestCustomFieldOption neighbor = (TestCustomFieldOption) getDao().findFirstByHQL(hql, fieldId, opt.getOrdr());
Integer order = opt.getOrdr();
opt.setOrdr(neighbor.getOrdr());
neighbor.setOrdr(order);
saveOrUpdate(opt);
saveOrUpdate(neighbor);
return true;
}
use of com.ngtesting.platform.entity.TestCustomFieldOption in project ngtesting-platform by aaronchen2k.
the class CustomFieldOptionServiceImpl method save.
@Override
public TestCustomFieldOption save(CustomFieldOptionVo vo) {
if (vo == null) {
return null;
}
TestCustomFieldOption po;
if (vo.getId() != null) {
po = (TestCustomFieldOption) get(TestCustomFieldOption.class, vo.getId());
} else {
po = new TestCustomFieldOption();
}
BeanUtilEx.copyProperties(po, vo);
if (vo.getId() == null) {
String hql = "select max(ordr) from TestCustomFieldOption opt where opt.fieldId = ?";
Object obj = getByHQL(hql, vo.getFieldId());
Integer maxOrder = obj != null ? (Integer) getByHQL(hql, vo.getFieldId()) : 10;
po.setOrdr(maxOrder + 10);
}
saveOrUpdate(po);
return po;
}
Aggregations