选品广场接口

This commit is contained in:
kuang.yife 2023-01-15 16:22:34 +08:00
parent b1c8867a08
commit e2112b4a5f
7 changed files with 610 additions and 0 deletions

View File

@ -0,0 +1,179 @@
package com.ghy.web.controller.customer;
import java.util.List;
import com.ghy.common.exception.base.BaseException;
import com.ghy.customer.domain.Customer;
import com.ghy.customer.domain.CustomerSelection;
import com.ghy.customer.service.CustomerService;
import com.ghy.customer.service.ICustomerSelectionService;
import com.ghy.worker.domain.Worker;
import com.ghy.worker.service.WorkerService;
import com.huifu.adapay.core.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import com.ghy.common.annotation.Log;
import com.ghy.common.enums.BusinessType;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.utils.poi.ExcelUtil;
import com.ghy.common.core.page.TableDataInfo;
/**
* 消费者选品Controller
*
* @author clunt
* @date 2023-01-15
*/
@Controller
@RequestMapping("/customer/selection")
public class CustomerSelectionController extends BaseController
{
private String prefix = "customer/selection";
@Autowired
private ICustomerSelectionService customerSelectionService;
@Autowired
private CustomerService customerService;
@Autowired
private WorkerService workerService;
@GetMapping()
public String selection()
{
return prefix + "/selection";
}
/**
* 查询消费者选品列表
*/
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(CustomerSelection customerSelection)
{
startPage();
List<CustomerSelection> list = customerSelectionService.selectCustomerSelectionList(customerSelection);
return getDataTable(list);
}
/**
* App查询消费者选品列表
*/
@PostMapping("/app/list")
@ResponseBody
public TableDataInfo appList(@RequestBody CustomerSelection customerSelection)
{
startPage();
List<CustomerSelection> list = customerSelectionService.selectCustomerSelectionList(customerSelection);
return getDataTable(list);
}
/**
* 导出消费者选品列表
*/
@Log(title = "消费者选品", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(CustomerSelection customerSelection)
{
List<CustomerSelection> list = customerSelectionService.selectCustomerSelectionList(customerSelection);
ExcelUtil<CustomerSelection> util = new ExcelUtil<CustomerSelection>(CustomerSelection.class);
return util.exportExcel(list, "消费者选品数据");
}
/**
* 新增消费者选品
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存消费者选品
*/
@Log(title = "消费者选品", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(CustomerSelection customerSelection)
{
return toAjax(customerSelectionService.insertCustomerSelection(customerSelection));
}
/**
* 新增保存消费者选品
*/
@PostMapping("/app/add")
@ResponseBody
public AjaxResult appAddSave(@RequestBody List<CustomerSelection> customerSelection)
{
try {
if(!CollectionUtils.isEmpty(customerSelection)){
CustomerSelection checkOne = customerSelection.get(0);
Customer customer = customerService.selectByCustomerId(checkOne.getCustomerId());
if(StringUtil.isEmpty(customer.getPhone())){
throw new BaseException("手机号为空,无法关联师傅!");
}
Worker worker = new Worker();
worker.setPhone(customer.getPhone());
Long workId;
List<Worker> workList = workerService.getWorkList(worker);
if(CollectionUtils.isEmpty(workList)){
throw new BaseException("消费者没有对应的师傅,无需配置选品!");
}else {
workId = workList.get(0).getWorkerId();
}
customerSelection.forEach(selection->{
selection.setWorkId(workId);
customerSelectionService.insertCustomerSelection(selection);
});
return AjaxResult.success("新增成功");
}else {
return AjaxResult.error("不能一个都不选哦!");
}
}catch (Exception e){
return AjaxResult.error(e.getMessage());
}
}
/**
* 修改消费者选品
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") String id, ModelMap mmap)
{
CustomerSelection customerSelection = customerSelectionService.selectCustomerSelectionById(id);
mmap.put("customerSelection", customerSelection);
return prefix + "/edit";
}
/**
* 修改保存消费者选品
*/
@Log(title = "消费者选品", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(CustomerSelection customerSelection)
{
return toAjax(customerSelectionService.updateCustomerSelection(customerSelection));
}
/**
* 删除消费者选品
*/
@Log(title = "消费者选品", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(customerSelectionService.deleteCustomerSelectionByIds(ids));
}
}

View File

@ -0,0 +1,112 @@
package com.ghy.customer.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ghy.common.annotation.Excel;
import com.ghy.common.core.domain.BaseEntity;
/**
* 消费者选品对象 customer_selection
*
* @author clunt
* @date 2023-01-15
*/
public class CustomerSelection extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private String id;
/** 师傅id */
@Excel(name = "师傅id")
private Long workId;
/** 分公司id */
@Excel(name = "分公司id")
private Long deptId;
/** 消费者id */
@Excel(name = "消费者id")
private Long customerId;
/** 分公司类目id */
@Excel(name = "分公司类目id")
private Long deptCategoryId;
/** 选品类型 1.选取 2.屏蔽 */
@Excel(name = "选品类型 1.选取 2.屏蔽")
private Long selectionType;
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setWorkId(Long workId)
{
this.workId = workId;
}
public Long getWorkId()
{
return workId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getDeptId()
{
return deptId;
}
public void setCustomerId(Long customerId)
{
this.customerId = customerId;
}
public Long getCustomerId()
{
return customerId;
}
public void setDeptCategoryId(Long deptCategoryId)
{
this.deptCategoryId = deptCategoryId;
}
public Long getDeptCategoryId()
{
return deptCategoryId;
}
public void setSelectionType(Long selectionType)
{
this.selectionType = selectionType;
}
public Long getSelectionType()
{
return selectionType;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("workId", getWorkId())
.append("deptId", getDeptId())
.append("customerId", getCustomerId())
.append("deptCategoryId", getDeptCategoryId())
.append("selectionType", getSelectionType())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@ -0,0 +1,62 @@
package com.ghy.customer.mapper;
import com.ghy.customer.domain.CustomerSelection;
import java.util.List;
/**
* 消费者选品Mapper接口
*
* @author clunt
* @date 2023-01-15
*/
public interface CustomerSelectionMapper
{
/**
* 查询消费者选品
*
* @param id 消费者选品主键
* @return 消费者选品
*/
public CustomerSelection selectCustomerSelectionById(String id);
/**
* 查询消费者选品列表
*
* @param customerSelection 消费者选品
* @return 消费者选品集合
*/
public List<CustomerSelection> selectCustomerSelectionList(CustomerSelection customerSelection);
/**
* 新增消费者选品
*
* @param customerSelection 消费者选品
* @return 结果
*/
public int insertCustomerSelection(CustomerSelection customerSelection);
/**
* 修改消费者选品
*
* @param customerSelection 消费者选品
* @return 结果
*/
public int updateCustomerSelection(CustomerSelection customerSelection);
/**
* 删除消费者选品
*
* @param id 消费者选品主键
* @return 结果
*/
public int deleteCustomerSelectionById(String id);
/**
* 批量删除消费者选品
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteCustomerSelectionByIds(String[] ids);
}

View File

@ -0,0 +1,62 @@
package com.ghy.customer.service;
import com.ghy.customer.domain.CustomerSelection;
import java.util.List;
/**
* 消费者选品Service接口
*
* @author clunt
* @date 2023-01-15
*/
public interface ICustomerSelectionService
{
/**
* 查询消费者选品
*
* @param id 消费者选品主键
* @return 消费者选品
*/
public CustomerSelection selectCustomerSelectionById(String id);
/**
* 查询消费者选品列表
*
* @param customerSelection 消费者选品
* @return 消费者选品集合
*/
public List<CustomerSelection> selectCustomerSelectionList(CustomerSelection customerSelection);
/**
* 新增消费者选品
*
* @param customerSelection 消费者选品
* @return 结果
*/
public int insertCustomerSelection(CustomerSelection customerSelection);
/**
* 修改消费者选品
*
* @param customerSelection 消费者选品
* @return 结果
*/
public int updateCustomerSelection(CustomerSelection customerSelection);
/**
* 批量删除消费者选品
*
* @param ids 需要删除的消费者选品主键集合
* @return 结果
*/
public int deleteCustomerSelectionByIds(String ids);
/**
* 删除消费者选品信息
*
* @param id 消费者选品主键
* @return 结果
*/
public int deleteCustomerSelectionById(String id);
}

View File

@ -0,0 +1,97 @@
package com.ghy.customer.service.impl;
import java.util.List;
import com.ghy.common.utils.DateUtils;
import com.ghy.customer.domain.CustomerSelection;
import com.ghy.customer.mapper.CustomerSelectionMapper;
import com.ghy.customer.service.ICustomerSelectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ghy.common.core.text.Convert;
/**
* 消费者选品Service业务层处理
*
* @author clunt
* @date 2023-01-15
*/
@Service
public class CustomerSelectionServiceImpl implements ICustomerSelectionService
{
@Autowired
private CustomerSelectionMapper customerSelectionMapper;
/**
* 查询消费者选品
*
* @param id 消费者选品主键
* @return 消费者选品
*/
@Override
public CustomerSelection selectCustomerSelectionById(String id)
{
return customerSelectionMapper.selectCustomerSelectionById(id);
}
/**
* 查询消费者选品列表
*
* @param customerSelection 消费者选品
* @return 消费者选品
*/
@Override
public List<CustomerSelection> selectCustomerSelectionList(CustomerSelection customerSelection)
{
return customerSelectionMapper.selectCustomerSelectionList(customerSelection);
}
/**
* 新增消费者选品
*
* @param customerSelection 消费者选品
* @return 结果
*/
@Override
public int insertCustomerSelection(CustomerSelection customerSelection)
{
customerSelection.setCreateTime(DateUtils.getNowDate());
return customerSelectionMapper.insertCustomerSelection(customerSelection);
}
/**
* 修改消费者选品
*
* @param customerSelection 消费者选品
* @return 结果
*/
@Override
public int updateCustomerSelection(CustomerSelection customerSelection)
{
customerSelection.setUpdateTime(DateUtils.getNowDate());
return customerSelectionMapper.updateCustomerSelection(customerSelection);
}
/**
* 批量删除消费者选品
*
* @param ids 需要删除的消费者选品主键
* @return 结果
*/
@Override
public int deleteCustomerSelectionByIds(String ids)
{
return customerSelectionMapper.deleteCustomerSelectionByIds(Convert.toStrArray(ids));
}
/**
* 删除消费者选品信息
*
* @param id 消费者选品主键
* @return 结果
*/
@Override
public int deleteCustomerSelectionById(String id)
{
return customerSelectionMapper.deleteCustomerSelectionById(id);
}
}

View File

@ -0,0 +1,97 @@
<?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">
<mapper namespace="com.ghy.customer.mapper.CustomerSelectionMapper">
<resultMap type="CustomerSelection" id="CustomerSelectionResult">
<result property="id" column="id" />
<result property="workId" column="work_id" />
<result property="deptId" column="dept_id" />
<result property="customerId" column="customer_id" />
<result property="deptCategoryId" column="dept_category_id" />
<result property="selectionType" column="selection_type" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectCustomerSelectionVo">
select id, work_id, dept_id, customer_id, dept_category_id, selection_type, create_by, create_time, update_by, update_time, remark from customer_selection
</sql>
<select id="selectCustomerSelectionList" parameterType="CustomerSelection" resultMap="CustomerSelectionResult">
<include refid="selectCustomerSelectionVo"/>
<where>
<if test="workId != null "> and work_id = #{workId}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="customerId != null "> and customer_id = #{customerId}</if>
<if test="deptCategoryId != null "> and dept_category_id = #{deptCategoryId}</if>
<if test="selectionType != null "> and selection_type = #{selectionType}</if>
</where>
</select>
<select id="selectCustomerSelectionById" parameterType="String" resultMap="CustomerSelectionResult">
<include refid="selectCustomerSelectionVo"/>
where id = #{id}
</select>
<insert id="insertCustomerSelection" parameterType="CustomerSelection" useGeneratedKeys="true" keyProperty="id">
insert into customer_selection
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="workId != null">work_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="customerId != null">customer_id,</if>
<if test="deptCategoryId != null">dept_category_id,</if>
<if test="selectionType != null">selection_type,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="workId != null">#{workId},</if>
<if test="deptId != null">#{deptId},</if>
<if test="customerId != null">#{customerId},</if>
<if test="deptCategoryId != null">#{deptCategoryId},</if>
<if test="selectionType != null">#{selectionType},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateCustomerSelection" parameterType="CustomerSelection">
update customer_selection
<trim prefix="SET" suffixOverrides=",">
<if test="workId != null">work_id = #{workId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="deptCategoryId != null">dept_category_id = #{deptCategoryId},</if>
<if test="selectionType != null">selection_type = #{selectionType},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCustomerSelectionById" parameterType="String">
delete from customer_selection where id = #{id}
</delete>
<delete id="deleteCustomerSelectionByIds" parameterType="String">
delete from customer_selection where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -288,6 +288,7 @@ public class ShiroConfig
filterChainDefinitionMap.put("/adapay/**", "anon");
filterChainDefinitionMap.put("/system/area/**", "anon");
filterChainDefinitionMap.put("/customer/address/**", "anon");
filterChainDefinitionMap.put("/customer/selection/app/**", "anon");
filterChainDefinitionMap.put("/jim/**", "anon");
filterChainDefinitionMap.put("/MP_verify_bRFuvYpyQ4WLr0on.txt", "anon");
// 对静态资源设置匿名访问