Bläddra i källkod

常用联系人管理

linbl 1 år sedan
förälder
incheckning
2bb29beb50

+ 111 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_favorite_contacts/TbFavoriteContacts.java

@@ -0,0 +1,111 @@
+package com.pj.project.tb_favorite_contacts;
+
+import java.io.Serializable;
+import java.util.*;
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.EqualsAndHashCode;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * Model: tb_favorite_contacts -- 常用联系人
+ * @author lbl
+ */
+@Data
+@Accessors(chain = true)
+@TableName(TbFavoriteContacts.TABLE_NAME)
+@EqualsAndHashCode(callSuper = false)
+public class TbFavoriteContacts extends Model<TbFavoriteContacts> implements Serializable {
+
+	// ---------- 模块常量 ----------
+	/**
+	 * 序列化版本id
+	 */
+	private static final long serialVersionUID = 1L;
+	/**
+	 * 此模块对应的表名
+	 */
+	public static final String TABLE_NAME = "tb_favorite_contacts";
+	/**
+	 * 此模块对应的权限码
+	 */
+	public static final String PERMISSION_CODE = "tb-favorite-contacts";
+	public static final String PERMISSION_CODE_ADD = "tb-favorite-contacts-add";
+	public static final String PERMISSION_CODE_EDIT = "tb-favorite-contacts-edit";
+	public static final String PERMISSION_CODE_DEL = "tb-favorite-contacts-del";
+
+
+
+
+	// ---------- 表中字段 ----------
+	/**
+	 * 主键
+	 */
+	@TableId(type = IdType.AUTO)
+	private Long id;
+
+	/**
+	 * 姓名
+	 */
+	private String name;
+
+	/**
+	 * 手机号
+	 */
+	private String phone;
+
+	/**
+	 * 联系地址
+	 */
+	private String address;
+
+	/**
+	 * 管理人(外联id,与app_user表的id相等)
+	 */
+	private Long fkAppUserId;
+
+	/**
+	 * 创建时间
+	 */
+	private Date createTime;
+
+	/**
+	 * 创建者id
+	 */
+	private String createBy;
+
+	/**
+	 * 创建者名称
+	 */
+	private String createName;
+
+	/**
+	 * 更新时间
+	 */
+	private Date updateTime;
+
+	/**
+	 * 更新者id
+	 */
+	private String updateBy;
+
+	/**
+	 * 更新者名称
+	 */
+	private String updateName;
+
+	/**
+	 * 删除状态
+	 */
+	private String deleteStatus;
+
+
+
+
+
+
+
+
+}

+ 88 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_favorite_contacts/TbFavoriteContactsController.java

@@ -0,0 +1,88 @@
+package com.pj.project.tb_favorite_contacts;
+
+import java.util.List;
+import com.pj.utils.so.SoMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import com.pj.utils.sg.*;
+import com.pj.project4sp.SP;
+
+import com.pj.current.satoken.StpUserUtil;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+
+
+/**
+ * Controller: tb_favorite_contacts -- 常用联系人
+ * @author lbl
+ */
+@RestController
+@RequestMapping("/TbFavoriteContacts/")
+public class TbFavoriteContactsController {
+
+	/** 底层 Service 对象 */
+	@Autowired
+	TbFavoriteContactsService tbFavoriteContactsService;
+
+	/** 增 */
+	@RequestMapping("add")
+	@SaCheckPermission(TbFavoriteContacts.PERMISSION_CODE_ADD)
+	public AjaxJson add(TbFavoriteContacts t){
+		tbFavoriteContactsService.add(t);
+		t = tbFavoriteContactsService.getById(SP.publicMapper.getPrimarykey());
+		return AjaxJson.getSuccessData(t);
+	}
+
+	/** 删 */
+	@RequestMapping("delete")
+	@SaCheckPermission(TbFavoriteContacts.PERMISSION_CODE_DEL)
+	public AjaxJson delete(Long id){
+		 tbFavoriteContactsService.delete(id);
+		return AjaxJson.getSuccess();
+	}
+
+	/** 删 - 根据id列表 */
+	@RequestMapping("deleteByIds")
+	@SaCheckPermission(TbFavoriteContacts.PERMISSION_CODE_DEL)
+	public AjaxJson deleteByIds(){
+		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
+		int line = SP.publicMapper.deleteByIds(TbFavoriteContacts.TABLE_NAME, ids);
+		return AjaxJson.getByLine(line);
+	}
+
+	/** 改 */
+	@RequestMapping("update")
+	@SaCheckPermission(TbFavoriteContacts.PERMISSION_CODE_EDIT)
+	public AjaxJson update(TbFavoriteContacts t){
+		tbFavoriteContactsService.update(t);
+		return AjaxJson.getSuccess();
+	}
+
+	/** 查 - 根据id */
+	@RequestMapping("getById")
+		@SaCheckPermission(TbFavoriteContacts.PERMISSION_CODE)
+	public AjaxJson getById(Long id){
+		TbFavoriteContacts t = tbFavoriteContactsService.getById(id);
+		return AjaxJson.getSuccessData(t);
+	}
+
+	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
+	@RequestMapping("getList")
+		@SaCheckPermission(TbFavoriteContacts.PERMISSION_CODE)
+	public AjaxJson getList() {
+		SoMap so = SoMap.getRequestSoMap();
+		so.set("deleteStatus", 1);
+		List<TbFavoriteContacts> list = tbFavoriteContactsService.getList(so.startPage());
+		return AjaxJson.getPageData(so.getDataCount(), list);
+	}
+
+
+
+
+
+
+
+
+
+}

