您好,登錄后才能下訂單哦!
Saas模式的crm項(xiàng)目模塊是什么,針對(duì)這個(gè)問題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問題的小伙伴找到更簡(jiǎn)單易行的方法。
最近做Saas模式的crm項(xiàng)目員工模塊功能總結(jié): 項(xiàng)目采用maven管理,分為多模塊開發(fā)的模式,這樣方便項(xiàng)目的拆分和開發(fā),避免所有的功能都 揉合在一起,這也是公司里比較常見的開發(fā)模式。
基礎(chǔ)組件的創(chuàng)建
maven多模塊項(xiàng)目結(jié)構(gòu)搭建
使用代碼生成器生成相應(yīng)的mapper ,domain以及用Velocity生成相應(yīng)的 js、jsp controller query service serviceimpl 文件
2.高級(jí)查詢分頁
分頁查詢,參照以前項(xiàng)目發(fā)現(xiàn),分頁數(shù)據(jù)需要一個(gè)請(qǐng)求得到總共多少條數(shù)據(jù),和當(dāng)前分頁的第幾頁和當(dāng)前頁的數(shù)據(jù)。應(yīng)該封裝一個(gè)分頁的service方法queryPageDataByQuery;再mapper層查詢發(fā)送兩條sql完成。并且把查詢結(jié)果封裝成一個(gè)分頁對(duì)象返回。創(chuàng)建PageList封裝分頁對(duì)象。很多數(shù)據(jù)都有查詢要求,封裝一個(gè)BaseQuery對(duì)象,作為查詢條件的base類。
PageList對(duì)象
public class PageList<T> {
private long total = 0;
private List<T> rows = new ArrayList<T>();
public long getTotal() {
return total;
}
public void setTotal(long total) {
this.total = total;
}
public List<T> getRows() {
return rows;
}
public void setRows(List<T> rows) {
this.rows = rows;
}
}
public PageList<T> getByQuery(BaseQuery query) {
//創(chuàng)建封裝數(shù)據(jù)的PageList對(duì)象
PageList<T> pageList = new PageList<T>();
//設(shè)置分頁條件
Page page = PageHelper.startPage(query.getPage(),query.getRows());
//查詢當(dāng)前頁的數(shù)據(jù)
List<T> rows = getMapper().selectByQuery(query);
//獲取總條目數(shù)
long total = page.getTotal();
//將數(shù)據(jù)封裝到PageList對(duì)象中返回
pageList.setRows(rows);
pageList.setTotal(total);
return pageList;
}
在對(duì)應(yīng)的xml里面
<select id="selectByQuery" parameterType="EmployeeQuery" resultMap="BaseResultMap" >
select e.*,d.name as dname
from t_employee e
left join t_department d on e.department_id = d.id
<include refid="whereSql"/>
</select>
3.以及crud
@Controller@RequestMapping("/employee")public class EmployeeController {@Autowired private IEmployeeService employeeService; @RequestMapping("/index")public String index() {return "employee/employee"; }@RequestMapping("/getByid")@ResponseBody public Employee getById(Long id){return employeeService.selectByPrimaryKey(id); }@RequestMapping("/list")@ResponseBody//json public PageResult<Employee> list(EmployeeQuery employeeQuery) {return employeeService.selectForList(employeeQuery); }@RequestMapping("/page")@ResponseBody public PageResult page(@RequestBody String qu){ EmployeeQuery query = JSONObject.parseObject(qu, EmployeeQuery.class); return employeeService.selectForList(query); }@RequestMapping("remove")@ResponseBody public AjaxResult remove(Long id){ System.out.println(id); try {employeeService.deleteByPrimaryKey(id); return AjaxResult.success(); }catch (Exception e){ e.printStackTrace(); return AjaxResult.error("錯(cuò)了"); } }@RequestMapping(value = "/saveUpdate",method = RequestMethod.POST)@ResponseBody public AjaxResult saveUpdate(@RequestBody String product){ Employee produ = JSONObject.parseObject(product, Employee.class); /* System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); System.out.println(produ.getAge());*/ try {if(produ.getId()==null){ Date date = new Date(); produ.setAddtime(date); employeeService.insert(produ); }else { System.out.println("djeksdwdweferferferge"); System.out.println(produ.getInitiationtime()); System.out.println(produ.getAddtime()); employeeService.updateByPrimaryKey(produ); }return AjaxResult.success(); }catch (Exception e){ e.printStackTrace(); return AjaxResult.error("錯(cuò)的"); } }
mapper
<?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="cn.itsource.mapper.EmployeeMapper" > <resultMap id="BaseResultMap" type="cn.itsource.domain.Employee" > <id column="id" property="id" jdbcType="BIGINT" /> <result column="username" property="username" jdbcType="VARCHAR" /> <result column="password" property="password" jdbcType="VARCHAR" /> <result column="age" property="age" jdbcType="INTEGER" /> <result column="post_id" property="postId" jdbcType="VARCHAR" /> <result column="iphone" property="iphone" jdbcType="INTEGER" /> <result column="pay" property="pay" jdbcType="INTEGER" /> <result column="shop_id" property="shopId" jdbcType="VARCHAR" /> <result column="Initiationtime" property="initiationtime" jdbcType="DATE" /> <result column="addtime" property="addtime" jdbcType="DATE" /> </resultMap> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" > delete from employee where id = #{id,jdbcType=BIGINT} </delete> <insert id="insert" parameterType="cn.itsource.domain.Employee" useGeneratedKeys="true" keyProperty="id" > insert into employee (username, password, age, post_id, iphone, pay, shop_id, Initiationtime, addtime ) values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER}, #{postId,jdbcType=VARCHAR}, #{iphone,jdbcType=INTEGER}, #{pay,jdbcType=INTEGER}, #{shopId,jdbcType=VARCHAR}, #{initiationtime,jdbcType=DATE}, #{addtime,jdbcType=DATE} ) </insert> <update id="updateByPrimaryKey" parameterType="cn.itsource.domain.Employee" > update employee set username = #{username,jdbcType=VARCHAR}, password = #{password,jdbcType=VARCHAR}, age = #{age,jdbcType=INTEGER}, post_id = #{postId,jdbcType=VARCHAR}, iphone = #{iphone,jdbcType=INTEGER}, pay = #{pay,jdbcType=INTEGER}, shop_id = #{shopId,jdbcType=VARCHAR}, Initiationtime = #{initiationtime,jdbcType=DATE}, addtime = #{addtime,jdbcType=DATE} where id = #{id,jdbcType=BIGINT} </update> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" > select id, username, password, age, post_id, iphone, pay, shop_id, Initiationtime, addtime from employee where id = #{id,jdbcType=BIGINT} </select> <select id="selectForList" resultMap="BaseResultMap" > select id, username, password, age, post_id, iphone, pay, shop_id, Initiationtime, addtime from employee </select> <select id="findEmployeeByUsername" resultMap="BaseResultMap" parameterType="cn.itsource.domain.Employee"> select id, username, password, age, post_id, iphone, pay, shop, Initiationtime, addtime from employee where username=#{username} </select></mapper>
心得總結(jié)
項(xiàng)目中的收獲
開始自主的思考代碼 提高了自己對(duì)代碼的理解
項(xiàng)目中遇到的問題
因?yàn)轫?xiàng)目是使用了elementui 在因?yàn)橹安皇煜せㄙM(fèi)了大量時(shí)間 之中遇到使用el-date-picker日期組件在編輯中一直回顯不了日期 百度了很久 發(fā)現(xiàn)是缺少了value-format="yyyy-MM-dd" 來改變 v-model上值的格式 加了以后回顯就成功了
關(guān)于Saas模式的crm項(xiàng)目模塊是什么問題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。