• WebService框架cxf


    1、配置类

     1 package com.baibeiyun.costume.base.config;
     2 
     3 import com.baibeiyun.costume.controller.webservice.WBSortOutService;
     4 import org.apache.cxf.Bus;
     5 import org.apache.cxf.bus.spring.SpringBus;
     6 import org.apache.cxf.jaxws.EndpointImpl;
     7 import org.apache.cxf.transport.servlet.CXFServlet;
     8 import org.springframework.beans.factory.annotation.Autowired;
     9 import org.springframework.boot.web.servlet.ServletRegistrationBean;
    10 import org.springframework.context.annotation.Bean;
    11 import org.springframework.context.annotation.Configuration;
    12 
    13 import javax.xml.ws.Endpoint;
    14 
    15 /**
    16  * @author zh
    17  * @date 2019/11/23
    18  */
    19 @Configuration
    20 public class CxfConfig {
    21 
    22     @Autowired
    23     private Bus bus;
    24 
    25     @Autowired
    26     private WBSortOutService wbSortOutService;
    27 
    28     @Bean
    29     public ServletRegistrationBean disServlet() {
    30         return new ServletRegistrationBean(new CXFServlet(), "/erp/*");
    31     }
    32 
    33     @Bean(name = Bus.DEFAULT_BUS_ID)
    34     public SpringBus springBus() {
    35         return new SpringBus();
    36     }
    37 
    38     /**
    39      * 分拣规则
    40      */
    41     @Bean
    42     public Endpoint wBUserService() {
    43         EndpointImpl endpoint = new EndpointImpl(bus, wbSortOutService);
    44         endpoint.publish("/sortOut");
    45         return endpoint;
    46     }
    47 }

    2、service接口

     1 package com.baibeiyun.costume.controller.webservice;
     2 
     3 
     4 import com.baibeiyun.costume.base.dto.sort.SaveSortRuleDto;
     5 import com.baibeiyun.costume.base.util.WsResultModel;
     6 
     7 import javax.jws.WebMethod;
     8 import javax.jws.WebService;
     9 import java.util.List;
    10 
    11 
    12 /**
    13  * <p>
    14  * 分拣规则 服务类
    15  * </p>
    16  *
    17  * @author zh
    18  * @since 2019/11/6
    19  */
    20 @WebService
    21 public interface WBSortOutService {
    22 
    23     /**
    24      * 获取设计小组列表
    25      *
    26      * @return ResultModel
    27      * @author zh
    28      * @date 2019/11/6
    29      */
    30     @WebMethod
    31     WsResultModel getDesignTeamList();
    32 
    33     /**
    34      * 获取一级类目列表
    35      *
    36      * @return ResultModel
    37      * @author zh
    38      * @date 2019/11/6
    39      */
    40     @WebMethod
    41     WsResultModel getCategoryOneList();
    42 
    43     /**
    44      * 获取颜色列表
    45      *
    46      * @return ResultModel
    47      * @author zh
    48      * @date 2019/11/6
    49      */
    50     @WebMethod
    51     WsResultModel getColorList();
    52 
    53     /**
    54      * 获取码段列表
    55      *
    56      * @return ResultModel
    57      * @author zh
    58      * @date 2019/11/6
    59      */
    60     @WebMethod
    61     WsResultModel getCodeSegmentList();
    62 
    63 
    64     /**
    65      * 保存分拣数据
    66      *
    67      *@param list 分拣数据
    68      *@return WsResultModel
    69      *@author yb
    70      *@date 2019/11/11 19:49
    71      */
    72     @WebMethod
    73     WsResultModel saveSortRuleList(List<SaveSortRuleDto> list);
    74 
    75     /**
    76      * 获取分拣规则列表
    77      *
    78      *@return WsResultModel
    79      *@author yb
    80      *@date 2019/11/11 21:53
    81      */
    82     @WebMethod
    83     WsResultModel getSortRuleList();
    84 }

    3、ServiceImpl实现类

      1 package com.baibeiyun.costume.controller.webservice.impl;
      2 
      3 import com.baibeiyun.costume.base.dao.*;
      4 import com.baibeiyun.costume.base.dto.sort.SaveSortRuleDto;
      5 import com.baibeiyun.costume.base.entity.SortRule;
      6 import com.baibeiyun.costume.base.result.sortOut.*;
      7 import com.baibeiyun.costume.base.service.ISortRuleService;
      8 import com.baibeiyun.costume.base.util.PropertiesUtils;
      9 import com.baibeiyun.costume.base.util.SomeUtil;
     10 import com.baibeiyun.costume.base.util.WsResultModel;
     11 import com.baibeiyun.costume.base.util.WsResultUtil;
     12 import com.baibeiyun.costume.controller.webservice.WBSortOutService;
     13 import com.baibeiyun.costume.exception.custom.MyParameterException;
     14 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
     15 import org.springframework.beans.BeanUtils;
     16 import org.springframework.stereotype.Service;
     17 import org.springframework.web.bind.annotation.RequestParam;
     18 
     19 import javax.annotation.Resource;
     20 import javax.jws.WebService;
     21 import java.util.ArrayList;
     22 import java.util.List;
     23 
     24 /**
     25  * <p>
     26  * 分拣规则 服务实现类
     27  * </p>
     28  *
     29  * @author zh
     30  * @since 2019-11-6
     31  */
     32 @Service
     33 @WebService(serviceName = "sortOutService",
     34         endpointInterface = "com.baibeiyun.costume.controller.webservice.WBSortOutService"
     35 )
     36 public class WBSortOutServiceImpl implements WBSortOutService {
     37 
     38     @Resource
     39     private AdminDepartmentMapper adminDepartmentMapper;
     40     @Resource
     41     private DesignCategoryEditMapper designCategoryEditMapper;
     42     @Resource
     43     private DesignColorEditMapper designColorEditMapper;
     44     @Resource
     45     private DesignCodeSegmentMapper designCodeSegmentMapper;
     46     @Resource
     47     private ISortRuleService iSortRuleService;
     48     @Resource
     49     private SortRuleMapper sortRuleMapper;
     50 
     51     /**
     52      * 获取设计小组列表
     53      *
     54      * @return ResultModel
     55      * @author zh
     56      * @date 2019/11/6
     57      */
     58     @Override
     59     public WsResultModel getDesignTeamList() {
     60         String designCode = PropertiesUtils.getInstace("config/webService.properties").getProperty("designCode");
     61         List<DesignTeamResult> list = adminDepartmentMapper.getTeamIdAndNames(designCode);
     62         return WsResultUtil.wsSuccessWithDataAndMsg(list, "查询成功");
     63     }
     64 
     65     /**
     66      * 获取一级类目列表
     67      *
     68      * @return ResultModel
     69      * @author zh
     70      * @date 2019/11/6
     71      */
     72     @Override
     73     public WsResultModel getCategoryOneList() {
     74         List<CategoryResult> list = designCategoryEditMapper.getTwoCategoryList();
     75         return WsResultUtil.wsSuccessWithDataAndMsg(list, "查询成功");
     76     }
     77 
     78     /**
     79      * 获取颜色列表
     80      *
     81      * @return ResultModel
     82      * @author zh
     83      * @date 2019/11/6
     84      */
     85     @Override
     86     public WsResultModel getColorList() {
     87         List<ColorResult> list = designColorEditMapper.getColorList();
     88         return WsResultUtil.wsSuccessWithDataAndMsg(list, "查询成功");
     89     }
     90 
     91     /**
     92      * 获取码段列表
     93      *
     94      * @return ResultModel
     95      * @author zh
     96      * @date 2019/11/6
     97      */
     98     @Override
     99     public WsResultModel getCodeSegmentList() {
    100         List<CodeSegmentResult> list = designCodeSegmentMapper.getCodeSegmentList();
    101         return WsResultUtil.wsSuccessWithDataAndMsg(list, "查询成功");
    102     }
    103 
    104     /**
    105      * 保存分拣数据
    106      *
    107      * @param list 分拣数据
    108      * @return WsResultModel
    109      * @author yb
    110      * @date 2019/11/11 19:53
    111      */
    112     @Override
    113     public WsResultModel saveSortRuleList(@RequestParam List<SaveSortRuleDto> list) {
    114 
    115         if (SomeUtil.isNoEmpty(list) && list.size() > 0) {
    116             List<SortRule> list1 = new ArrayList<>();
    117             for (SaveSortRuleDto SortRuleDto : list) {
    118                 SortRule sortRule = new SortRule();
    119                 BeanUtils.copyProperties(SortRuleDto, sortRule);
    120                 sortRule.setId(SortRuleDto.getId());
    121                 sortRule.setSeason(SortRuleDto.getSeason());
    122                 sortRule.setCostumeType(SortRuleDto.getCostumeType());
    123                 list1.add(sortRule);
    124             }
    125             boolean b = iSortRuleService.saveOrUpdateBatch(list1);
    126             if (!b) {
    127                 throw new MyParameterException(400, "保存失败");
    128             }
    129         }
    130         return WsResultUtil.wsSuccessWithMsg("保存成功");
    131     }
    132 
    133     /**
    134      * 获取分拣规则列表
    135      *
    136      * @return WsResultModel
    137      * @author yb
    138      * @date 2019/11/11 21:53
    139      */
    140     @Override
    141     public WsResultModel getSortRuleList() {
    142 
    143 //      List<SortRuleResult> sortRuleList = sortRuleMapper.getSortRuleList(new QueryWrapper<SortRule>());
    144 
    145         //直接查询SortRule表
    146         List<SortRule> sortRules = sortRuleMapper.selectList(new QueryWrapper<>());
    147 
    148         return WsResultUtil.wsFailWithResultAndMsg(sortRules, "查询成功");
    149     }
    150 }
  • 相关阅读:
    红黑树——以无厚入有间
    红黑树——依天理以神遇
    B-树 分合之道
    B-树 动机与结构
    云心出岫——Splay Tree
    双散列和再散列暨散列表总结
    开放定址法——平方探测(Quadratic Probing)
    [LeetCode 109]
    [LeetCode 110]
    [LeetCode 111]
  • 原文地址:https://www.cnblogs.com/04241202-nan/p/11917848.html
Copyright © 2020-2023  润新知