| @@ -0,0 +1,73 @@ | ||||
| package com.stdiet.web.controller.common; | ||||
|  | ||||
| import com.stdiet.common.core.controller.BaseController; | ||||
| import com.stdiet.common.core.domain.AjaxResult; | ||||
| import com.stdiet.common.core.page.TableDataInfo; | ||||
| import com.stdiet.custom.domain.SysCustomer; | ||||
| import com.stdiet.custom.domain.SysPhysicalSigns; | ||||
| import com.stdiet.custom.dto.request.CustomerInvestigateRequest; | ||||
| import com.stdiet.custom.service.ISysCustomerService; | ||||
| import com.stdiet.custom.service.ISysPhysicalSignsService; | ||||
| import com.stdiet.system.service.ISysDictTypeService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 客户信息调查Controller | ||||
|  * | ||||
|  * @author xzj | ||||
|  * @date 2020-12-31 | ||||
|  */ | ||||
| @RestController | ||||
| @RequestMapping("/investigate") | ||||
| public class InvestigateController extends BaseController { | ||||
|  | ||||
|     @Autowired | ||||
|     private ISysCustomerService iSysCustomerService; | ||||
|  | ||||
|     @Autowired | ||||
|     private ISysPhysicalSignsService iSysPhysicalSignsService; | ||||
|  | ||||
|     @Autowired | ||||
|     private ISysDictTypeService dictTypeService; | ||||
|  | ||||
|     /** | ||||
|      * 建立客户信息档案 | ||||
|      */ | ||||
|     @PostMapping("/customerInvestigate") | ||||
|     public AjaxResult customerInvestigate(@RequestBody CustomerInvestigateRequest customerInvestigateRequest) throws Exception | ||||
|     { | ||||
|         //验证是否已存在该手机号 | ||||
|         SysCustomer phoneCustomer = iSysCustomerService.getCustomerByPhone(customerInvestigateRequest.getPhone()); | ||||
|         if(phoneCustomer != null){ | ||||
|             return AjaxResult.error("该手机号已存在"); | ||||
|         } | ||||
|         customerInvestigateRequest.setId(null); //只能添加,无法修改 | ||||
|         return AjaxResult.success(iSysCustomerService.addOrupdateCustomerAndSign(customerInvestigateRequest)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取体征列表 | ||||
|      */ | ||||
|     @GetMapping("/physicalSignsList") | ||||
|     public TableDataInfo physicalSignsList() throws Exception | ||||
|     { | ||||
|         List<SysPhysicalSigns>  physicalSignsList =  iSysPhysicalSignsService.selectSysPhysicalSignsList(new SysPhysicalSigns()); | ||||
|         //System.out.println(physicalSignsList.size()); | ||||
|         return getDataTable(physicalSignsList); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 根据字典类型查询字典数据信息 | ||||
|      */ | ||||
|     @GetMapping(value = "/type/{dictType}") | ||||
|     public AjaxResult dictType(@PathVariable String dictType) | ||||
|     { | ||||
|         return AjaxResult.success(dictTypeService.selectDictDataByType(dictType)); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,118 @@ | ||||
| package com.stdiet.web.controller.custom; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import com.stdiet.custom.dto.request.CustomerInvestigateRequest; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | ||||
| import org.springframework.web.bind.annotation.PutMapping; | ||||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||||
| import org.springframework.web.bind.annotation.PathVariable; | ||||
| import org.springframework.web.bind.annotation.RequestBody; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
| import com.stdiet.common.annotation.Log; | ||||
| import com.stdiet.common.core.controller.BaseController; | ||||
| import com.stdiet.common.core.domain.AjaxResult; | ||||
| import com.stdiet.common.enums.BusinessType; | ||||
| import com.stdiet.custom.domain.SysCustomer; | ||||
| import com.stdiet.custom.service.ISysCustomerService; | ||||
| import com.stdiet.common.utils.poi.ExcelUtil; | ||||
| import com.stdiet.common.core.page.TableDataInfo; | ||||
|  | ||||
| /** | ||||
|  * 客户体征信息Controller | ||||
|  * | ||||
|  * @author xzj | ||||
|  * @date 2021-01-03 | ||||
|  */ | ||||
| @RestController | ||||
| @RequestMapping("/custom/customer") | ||||
| public class SysCustomerController extends BaseController | ||||
| { | ||||
|     @Autowired | ||||
|     private ISysCustomerService sysCustomerService; | ||||
|  | ||||
|     /** | ||||
|      * 查询客户信息列表 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:customer:list')") | ||||
|     @GetMapping("/list") | ||||
|     public TableDataInfo list(SysCustomer sysCustomer) | ||||
|     { | ||||
|         startPage(); | ||||
|         List<SysCustomer> list = sysCustomerService.selectSysCustomerAndSignList(sysCustomer); | ||||
|         return getDataTable(list); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 导出客户信息列表 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:customer:export')") | ||||
|     @Log(title = "客户信息", businessType = BusinessType.EXPORT) | ||||
|     @GetMapping("/export") | ||||
|     public AjaxResult export(SysCustomer sysCustomer) | ||||
|     { | ||||
|         List<SysCustomer> list = sysCustomerService.selectSysCustomerList(sysCustomer); | ||||
|         ExcelUtil<SysCustomer> util = new ExcelUtil<SysCustomer>(SysCustomer.class); | ||||
|         return util.exportExcel(list, "customer"); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取客户信息详细信息 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:customer:query')") | ||||
|     @GetMapping(value = "/{id}") | ||||
|     public AjaxResult getInfo(@PathVariable("id") Long id) | ||||
|     { | ||||
|         return AjaxResult.success(sysCustomerService.getCustomerAndSignById(id)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增客户信息 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:customer:add')") | ||||
|     @Log(title = "客户信息", businessType = BusinessType.INSERT) | ||||
|     @PostMapping | ||||
|     public AjaxResult add(@RequestBody CustomerInvestigateRequest customerInvestigateRequest) throws Exception | ||||
|     { | ||||
|         //验证是否已存在该手机号 | ||||
|         SysCustomer phoneCustomer = sysCustomerService.getCustomerByPhone(customerInvestigateRequest.getPhone()); | ||||
|         if(phoneCustomer != null){ | ||||
|             return AjaxResult.error("该手机号已存在"); | ||||
|         } | ||||
|         return toAjax(sysCustomerService.addOrupdateCustomerAndSign(customerInvestigateRequest)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 修改客户信息 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:customer:edit')") | ||||
|     @Log(title = "客户信息", businessType = BusinessType.UPDATE) | ||||
|     @PutMapping | ||||
|     public AjaxResult edit(@RequestBody CustomerInvestigateRequest customerInvestigateRequest) throws Exception | ||||
|     { | ||||
|         SysCustomer oldCustomer = sysCustomerService.selectSysCustomerById(customerInvestigateRequest.getId()); | ||||
|         if(oldCustomer != null && !oldCustomer.getPhone().equals(customerInvestigateRequest.getPhone())){ | ||||
|             //验证是否已存在该手机号 | ||||
|             SysCustomer phoneCustomer = sysCustomerService.getCustomerByPhone(customerInvestigateRequest.getPhone()); | ||||
|             if(phoneCustomer != null){ | ||||
|                 return AjaxResult.error("该手机号已存在"); | ||||
|             } | ||||
|         } | ||||
|         return toAjax(sysCustomerService.addOrupdateCustomerAndSign(customerInvestigateRequest)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 删除客户信息 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:customer:remove')") | ||||
|     @Log(title = "客户信息", businessType = BusinessType.DELETE) | ||||
|     @DeleteMapping("/{ids}") | ||||
|     public AjaxResult remove(@PathVariable Long[] ids) | ||||
|     { | ||||
|         return toAjax(sysCustomerService.delCustomerAndSignById(ids)); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user