Commit 3d6de963 authored by 罗林杰's avatar 罗林杰

初始化客户信息管理

parent 1f0a8c82
package org.rcisoft.bus.custinfo.controller;
/*固定导入*/
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.core.anno.CyOpeLogAnno;
import org.rcisoft.core.operlog.enums.CyLogTypeEnum;
import org.rcisoft.core.util.CyEpExcelUtil;
import org.springframework.validation.BindingResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.rcisoft.core.result.CyResult;
import org.rcisoft.core.util.CyResultGenUtil;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.constant.CyMessCons;
import org.rcisoft.core.controller.CyPaginationController;
import org.rcisoft.core.model.CyGridModel;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.rcisoft.bus.custinfo.entity.CustInfo;
import org.rcisoft.bus.custinfo.service.CustInfoService;
import java.util.List;
/**
* Created by cy on 2024年12月13日 上午9:58:24.
*/
@RestController
@RequestMapping("/custinfo")
public class CustInfoController extends CyPaginationController<CustInfo> {
@Autowired
private CustInfoService custInfoServiceImpl;
//@PreAuthorize("@cyPerm.hasPerm('sys:tInfo:add')")
@CyOpeLogAnno(title = "system-客户信息表管理-新增客户信息表", businessType = CyLogTypeEnum.INSERT)
@ApiOperation(value="添加客户信息表", notes="添加客户信息表")
@PostMapping(value = "/add")
public CyResult add(@Valid CustInfo custInfo, BindingResult bindingResult) {
CyPersistModel data = custInfoServiceImpl.persist(custInfo);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
custInfo);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:tInfo:delete')")
@CyOpeLogAnno(title = "system-客户信息表管理-删除客户信息表", businessType = CyLogTypeEnum.DELETE)
@ApiOperation(value="逻辑删除客户信息表", notes="逻辑删除客户信息表")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")})
@DeleteMapping("/deleteLogical/{businessId:\\w+}")
public CyResult deleteLogical(@PathVariable int businessId,CustInfo custInfo) {
custInfo.setBusinessId(businessId);
CyPersistModel data = custInfoServiceImpl.removeLogical(custInfo);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
businessId);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:tInfo:delete')")
@CyOpeLogAnno(title = "system-客户信息表管理-删除客户信息表", businessType = CyLogTypeEnum.DELETE)
@ApiOperation(value="删除客户信息表", notes="删除客户信息表")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")})
@DeleteMapping("/delete/{businessId:\\w+}")
public CyResult delete(@PathVariable int businessId,CustInfo custInfo) {
custInfo.setBusinessId(businessId);
CyPersistModel data = custInfoServiceImpl.remove(custInfo);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
businessId);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:tInfo:update')")
@CyOpeLogAnno(title = "system-客户信息表管理-修改客户信息表", businessType = CyLogTypeEnum.UPDATE)
@ApiOperation(value="修改客户信息表", notes="修改客户信息表")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PutMapping("/update/{businessId:\\w+}")
public CyResult update(@PathVariable int businessId, @Valid CustInfo custInfo, BindingResult bindingResult) {
custInfo.setBusinessId(businessId);
CyPersistModel data = custInfoServiceImpl.merge(custInfo);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
custInfo);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:tInfo:query')")
@CyOpeLogAnno(title = "system-客户信息表管理-查询客户信息表", businessType = CyLogTypeEnum.QUERY)
@ApiOperation(value="查询单一客户信息表", notes="查询单一客户信息表")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")})
@GetMapping("/detail/{businessId:\\w+}")
public CyResult detail(@PathVariable int businessId) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
custInfoServiceImpl.findById(businessId));
}
//@PreAuthorize("@cyPerm.hasPerm('sys:tInfo:list')")
@CyOpeLogAnno(title = "system-客户信息表管理-查询客户信息表", businessType = CyLogTypeEnum.QUERY)
@ApiOperation(value="查询客户信息表集合", notes="查询客户信息表集合")
@GetMapping(value = "/listAll")
public CyResult listAll(CustInfo custInfo) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
custInfoServiceImpl.findAll(custInfo));
}
//@PreAuthorize("@cyPerm.hasPerm('sys:tInfo:list')")
@CyOpeLogAnno(title = "system-客户信息表管理-查询客户信息表", businessType = CyLogTypeEnum.QUERY)
@ApiOperation(value="分页查询客户信息表集合", notes="分页查询客户信息表集合")
@GetMapping(value = "/list")
public CyGridModel listByPagination(CustInfo custInfo) {
custInfoServiceImpl.findAllByPagination(getPaginationUtility(), custInfo);
return getGridModelResponse();
}
@CyOpeLogAnno(title = "system-客户信息表管理-查询客户信息表", businessType = CyLogTypeEnum.EXPORT)
@ApiOperation(value = "导出客户信息表信息", notes = "导出客户信息表信息")
@GetMapping(value = "/export")
public void outCustInfo(HttpServletResponse response,CustInfo custInfo,@PathVariable @RequestParam(defaultValue = "0") String excelId) {
String excelName="";
switch(excelId){
case "0": excelName="客户信息表信息.xls";break;
case "1": excelName="客户信息表信息.xlsx";break;
case "2": excelName="客户信息表信息.csv";break;
}
List<CustInfo> custInfoList = custInfoServiceImpl.export(custInfo);
CyEpExcelUtil.exportExcel(custInfoList, "客户信息表信息", "客户信息表信息", CustInfo.class, excelName, response);
}
}
package org.rcisoft.bus.custinfo.dao;
import org.rcisoft.core.mapper.CyBaseMapper;
import org.rcisoft.bus.custinfo.entity.CustInfo;
import org.rcisoft.core.model.CyPageInfo;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
* Created with cy on 2024年12月13日 上午9:58:24.
*/
public interface CustInfoRepository extends CyBaseMapper<CustInfo> {
List<CustInfo> queryCustInfos(@Param("entity") CustInfo custInfo);
/**
* 分页查询 custInfo
*
*/
IPage<CustInfo> queryCustInfosPaged(CyPageInfo cyPageInfo,@Param("entity") CustInfo custInfo);
}
package org.rcisoft.bus.custinfo.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.baomidou.mybatisplus.annotation.TableField;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import org.rcisoft.core.entity.CyIdIncreEntity;
import java.math.BigDecimal;
import java.util.Date;
/**
* Created with cy on 2024年12月13日 上午9:58:24.
*/
@Data
@TableName("cust_info")
public class CustInfo extends CyIdIncreEntity<CustInfo> {
/**
* @desc 客户姓名
* @column customer_name
* @default
*/
@Excel(name = "客户姓名", orderNum = "0", width = 20)
private String customerName;
/**
* @desc 性别(1男 0女)
* @column customer_gender
* @default
*/
@Excel(name = "性别(1男 0女)", orderNum = "1", width = 20)
private String customerGender;
/**
* @desc 生日
* @column customer_birthday
* @default
*/
@JsonFormat(
pattern = "yyyy-MM-dd"
)
@Excel(name = "生日", orderNum = "2", width = 20, format = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date customerBirthday;
/**
* @desc 电话
* @column customer_telephone
* @default
*/
@Excel(name = "电话", orderNum = "3", width = 20)
private String customerTelephone;
/**
* @desc 当前余额
* @column customer_balance
* @default
*/
@Excel(name = "当前余额", orderNum = "4", width = 20)
private BigDecimal customerBalance;
/**
* @desc 门店id
* @column store_id
* @default
*/
@Excel(name = "门店id", orderNum = "5", width = 20)
private String storeId;
/**
* 开始时间
*/
@JsonIgnore
@TableField(exist = false)
private String beginTime;
/**
* 结束时间
*/
@JsonIgnore
@TableField(exist = false)
private String endTime;
}
package org.rcisoft.bus.custinfo.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.rcisoft.bus.custinfo.entity.CustInfo;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.model.CyPageInfo;
import java.util.List;
/**
* Created by cy on 2024年12月13日 上午9:58:24.
*/
public interface CustInfoService {
/**
* 保存 客户信息表
* @param custInfo
* @return
*/
CyPersistModel persist(CustInfo custInfo);
/**
* 删除 客户信息表
* @param custInfo
* @return
*/
CyPersistModel remove(CustInfo custInfo);
/**
* 逻辑删除 客户信息表
* @param custInfo
* @return
*/
CyPersistModel removeLogical(CustInfo custInfo);
/**
* 修改 客户信息表
* @param custInfo
* @return
*/
CyPersistModel merge(CustInfo custInfo);
/**
* 根据id查询 客户信息表
* @param id
* @return
*/
CustInfo findById(int id);
/**
* 分页查询 客户信息表
* @param custInfo
* @return
*/
IPage<CustInfo> findAllByPagination(CyPageInfo<CustInfo> paginationUtility,
CustInfo custInfo);
/**
* 查询list 客户信息表
* @param custInfo
* @return
*/
List<CustInfo> findAll(CustInfo custInfo);
/**
* 导出客户信息表
* @return
*/
List<CustInfo> export(CustInfo custInfo);
}
package org.rcisoft.bus.custinfo.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.rcisoft.core.util.CyUserUtil;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.bus.custinfo.dao.CustInfoRepository;
import org.rcisoft.bus.custinfo.entity.CustInfo;
import org.rcisoft.bus.custinfo.service.CustInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.rcisoft.core.model.CyPageInfo;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
/**
* Created by cy on 2024年12月13日 上午9:58:24.
*/
@Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class CustInfoServiceImpl extends ServiceImpl<CustInfoRepository,CustInfo> implements CustInfoService {
/**
* 保存 客户信息表
* @param custInfo
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel persist(CustInfo custInfo){
//增加操作
int line = baseMapper.insert(custInfo);
log.debug(CyUserUtil.getAuthenUsername()+"新增了ID为"+
custInfo.getBusinessId()+"的客户信息表信息");
return new CyPersistModel(line);
}
/**
* 删除 客户信息表
* @param custInfo
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel remove(CustInfo custInfo){
int line = baseMapper.realDelete(custInfo);
log.debug(CyUserUtil.getAuthenUsername()+"删除了ID为"+
custInfo.getBusinessId()+"的客户信息表信息");
return new CyPersistModel(line);
}
/**
* 逻辑删除 客户信息表
* @param custInfo
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel removeLogical(CustInfo custInfo){
custInfo.setDeleted();
int line = baseMapper.deleteById(custInfo);
log.debug(CyUserUtil.getAuthenUsername()+"逻辑删除了ID为"+
custInfo.getBusinessId()+"的客户信息表信息");
return new CyPersistModel(line);
}
/**
* 修改 客户信息表
* @param custInfo
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel merge(CustInfo custInfo){
int line = baseMapper.updateById(custInfo);
log.debug(CyUserUtil.getAuthenUsername()+"修改了ID为"+ custInfo.getBusinessId()+"的客户信息表信息");
return new CyPersistModel(line);
}
/**
* 根据id查询 客户信息表
* @param id
* @return
*/
@Override
public CustInfo findById(int id){
return baseMapper.selectById(id);
}
/**
* 分页查询 客户信息表
* @param custInfo
* @return
*/
@Override
public IPage<CustInfo> findAllByPagination(CyPageInfo<CustInfo> paginationUtility,
CustInfo custInfo){
return baseMapper.queryCustInfosPaged(paginationUtility,custInfo);
}
/**
* 查询list 客户信息表
* @param custInfo
* @return
*/
@Override
public List<CustInfo> findAll(CustInfo custInfo){
return baseMapper.queryCustInfos(custInfo);
}
/**
* 导出客户信息表
* @return
*/
@Override
public List<CustInfo> export(CustInfo custInfo) {
List<CustInfo> custInfoList = baseMapper.queryCustInfos(custInfo);
return custInfoList;
}
}
<?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="org.rcisoft.bus.custinfo.dao.CustInfoRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.bus.custinfo.entity.CustInfo">
<id column="business_id" jdbcType="INTEGER" property="businessId"/>
<result column="customer_name" jdbcType="VARCHAR" property="customerName"/>
<result column="customer_gender" jdbcType="CHAR" property="customerGender"/>
<result column="customer_birthday" jdbcType="TIMESTAMP" property="customerBirthday"/>
<result column="customer_telephone" jdbcType="VARCHAR" property="customerTelephone"/>
<result column="customer_balance" jdbcType="DECIMAL" property="customerBalance"/>
<result column="flag" jdbcType="CHAR" property="flag"/>
<result column="del_flag" jdbcType="CHAR" property="delFlag"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="store_id" jdbcType="VARCHAR" property="storeId"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
<select id="queryCustInfos" resultMap="BaseResultMap">
select * from cust_info
where 1=1
and del_flag = '0'
<if test="entity.flag !=null and entity.flag != '' ">
and flag = #{entity.flag}
</if>
<if test="entity.customerName !=null and entity.customerName != '' ">
and customer_name like concat('%',#{entity.customerName},'%')
</if>
<if test="entity.customerGender !=null and entity.customerGender != '' ">
and customer_gender = #{entity.customerGender}
</if>
<if test="entity.beginTime !=null and entity.beginTime != '' ">
and customer_birthday &gt;= #{entity.beginTime}
</if>
<if test="entity.endTime !=null and entity.endTime != '' ">
and customer_birthday &lt;= #{entity.endTime}
</if>
<if test="entity.customerTelephone !=null and entity.customerTelephone != '' ">
and customer_telephone like concat('%',#{entity.customerTelephone},'%')
</if>
<if test="entity.customerBalance !=null and entity.customerBalance != '' ">
and customer_balance = #{entity.customerBalance}
</if>
<if test="entity.storeId !=null and entity.storeId != '' ">
and store_id like concat('%',#{entity.storeId},'%')
</if>
ORDER BY business_id DESC
</select>
<select id="queryCustInfosPaged" resultMap="BaseResultMap">
select * from cust_info
where 1=1
and del_flag = '0'
<if test="entity.flag !=null and entity.flag != '' ">
and flag = #{entity.flag}
</if>
<if test="entity.customerName !=null and entity.customerName != '' ">
and customer_name like concat('%',#{entity.customerName},'%')
</if>
<if test="entity.customerGender !=null and entity.customerGender != '' ">
and customer_gender = #{entity.customerGender}
</if>
<if test="entity.beginTime !=null and entity.beginTime != '' ">
and customer_birthday &gt;= #{entity.beginTime}
</if>
<if test="entity.endTime !=null and entity.endTime != '' ">
and customer_birthday &lt;= #{entity.endTime}
</if>
<if test="entity.customerTelephone !=null and entity.customerTelephone != '' ">
and customer_telephone like concat('%',#{entity.customerTelephone},'%')
</if>
<if test="entity.customerBalance !=null and entity.customerBalance != '' ">
and customer_balance = #{entity.customerBalance}
</if>
<if test="entity.storeId !=null and entity.storeId != '' ">
and store_id like concat('%',#{entity.storeId},'%')
</if>
ORDER BY business_id DESC
</select>
</mapper>
\ No newline at end of file
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