Commit a24e44db authored by lining's avatar lining

feat: 服务类型接口

parent f84d97f9
......@@ -3,5 +3,10 @@ package com.onsiteservice.dao.mapper.service;
import com.onsiteservice.dao.common.Mapper;
import com.onsiteservice.entity.category.ServiceCategory;
import java.util.List;
public interface ServiceCategoryMapper extends Mapper<ServiceCategory> {
List<ServiceCategory> selectAllOrderBySequence();
}
\ No newline at end of file
......@@ -3,5 +3,10 @@ package com.onsiteservice.dao.mapper.service;
import com.onsiteservice.dao.common.Mapper;
import com.onsiteservice.entity.category.ServiceSubclass;
import java.util.List;
public interface ServiceSubclassMapper extends Mapper<ServiceSubclass> {
List<ServiceSubclass> selectByServiceNameLike(String keyWord);
}
\ No newline at end of file
......@@ -5,13 +5,18 @@
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="service_name" jdbcType="VARCHAR" property="serviceName" />
<result column="sequence" jdbcType="INTEGER" property="sequence" />
<result column="img" jdbcType="VARCHAR" property="img" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="modify_by" jdbcType="VARCHAR" property="modifyBy" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="service_name" jdbcType="VARCHAR" property="serviceName"/>
<result column="sequence" jdbcType="INTEGER" property="sequence"/>
<result column="img" jdbcType="VARCHAR" property="img"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="modify_by" jdbcType="VARCHAR" property="modifyBy"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
</resultMap>
<select id="selectAllOrderBySequence" resultType="com.onsiteservice.entity.category.ServiceCategory">
select * from service_category order by sequence asc
</select>
</mapper>
\ No newline at end of file
......@@ -3,7 +3,6 @@
<mapper namespace="com.onsiteservice.dao.mapper.service.ServiceOrderMapper">
<select id="selectServiceOrderPage" resultType="com.onsiteservice.entity.order.ServiceOrder">
<bind name="p1" value="'%' + keyWord + '%'"/>
select *
from service_order
where
......@@ -15,6 +14,7 @@
and date_format(create_time,'%Y%m') = #{month}
</if>
<if test="keyWord != null and keyWord != ''">
<bind name="p1" value="'%' + keyWord + '%'"/>
and (service_name like #{p1} or address like #{p1} or name like #{p1})
</if>
order by create_time asc
......
......@@ -5,14 +5,24 @@
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="category_id" jdbcType="INTEGER" property="categoryId" />
<result column="service_name" jdbcType="VARCHAR" property="serviceName" />
<result column="sequence" jdbcType="INTEGER" property="sequence" />
<result column="img" jdbcType="VARCHAR" property="img" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="modify_by" jdbcType="VARCHAR" property="modifyBy" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="category_id" jdbcType="INTEGER" property="categoryId"/>
<result column="service_name" jdbcType="VARCHAR" property="serviceName"/>
<result column="sequence" jdbcType="INTEGER" property="sequence"/>
<result column="img" jdbcType="VARCHAR" property="img"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="modify_by" jdbcType="VARCHAR" property="modifyBy"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
</resultMap>
<select id="selectByServiceNameLike" resultType="com.onsiteservice.entity.category.ServiceSubclass">
select * from service_subclass
<if test="keyWord != null and keyWord != ''">
<bind name="p1" value="'%' + keyWord + '%'"/>
where service_name like #{p1}
</if>
order by sequence asc
</select>
</mapper>
\ No newline at end of file
......@@ -10,14 +10,13 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.NonNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
import static com.onsiteservice.core.result.ResultGenerator.success;
/**
......@@ -37,11 +36,17 @@ public class ServiceCategoryController {
private ServiceCategoryService serviceCategoryService;
@ApiOperation(value = "分页查询服务大类")
@ApiOperation(value = "查询服务大类")
@GetMapping("list")
public Result<List<ServiceCategoryVO>> list(@RequestParam(required = false) String keyWord) {
return serviceCategoryService.list(keyWord);
}
/*@ApiOperation(value = "分页查询服务大类")
@PostMapping("page")
public Result<PageInfoVO<ServiceCategoryVO>> getPage(@RequestBody @NonNull @Validated PageServiceCategoryDTO dto) {
return serviceCategoryService.getPage(dto);
}
}*/
}
package com.onsiteservice.miniapp.controller.category;
import com.onsiteservice.core.result.Result;
import com.onsiteservice.dao.common.page.PageInfoVO;
import com.onsiteservice.dao.common.page.PageParams;
import com.onsiteservice.miniapp.controller.category.dto.PageServiceSubclassDTO;
import com.onsiteservice.miniapp.controller.category.vo.ServiceSubclassVO;
import com.onsiteservice.miniapp.service.category.ServiceSubclassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.NonNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import static com.onsiteservice.core.result.ResultGenerator.success;
/**
* <P>服务大类模块</P>
*
......@@ -37,11 +25,11 @@ public class ServiceSubclassController {
private ServiceSubclassService serviceSubclassService;
@ApiOperation(value = "分页查询列表")
/*@ApiOperation(value = "分页查询列表")
@PostMapping("page")
public Result<PageInfoVO<ServiceSubclassVO>> getPage(@RequestBody @NonNull @Validated PageServiceSubclassDTO dto) {
return serviceSubclassService.getPage(dto);
}
}*/
}
......@@ -2,6 +2,7 @@ package com.onsiteservice.miniapp.controller.category.dto;
import com.onsiteservice.dao.common.page.PageParams;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
......@@ -16,4 +17,8 @@ import lombok.EqualsAndHashCode;
@Data
@ApiModel("分页查询服务子类请求模型")
public class PageServiceSubclassDTO extends PageParams {
@ApiModelProperty(value = "服务子类名")
private String keyWord;
}
......@@ -2,43 +2,19 @@ package com.onsiteservice.miniapp.controller.category.vo;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class ServiceCategoryVO {
/**
* 主键
*/
private Integer id;
/**
* 服务名称
*/
private String serviceName;
private Integer sequence;
private String img;
/**
* 创建人
*/
private String createBy;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改人
*/
private String modifyBy;
/**
* 修改时间
*/
private Date modifyTime;
private List<ServiceSubclassVO> children;
}
\ No newline at end of file
......@@ -7,9 +7,6 @@ import java.util.Date;
@Data
public class ServiceSubclassVO {
/**
* 主键
*/
private Integer id;
private Integer categoryId;
......@@ -20,24 +17,4 @@ public class ServiceSubclassVO {
private String img;
/**
* 创建人
*/
private String createBy;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改人
*/
private String modifyBy;
/**
* 修改时间
*/
private Date modifyTime;
}
\ No newline at end of file
package com.onsiteservice.miniapp.service.category;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import com.onsiteservice.core.result.Result;
import com.onsiteservice.core.result.ResultGenerator;
import com.onsiteservice.dao.common.AbstractMapper;
import com.onsiteservice.dao.common.page.PageInfoVO;
import com.onsiteservice.dao.mapper.service.ServiceCategoryMapper;
import com.onsiteservice.dao.mapper.service.ServiceSubclassMapper;
import com.onsiteservice.entity.category.ServiceCategory;
import com.onsiteservice.miniapp.controller.category.dto.PageServiceCategoryDTO;
import com.onsiteservice.entity.category.ServiceSubclass;
import com.onsiteservice.miniapp.controller.category.vo.ServiceCategoryVO;
import com.onsiteservice.miniapp.mapper.category.ServiceCategoryBizMapper;
import com.onsiteservice.miniapp.controller.category.vo.ServiceSubclassVO;
import com.onsiteservice.util.AttrCopyUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class ServiceCategoryService extends AbstractMapper<ServiceCategory> {
//@Resource
//private ServiceCategoryBizMapper serviceCategoryBizMapper;
@Resource
private ServiceCategoryMapper serviceCategoryMapper;
@Resource
private ServiceCategoryBizMapper serviceCategoryBizMapper;
private ServiceSubclassMapper serviceSubclassMapper;
/**
* 分页查询列表
*/
public Result<PageInfoVO<ServiceCategoryVO>> getPage(PageServiceCategoryDTO dto) {
/*public Result<PageInfoVO<ServiceCategoryVO>> getPage(PageServiceCategoryDTO dto) {
PageHelper.startPage(dto.getPage(), dto.getSize());
List<ServiceCategory> serviceCategoryList = serviceCategoryBizMapper.selectServiceCategoryPage(dto);
List<ServiceCategoryVO> serviceCategoryVOList = serviceCategoryList.parallelStream()
.map(e -> AttrCopyUtils.copy(e, new ServiceCategoryVO())).collect(Collectors.toList());
return ResultGenerator.success(new PageInfoVO<>(serviceCategoryVOList));
}*/
public Result<List<ServiceCategoryVO>> list(String keyWord) {
List<ServiceCategory> serviceCategoryList = serviceCategoryMapper.selectAllOrderBySequence();
List<ServiceSubclass> serviceSubclassList = serviceSubclassMapper.selectByServiceNameLike(keyWord);
Map<Integer, List<ServiceSubclass>> categoryIdServiceSubclassMap = serviceSubclassList.parallelStream().collect(Collectors.groupingBy(ServiceSubclass::getCategoryId));
List<ServiceCategoryVO> serviceCategoryVOList = serviceCategoryList.parallelStream().map(e -> {
ServiceCategoryVO serviceCategoryVO = AttrCopyUtils.copy(e, new ServiceCategoryVO());
List<ServiceSubclass> childServiceSubclassList = categoryIdServiceSubclassMap.getOrDefault(serviceCategoryVO.getId(), Lists.newArrayList());
List<ServiceSubclassVO> childServiceSubclassVOList = childServiceSubclassList.parallelStream().map(e1 -> AttrCopyUtils.copy(e1, new ServiceSubclassVO())).collect(Collectors.toList());
serviceCategoryVO.setChildren(childServiceSubclassVOList);
return serviceCategoryVO;
}).collect(Collectors.toList());
return ResultGenerator.success(serviceCategoryVOList);
}
......
package com.onsiteservice.miniapp.service.category;
import com.github.pagehelper.PageHelper;
import com.onsiteservice.core.result.Result;
import com.onsiteservice.core.result.ResultGenerator;
import com.onsiteservice.dao.common.AbstractMapper;
import com.onsiteservice.dao.common.page.PageInfoVO;
import com.onsiteservice.entity.category.ServiceSubclass;
import com.onsiteservice.miniapp.controller.category.dto.PageServiceSubclassDTO;
import com.onsiteservice.miniapp.controller.category.vo.ServiceSubclassVO;
import com.onsiteservice.miniapp.mapper.category.ServiceSubclassBizMapper;
import com.onsiteservice.util.AttrCopyUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
......@@ -24,12 +15,12 @@ public class ServiceSubclassService extends AbstractMapper<ServiceSubclass> {
@Resource
private ServiceSubclassBizMapper serviceSubclassBizMapper;
public Result<PageInfoVO<ServiceSubclassVO>> getPage(PageServiceSubclassDTO dto) {
/*public Result<PageInfoVO<ServiceSubclassVO>> getPage(PageServiceSubclassDTO dto) {
PageHelper.startPage(dto.getPage(), dto.getSize());
List<ServiceSubclass> serviceSubclassList = serviceSubclassBizMapper.selectServiceSubclassPage(dto);
List<ServiceSubclassVO> serviceSubclassVOList = serviceSubclassList.parallelStream()
.map(e -> AttrCopyUtils.copy(e, new ServiceSubclassVO())).collect(Collectors.toList());
return ResultGenerator.success(new PageInfoVO<>(serviceSubclassVOList));
}
}*/
}
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