Search in sources :

Example 1 with ServiceHallExample

use of com.itrus.portal.db.ServiceHallExample in project portal by ixinportal.

the class ServiceProviderController method delete.

// 删除服务商
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id) {
    ServiceProvider serviceProvider = ServiceProviderService.selectByPrimaryKey(id);
    if (null == serviceProvider) {
        return "未找到要删除的服务商";
    } else {
        try {
            ServiceProviderService.deleteByPrimaryKey(id);
            List<ServiceHall> serviceHalls = serviceHallService.getServiceHalls(id);
            if (null != serviceHalls && !serviceHalls.isEmpty()) {
                List<Long> list = new ArrayList<>();
                for (ServiceHall serviceHall : serviceHalls) {
                    list.add(serviceHall.getId());
                }
                ServiceHallExample example = new ServiceHallExample();
                ServiceHallExample.Criteria criteria = example.or();
                criteria.andServiceProviderIn(list);
                serviceHallService.deleteByExample(example);
            }
        } catch (Exception e) {
            return "要删除的服务商:" + serviceProvider.getName() + "存在关联,无法删除";
        }
    }
    return null;
}
Also used : ServiceProvider(com.itrus.portal.db.ServiceProvider) ArrayList(java.util.ArrayList) ServiceHall(com.itrus.portal.db.ServiceHall) ServiceHallExample(com.itrus.portal.db.ServiceHallExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with ServiceHallExample

use of com.itrus.portal.db.ServiceHallExample in project portal by ixinportal.

the class ServiceHallServiceImpl method getServiceHalls.

/**
 * 根据服务商ID,获取服务商的网点信息,根据优先级排序
 * @param id
 * @return
 * @throws Exception
 */
public List<ServiceHall> getServiceHalls(Long id) throws Exception {
    List<ServiceHall> serviceHalls = new ArrayList<>();
    ServiceHallExample example = new ServiceHallExample();
    ServiceHallExample.Criteria criteria = example.or();
    criteria.andServiceProviderEqualTo(id);
    example.setOrderByClause("priority ASC");
    serviceHalls = selectByExample(example);
    return serviceHalls;
}
Also used : ArrayList(java.util.ArrayList) ServiceHall(com.itrus.portal.db.ServiceHall) ServiceHallExample(com.itrus.portal.db.ServiceHallExample)

Aggregations

ServiceHall (com.itrus.portal.db.ServiceHall)2 ServiceHallExample (com.itrus.portal.db.ServiceHallExample)2 ArrayList (java.util.ArrayList)2 ServiceProvider (com.itrus.portal.db.ServiceProvider)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1