Commit a24e44db authored by lining's avatar lining

feat: 服务类型接口

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