+ 30 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_favorite_contacts/TbFavoriteContactsMapper.java

@@ -0,0 +1,30 @@
+package com.pj.project.tb_favorite_contacts;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+
+import com.pj.utils.so.*;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Mapper: tb_favorite_contacts -- 常用联系人
+ * @author lbl
+ */
+
+@Mapper
+@Repository
+public interface TbFavoriteContactsMapper extends BaseMapper <TbFavoriteContacts> {
+
+
+
+	/**
+	 * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+	 * @param so 参数集合
+	 * @return 数据列表
+	 */
+	List<TbFavoriteContacts> getList(SoMap so);
+
+
+}

+ 62 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_favorite_contacts/TbFavoriteContactsMapper.xml

@@ -0,0 +1,62 @@
+<?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.pj.project.tb_favorite_contacts.TbFavoriteContactsMapper">
+
+
+
+
+	<!-- ================================== 查询相关 ================================== -->
+	<!-- select id, name, phone, address, fk_app_user_id, create_time, create_by, create_name, update_time, update_by, update_name, delete_status from tb_favorite_contacts  -->
+
+	<!-- 通用映射:自动模式 -->
+	<resultMap id="model" autoMapping="true" type="com.pj.project.tb_favorite_contacts.TbFavoriteContacts"></resultMap>
+
+	<!-- 公共查询sql片段 -->
+	<sql id="select_sql">
+		select *
+		from tb_favorite_contacts
+	</sql>
+
+
+	<!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
+	<select id="getList" resultMap="model">
+		<include refid="select_sql"></include>
+		<where>
+			<if test=' this.has("id") '> and id = #{id} </if>
+			<if test=' this.has("name") '> and name = #{name} </if>
+			<if test=' this.has("phone") '> and phone = #{phone} </if>
+			<if test=' this.has("address") '> and address = #{address} </if>
+			<if test=' this.has("fkAppUserId") '> and fk_app_user_id = #{fkAppUserId} </if>
+			<if test=' this.has("createBy") '> and create_by = #{createBy} </if>
+			<if test=' this.has("createName") '> and create_name = #{createName} </if>
+			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>
+			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>
+			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>
+		</where>
+		order by
+		<choose>
+			<when test='sortType == 1'> id desc </when>
+			<when test='sortType == 2'> name desc </when>
+			<when test='sortType == 3'> phone desc </when>
+			<when test='sortType == 4'> address desc </when>
+			<when test='sortType == 5'> fk_app_user_id desc </when>
+			<when test='sortType == 6'> create_time desc </when>
+			<when test='sortType == 7'> create_by desc </when>
+			<when test='sortType == 8'> create_name desc </when>
+			<when test='sortType == 9'> update_time desc </when>
+			<when test='sortType == 10'> update_by desc </when>
+			<when test='sortType == 11'> update_name desc </when>
+			<otherwise> id desc </otherwise>
+		</choose>
+	</select>
+
+
+
+
+
+
+
+
+
+
+</mapper>

+ 51 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_favorite_contacts/TbFavoriteContactsService.java

@@ -0,0 +1,51 @@
+package com.pj.project.tb_favorite_contacts;
+
+import java.util.List;
+import com.pj.utils.so.SoMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.transaction.annotation.Transactional;
+import com.pj.utils.sg.*;
+
+/**
+ * Service: tb_favorite_contacts -- 常用联系人
+ * @author lbl
+ */
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class TbFavoriteContactsService extends ServiceImpl<TbFavoriteContactsMapper, TbFavoriteContacts> implements IService<TbFavoriteContacts>{
+
+	/** 底层 Mapper 对象 */
+	@Autowired
+	TbFavoriteContactsMapper tbFavoriteContactsMapper;
+
+	/** 增 */
+	void add(TbFavoriteContacts t){
+		save(t);
+	}
+
+	/** 删 */
+	void delete(Long id){
+		removeById(id);
+	}
+
+	/** 改 */
+	void update(TbFavoriteContacts t){
+		updateById(t);
+
+	}
+
+	/** 查 */
+	TbFavoriteContacts getById(Long id){
+		return super.getById(id);
+	}
+
+	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
+	List<TbFavoriteContacts> getList(SoMap so) {
+		return tbFavoriteContactsMapper.getList(so);
+	}
+
+
+}

+ 30 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_favorite_contacts/TbFavoriteContactsUtil.java

@@ -0,0 +1,30 @@
+package com.pj.project.tb_favorite_contacts;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.pj.utils.sg.*;
+import java.util.*;
+
+/**
+ * 工具类:tb_favorite_contacts -- 常用联系人
+ * @author lbl
+ *
+ */
+@Component
+public class TbFavoriteContactsUtil {
+
+
+	/** 底层 Mapper 对象 */
+	public static TbFavoriteContactsMapper tbFavoriteContactsMapper;
+	@Autowired
+	private void setTbFavoriteContactsMapper(TbFavoriteContactsMapper tbFavoriteContactsMapper) {
+		TbFavoriteContactsUtil.tbFavoriteContactsMapper = tbFavoriteContactsMapper;
+	}
+
+
+
+
+
+
+}