初始化项目
This commit is contained in:
1 parent
45a1702948
commit
934b8aad40
155 files changed
+2649
-68
No files matched your search
@@ -0,0 +1,81 @@
|
||||
server:
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /api
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: by-crm
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.3.80:3306/by_crm?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: "Boyun@123"
|
||||
druid:
|
||||
initial-size: 5
|
||||
min-idle: 5
|
||||
max-active: 20
|
||||
max-wait: 60000
|
||||
time-between-eviction-runs-millis: 60000
|
||||
min-evictable-idle-time-millis: 300000
|
||||
validation-query: SELECT 1
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
filters: stat,wall
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
url-pattern: /*
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
url-pattern: /druid/*
|
||||
reset-enable: false
|
||||
login-username: admin
|
||||
login-password: admin123
|
||||
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
default-property-inclusion: non_null
|
||||
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
|
||||
# MyBatis 配置
|
||||
mybatis:
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
type-aliases-package: com.bycrm.entity
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
cache-enabled: false
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
# JWT 配置
|
||||
jwt:
|
||||
# HS512 算法要求密钥至少 64 字节(512 位)
|
||||
# 生产环境请使用环境变量或密钥管理系统存储此密钥
|
||||
secret: by-crm-jwt-secret-key-2024-hs512-requires-at-least-64-bytes-for-secure-signing-please-change-in-production-environment
|
||||
expiration: 86400000 # 24小时,单位:毫秒
|
||||
|
||||
# CRM 业务配置
|
||||
crm:
|
||||
report:
|
||||
ttl-days: 90 # 保护期天数
|
||||
allow-overlap: false # 是否允许重叠报备(生产环境必须为 false)
|
||||
|
||||
# Swagger 配置
|
||||
springfox:
|
||||
documentation:
|
||||
swagger-ui:
|
||||
enabled: true
|
||||
enabled: true
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.bycrm.mapper: debug
|
||||
org.springframework.web: info
|
||||
pattern:
|
||||
console: '%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n'
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,119 @@
|
||||
<?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.bycrm.mapper.CustomerMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bycrm.entity.Customer">
|
||||
<id column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="phone" property="phone"/>
|
||||
<result column="address" property="address"/>
|
||||
<result column="industry" property="industry"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="CustomerVOResultMap" type="com.bycrm.vo.CustomerVO" extends="BaseResultMap">
|
||||
<result column="status_desc" property="statusDesc"/>
|
||||
<result column="current_dealer_id" property="currentDealerId"/>
|
||||
<result column="current_dealer_name" property="currentDealerName"/>
|
||||
<result column="protect_end_date" property="protectEndDate"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_customer WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectByNameLike" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_customer
|
||||
WHERE name LIKE CONCAT('%', #{name}, '%')
|
||||
LIMIT 10
|
||||
</select>
|
||||
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_customer
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND industry = #{industry}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{query.size} OFFSET #{query.offset}
|
||||
</select>
|
||||
|
||||
<select id="countPage" resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM crm_customer
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND industry = #{industry}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.bycrm.entity.Customer" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO crm_customer (name, phone, address, industry, status)
|
||||
VALUES (#{name}, #{phone}, #{address}, #{industry}, #{status})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.bycrm.entity.Customer">
|
||||
UPDATE crm_customer
|
||||
<set>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="phone != null">phone = #{phone},</if>
|
||||
<if test="address != null">address = #{address},</if>
|
||||
<if test="industry != null">industry = #{industry},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM crm_customer WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="selectPageWithDealer" resultMap="CustomerVOResultMap">
|
||||
SELECT
|
||||
c.*,
|
||||
CASE c.status
|
||||
WHEN 0 THEN '可报备'
|
||||
WHEN 1 THEN '保护中'
|
||||
WHEN 2 THEN '已失效'
|
||||
ELSE '未知'
|
||||
END AS status_desc,
|
||||
r.dealer_id AS current_dealer_id,
|
||||
d.name AS current_dealer_name,
|
||||
r.protect_end_date
|
||||
FROM crm_customer c
|
||||
LEFT JOIN crm_report r ON c.id = r.customer_id
|
||||
AND r.status = 1
|
||||
AND r.protect_end_date > NOW()
|
||||
LEFT JOIN crm_dealer d ON r.dealer_id = d.id
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND c.name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND c.industry = #{industry}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND c.status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY c.created_at DESC
|
||||
LIMIT #{query.size} OFFSET #{query.offset}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?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.bycrm.mapper.DealerMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bycrm.entity.Dealer">
|
||||
<id column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="code" property="code"/>
|
||||
<result column="contact_person" property="contactPerson"/>
|
||||
<result column="contact_phone" property="contactPhone"/>
|
||||
<result column="email" property="email"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_dealer WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectByCode" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_dealer WHERE code = #{code}
|
||||
</select>
|
||||
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT d.*, u.id as user_id
|
||||
FROM crm_dealer d
|
||||
LEFT JOIN crm_user u ON u.dealer_id = d.id
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND d.name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="code != null and code != ''">
|
||||
AND d.code LIKE CONCAT('%', #{code}, '%')
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND d.status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY d.created_at DESC
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.bycrm.entity.Dealer" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO crm_dealer (name, code, contact_person, contact_phone, email, status)
|
||||
VALUES (#{name}, #{code}, #{contactPerson}, #{contactPhone}, #{email}, #{status})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.bycrm.entity.Dealer">
|
||||
UPDATE crm_dealer
|
||||
<set>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="code != null and code != ''">code = #{code},</if>
|
||||
<if test="contactPerson != null and contactPerson != ''">contact_person = #{contactPerson},</if>
|
||||
<if test="contactPhone != null and contactPhone != ''">contact_phone = #{contactPhone},</if>
|
||||
<if test="email != null">email = #{email},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM crm_dealer WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM crm_dealer
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,141 @@
|
||||
<?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.bycrm.mapper.ReportMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bycrm.entity.Report">
|
||||
<id column="id" property="id"/>
|
||||
<result column="dealer_id" property="dealerId"/>
|
||||
<result column="customer_id" property="customerId"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="reject_reason" property="rejectReason"/>
|
||||
<result column="protect_start_date" property="protectStartDate"/>
|
||||
<result column="protect_end_date" property="protectEndDate"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
<result column="dealer_name" property="dealerName"/>
|
||||
<result column="customer_name" property="customerName"/>
|
||||
<result column="customer_phone" property="customerPhone"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT r.*,
|
||||
d.name AS dealer_name,
|
||||
c.name AS customer_name,
|
||||
c.phone AS customer_phone
|
||||
FROM crm_report r
|
||||
LEFT JOIN crm_dealer d ON r.dealer_id = d.id
|
||||
LEFT JOIN crm_customer c ON r.customer_id = c.id
|
||||
WHERE r.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectValidByCustomerId" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_report
|
||||
WHERE customer_id = #{customerId}
|
||||
AND status IN (0, 1)
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT r.*,
|
||||
d.name AS dealer_name,
|
||||
c.name AS customer_name,
|
||||
c.phone AS customer_phone
|
||||
FROM crm_report r
|
||||
LEFT JOIN crm_dealer d ON r.dealer_id = d.id
|
||||
LEFT JOIN crm_customer c ON r.customer_id = c.id
|
||||
<where>
|
||||
<if test="dealerId != null">
|
||||
AND r.dealer_id = #{dealerId}
|
||||
</if>
|
||||
<if test="dealerName != null and dealerName != ''">
|
||||
AND d.name LIKE CONCAT('%', #{dealerName}, '%')
|
||||
</if>
|
||||
<if test="customerName != null and customerName != ''">
|
||||
AND c.name LIKE CONCAT('%', #{customerName}, '%')
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND r.status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY r.created_at DESC
|
||||
LIMIT #{query.size} OFFSET #{query.offset}
|
||||
</select>
|
||||
|
||||
<select id="countPage" resultType="java.lang.Long">
|
||||
SELECT COUNT(*)
|
||||
FROM crm_report r
|
||||
LEFT JOIN crm_dealer d ON r.dealer_id = d.id
|
||||
LEFT JOIN crm_customer c ON r.customer_id = c.id
|
||||
<where>
|
||||
<if test="dealerId != null">
|
||||
AND r.dealer_id = #{dealerId}
|
||||
</if>
|
||||
<if test="dealerName != null and dealerName != ''">
|
||||
AND d.name LIKE CONCAT('%', #{dealerName}, '%')
|
||||
</if>
|
||||
<if test="customerName != null and customerName != ''">
|
||||
AND c.name LIKE CONCAT('%', #{customerName}, '%')
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND r.status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.bycrm.entity.Report" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO crm_report (dealer_id, customer_id, description, status, protect_start_date, protect_end_date)
|
||||
VALUES (#{dealerId}, #{customerId}, #{description}, #{status}, #{protectStartDate}, #{protectEndDate})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.bycrm.entity.Report">
|
||||
UPDATE crm_report
|
||||
<set>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="rejectReason != null">reject_reason = #{rejectReason},</if>
|
||||
<if test="protectStartDate != null">protect_start_date = #{protectStartDate},</if>
|
||||
<if test="protectEndDate != null">protect_end_date = #{protectEndDate},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM crm_report WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="selectExpiringReports" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_report
|
||||
WHERE status = 1
|
||||
AND protect_end_date <= #{endDate}
|
||||
</select>
|
||||
|
||||
<update id="batchUpdateExpired">
|
||||
UPDATE crm_report
|
||||
SET status = 3
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="countByDealerId" resultType="java.lang.Long">
|
||||
SELECT COUNT(*)
|
||||
FROM crm_report
|
||||
<where>
|
||||
<if test="dealerId != null">
|
||||
AND dealer_id = #{dealerId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="countPendingByDealerId" resultType="java.lang.Long">
|
||||
SELECT COUNT(*)
|
||||
FROM crm_report
|
||||
WHERE status = 0
|
||||
<if test="dealerId != null">
|
||||
AND dealer_id = #{dealerId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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.bycrm.mapper.SchoolMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bycrm.entity.School">
|
||||
<id column="id" property="id"/>
|
||||
<result column="school_code" property="schoolCode"/>
|
||||
<result column="school_name" property="schoolName"/>
|
||||
<result column="location" property="location"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.bycrm.entity.School" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO crm_school (school_code, school_name, location, created_at, updated_at)
|
||||
VALUES (#{schoolCode}, #{schoolName}, #{location}, #{createdAt}, #{updatedAt})
|
||||
</insert>
|
||||
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO crm_school (school_code, school_name, location, created_at, updated_at)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.schoolCode}, #{item.schoolName}, #{item.location}, #{item.createdAt}, #{item.updatedAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="searchByName" resultMap="BaseResultMap">
|
||||
SELECT id, school_code, school_name, location, created_at, updated_at
|
||||
FROM crm_school
|
||||
WHERE school_name LIKE CONCAT('%', #{keyword}, '%')
|
||||
ORDER BY school_name
|
||||
LIMIT 50
|
||||
</select>
|
||||
|
||||
<select id="findByCode" resultMap="BaseResultMap">
|
||||
SELECT id, school_code, school_name, location, created_at, updated_at
|
||||
FROM crm_school
|
||||
WHERE school_code = #{schoolCode}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultMap="BaseResultMap">
|
||||
SELECT id, school_code, school_name, location, created_at, updated_at
|
||||
FROM crm_school
|
||||
ORDER BY school_name
|
||||
</select>
|
||||
|
||||
<select id="findByPage" resultMap="BaseResultMap">
|
||||
SELECT id, school_code, school_name, location, created_at, updated_at
|
||||
FROM crm_school
|
||||
ORDER BY school_name
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
SELECT COUNT(*) FROM crm_school
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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.bycrm.mapper.SystemConfigMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bycrm.entity.SystemConfig">
|
||||
<id column="id" property="id"/>
|
||||
<result column="config_key" property="configKey"/>
|
||||
<result column="config_value" property="configValue"/>
|
||||
<result column="config_label" property="configLabel"/>
|
||||
<result column="config_type" property="configType"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="is_editable" property="isEditable"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectAll" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_system_config ORDER BY id
|
||||
</select>
|
||||
|
||||
<select id="selectByKey" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_system_config WHERE config_key = #{configKey}
|
||||
</select>
|
||||
|
||||
<select id="selectValueByKey" resultType="java.lang.String">
|
||||
SELECT config_value FROM crm_system_config WHERE config_key = #{configKey}
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="com.bycrm.entity.SystemConfig">
|
||||
UPDATE crm_system_config
|
||||
SET config_value = #{configValue},
|
||||
updated_at = NOW()
|
||||
WHERE config_key = #{configKey}
|
||||
</update>
|
||||
|
||||
<update id="batchUpdate">
|
||||
<foreach collection="configs" item="config" separator=";">
|
||||
UPDATE crm_system_config
|
||||
SET config_value = #{config.configValue},
|
||||
updated_at = NOW()
|
||||
WHERE config_key = #{config.configKey}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?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.bycrm.mapper.UserMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bycrm.entity.User">
|
||||
<id column="id" property="id"/>
|
||||
<result column="username" property="username"/>
|
||||
<result column="password" property="password"/>
|
||||
<result column="real_name" property="realName"/>
|
||||
<result column="dealer_id" property="dealerId"/>
|
||||
<result column="role" property="role"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
<result column="dealer_name" property="dealerName"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByUsername" resultMap="BaseResultMap">
|
||||
SELECT u.*,
|
||||
d.name AS dealer_name
|
||||
FROM crm_user u
|
||||
LEFT JOIN crm_dealer d ON u.dealer_id = d.id
|
||||
WHERE u.username = #{username}
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT u.*,
|
||||
d.name AS dealer_name
|
||||
FROM crm_user u
|
||||
LEFT JOIN crm_dealer d ON u.dealer_id = d.id
|
||||
WHERE u.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT u.*,
|
||||
d.name AS dealer_name
|
||||
FROM crm_user u
|
||||
LEFT JOIN crm_dealer d ON u.dealer_id = d.id
|
||||
ORDER BY u.created_at DESC
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.bycrm.entity.User" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO crm_user (username, password, real_name, dealer_id, role, status)
|
||||
VALUES (#{username}, #{password}, #{realName}, #{dealerId}, #{role}, #{status})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.bycrm.entity.User">
|
||||
UPDATE crm_user
|
||||
<set>
|
||||
<if test="password != null and password != ''">password = #{password},</if>
|
||||
<if test="realName != null and realName != ''">real_name = #{realName},</if>
|
||||
<if test="dealerId != null">dealer_id = #{dealerId},</if>
|
||||
<if test="role != null">role = #{role},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM crm_user WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user