Commit d261d9b5 by 胡懿

删除test包

parent c27381c3
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.entity;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotNull;
import com.jeeplus.core.persistence.ActEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 请假申请Entity
* @author 刘高峰
* @version 2018-06-16
*/
public class OALeave extends ActEntity<OALeave> {
private static final long serialVersionUID = 1L;
private String procInsId; // 流程实例编号
private String leaveType; // 请假类型
private Date startTime; // 请假开始时间
private Date endTime; // 请假结束时间
private String reason; // 请假理由
public OALeave() {
super();
}
public OALeave(String id){
super(id);
}
@ExcelField(title="流程实例编号", align=2, sort=1)
public String getProcInsId() {
return procInsId;
}
public void setProcInsId(String procInsId) {
this.procInsId = procInsId;
}
@ExcelField(title="请假类型", dictType="oa_leave_type", align=2, sort=2)
public String getLeaveType() {
return leaveType;
}
public void setLeaveType(String leaveType) {
this.leaveType = leaveType;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message="请假开始时间不能为空")
@ExcelField(title="请假开始时间", align=2, sort=3)
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message="请假结束时间不能为空")
@ExcelField(title="请假结束时间", align=2, sort=4)
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
@ExcelField(title="请假理由", align=2, sort=5)
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.entity;
import com.jeeplus.modules.sys.entity.User;
import javax.validation.constraints.NotNull;
import com.jeeplus.modules.sys.entity.Office;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeeplus.core.persistence.ActEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 薪酬调整申请Entity
* @author 刘高峰
* @version 2018-06-16
*/
public class TestAudit extends ActEntity<TestAudit> {
private static final long serialVersionUID = 1L;
private String procInsId; // 流程实例ID
private User user; // 变动用户
private Office office; // 归属部门
private String post; // 岗位
private String sex; // 性别
private String edu; // 学历
private String content; // 调整原因
private String olda; // 现行标准 薪酬档级
private String oldb; // 现行标准 月工资额
private String oldc; // 现行标准 年薪总额
private String newa; // 调整后标准 薪酬档级
private String newb; // 调整后标准 月工资额
private String newc; // 调整后标准 年薪总额
private String addNum; // 月增资
private Date exeDate; // 执行时间
public TestAudit() {
super();
}
public TestAudit(String id){
super(id);
}
@ExcelField(title="流程实例ID", align=2, sort=1)
public String getProcInsId() {
return procInsId;
}
public void setProcInsId(String procInsId) {
this.procInsId = procInsId;
}
@NotNull(message="变动用户不能为空")
@ExcelField(title="变动用户", fieldType=User.class, value="user.name", align=2, sort=2)
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@NotNull(message="归属部门不能为空")
@ExcelField(title="归属部门", fieldType=Office.class, value="office.name", align=2, sort=3)
public Office getOffice() {
return office;
}
public void setOffice(Office office) {
this.office = office;
}
@ExcelField(title="岗位", align=2, sort=4)
public String getPost() {
return post;
}
public void setPost(String post) {
this.post = post;
}
@ExcelField(title="性别", dictType="sex", align=2, sort=5)
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
@ExcelField(title="学历", align=2, sort=6)
public String getEdu() {
return edu;
}
public void setEdu(String edu) {
this.edu = edu;
}
@ExcelField(title="调整原因", align=2, sort=7)
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@ExcelField(title="现行标准 薪酬档级", align=2, sort=8)
public String getOlda() {
return olda;
}
public void setOlda(String olda) {
this.olda = olda;
}
@ExcelField(title="现行标准 月工资额", align=2, sort=9)
public String getOldb() {
return oldb;
}
public void setOldb(String oldb) {
this.oldb = oldb;
}
@ExcelField(title="现行标准 年薪总额", align=2, sort=10)
public String getOldc() {
return oldc;
}
public void setOldc(String oldc) {
this.oldc = oldc;
}
@ExcelField(title="调整后标准 薪酬档级", align=2, sort=11)
public String getNewa() {
return newa;
}
public void setNewa(String newa) {
this.newa = newa;
}
@ExcelField(title="调整后标准 月工资额", align=2, sort=12)
public String getNewb() {
return newb;
}
public void setNewb(String newb) {
this.newb = newb;
}
@ExcelField(title="调整后标准 年薪总额", align=2, sort=13)
public String getNewc() {
return newc;
}
public void setNewc(String newc) {
this.newc = newc;
}
@ExcelField(title="月增资", align=2, sort=14)
public String getAddNum() {
return addNum;
}
public void setAddNum(String addNum) {
this.addNum = addNum;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelField(title="执行时间", align=2, sort=15)
public Date getExeDate() {
return exeDate;
}
public void setExeDate(Date exeDate) {
this.exeDate = exeDate;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.entity;
import com.jeeplus.modules.sys.entity.User;
import javax.validation.constraints.NotNull;
import com.jeeplus.modules.sys.entity.Office;
import com.jeeplus.core.persistence.ActEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 报销申请Entity
* @author 刘高峰
* @version 2018-06-16
*/
public class TestExpense extends ActEntity<TestExpense> {
private static final long serialVersionUID = 1L;
private User tuser; // 员工姓名
private Office office; // 所属部门
private String cost; // 报销费用
private String reason; // 报销事由
private String procInsId; // 流程实例id
public TestExpense() {
super();
}
public TestExpense(String id){
super(id);
}
@NotNull(message="员工姓名不能为空")
@ExcelField(title="员工姓名", fieldType=User.class, value="tuser.name", align=2, sort=1)
public User getTuser() {
return tuser;
}
public void setTuser(User tuser) {
this.tuser = tuser;
}
@NotNull(message="所属部门不能为空")
@ExcelField(title="所属部门", fieldType=Office.class, value="office.name", align=2, sort=2)
public Office getOffice() {
return office;
}
public void setOffice(Office office) {
this.office = office;
}
@ExcelField(title="报销费用", align=2, sort=3)
public String getCost() {
return cost;
}
public void setCost(String cost) {
this.cost = cost;
}
@ExcelField(title="报销事由", align=2, sort=4)
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
@ExcelField(title="流程实例id", align=2, sort=11)
public String getProcInsId() {
return procInsId;
}
public void setProcInsId(String procInsId) {
this.procInsId = procInsId;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.test.activiti.entity.OALeave;
/**
* 请假申请MAPPER接口
* @author 刘高峰
* @version 2018-06-16
*/
@MyBatisMapper
public interface OALeaveMapper extends BaseMapper<OALeave> {
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.test.activiti.entity.TestAudit;
/**
* 薪酬调整申请MAPPER接口
* @author 刘高峰
* @version 2018-06-16
*/
@MyBatisMapper
public interface TestAuditMapper extends BaseMapper<TestAudit> {
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.test.activiti.entity.TestExpense;
/**
* 报销申请MAPPER接口
* @author 刘高峰
* @version 2018-06-16
*/
@MyBatisMapper
public interface TestExpenseMapper extends BaseMapper<TestExpense> {
}
\ No newline at end of file
<?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.jeeplus.modules.test.activiti.mapper.OALeaveMapper">
<sql id="oALeaveColumns">
a.id AS "id",
a.proc_ins_id AS "procInsId",
a.leave_type AS "leaveType",
a.start_time AS "startTime",
a.end_time AS "endTime",
a.reason AS "reason",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag"
</sql>
<sql id="oALeaveJoins">
LEFT JOIN sys_user updateBy ON updateBy.id = a.update_by
</sql>
<resultMap type="OALeave" id="OALeaveResult" autoMapping="true">
<result column="reason" property="reason" typeHandler="com.jeeplus.core.mapper.ConvertBlobTypeHandler"/>
</resultMap>
<select id="get" resultMap="OALeaveResult" >
SELECT
<include refid="oALeaveColumns"/>
FROM test_activiti_leave a
<include refid="oALeaveJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultMap="OALeaveResult" >
SELECT
<include refid="oALeaveColumns"/>
FROM test_activiti_leave a
<include refid="oALeaveJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultMap="OALeaveResult" >
SELECT
<include refid="oALeaveColumns"/>
FROM test_activiti_leave a
<include refid="oALeaveJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO test_activiti_leave(
id,
proc_ins_id,
leave_type,
start_time,
end_time,
reason,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{procInsId},
#{leaveType},
#{startTime},
#{endTime},
#{reason},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE test_activiti_leave SET
proc_ins_id = #{procInsId},
leave_type = #{leaveType},
start_time = #{startTime},
end_time = #{endTime},
reason = #{reason},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM test_activiti_leave
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE test_activiti_leave SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="OALeave" statementType="STATEMENT">
select * FROM test_activiti_leave where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
<?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.jeeplus.modules.test.activiti.mapper.TestAuditMapper">
<sql id="testAuditColumns">
a.id AS "id",
a.proc_ins_id AS "procInsId",
a.user_id AS "user.id",
a.office_id AS "office.id",
a.post AS "post",
a.sex AS "sex",
a.edu AS "edu",
a.content AS "content",
a.olda AS "olda",
a.oldb AS "oldb",
a.oldc AS "oldc",
a.newa AS "newa",
a.newb AS "newb",
a.newc AS "newc",
a.add_num AS "addNum",
a.exe_date AS "exeDate",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag",
user.name AS "user.name",
office.name AS "office.name"
</sql>
<sql id="testAuditJoins">
LEFT JOIN sys_user user ON user.id = a.user_id
LEFT JOIN sys_office office ON office.id = a.office_id
</sql>
<select id="get" resultType="TestAudit" >
SELECT
<include refid="testAuditColumns"/>
FROM test_activiti_audit a
<include refid="testAuditJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="TestAudit" >
SELECT
<include refid="testAuditColumns"/>
FROM test_activiti_audit a
<include refid="testAuditJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="TestAudit" >
SELECT
<include refid="testAuditColumns"/>
FROM test_activiti_audit a
<include refid="testAuditJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO test_activiti_audit(
id,
proc_ins_id,
user_id,
office_id,
post,
sex,
edu,
content,
olda,
oldb,
oldc,
newa,
newb,
newc,
add_num,
exe_date,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{procInsId},
#{user.id},
#{office.id},
#{post},
#{sex},
#{edu},
#{content},
#{olda},
#{oldb},
#{oldc},
#{newa},
#{newb},
#{newc},
#{addNum},
#{exeDate},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE test_activiti_audit SET
proc_ins_id = #{procInsId},
user_id = #{user.id},
office_id = #{office.id},
post = #{post},
sex = #{sex},
edu = #{edu},
content = #{content},
olda = #{olda},
oldb = #{oldb},
oldc = #{oldc},
newa = #{newa},
newb = #{newb},
newc = #{newc},
add_num = #{addNum},
exe_date = #{exeDate},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM test_activiti_audit
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE test_activiti_audit SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="TestAudit" statementType="STATEMENT">
select * FROM test_activiti_audit where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
<?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.jeeplus.modules.test.activiti.mapper.TestExpenseMapper">
<sql id="testExpenseColumns">
a.id AS "id",
a.name AS "tuser.id",
a.office_id AS "office.id",
a.cost AS "cost",
a.reason AS "reason",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag",
a.proc_ins_id AS "procInsId",
tuser.name AS "tuser.name",
office.name AS "office.name"
</sql>
<sql id="testExpenseJoins">
LEFT JOIN sys_user tuser ON tuser.id = a.name
LEFT JOIN sys_office office ON office.id = a.office_id
</sql>
<select id="get" resultType="TestExpense" >
SELECT
<include refid="testExpenseColumns"/>
FROM test_activiti_expense a
<include refid="testExpenseJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="TestExpense" >
SELECT
<include refid="testExpenseColumns"/>
FROM test_activiti_expense a
<include refid="testExpenseJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="TestExpense" >
SELECT
<include refid="testExpenseColumns"/>
FROM test_activiti_expense a
<include refid="testExpenseJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO test_activiti_expense(
id,
name,
office_id,
cost,
reason,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag,
proc_ins_id
) VALUES (
#{id},
#{tuser.id},
#{office.id},
#{cost},
#{reason},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag},
#{procInsId}
)
</insert>
<update id="update">
UPDATE test_activiti_expense SET
name = #{tuser.id},
office_id = #{office.id},
cost = #{cost},
reason = #{reason},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks},
proc_ins_id = #{procInsId}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM test_activiti_expense
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE test_activiti_expense SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="TestExpense" statementType="STATEMENT">
select * FROM test_activiti_expense where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.activiti.entity.OALeave;
import com.jeeplus.modules.test.activiti.mapper.OALeaveMapper;
/**
* 请假申请Service
* @author 刘高峰
* @version 2018-06-16
*/
@Service
@Transactional(readOnly = true)
public class OALeaveService extends CrudService<OALeaveMapper, OALeave> {
public OALeave get(String id) {
return super.get(id);
}
public List<OALeave> findList(OALeave oALeave) {
return super.findList(oALeave);
}
public Page<OALeave> findPage(Page<OALeave> page, OALeave oALeave) {
return super.findPage(page, oALeave);
}
@Transactional(readOnly = false)
public void save(OALeave oALeave) {
super.save(oALeave);
}
@Transactional(readOnly = false)
public void delete(OALeave oALeave) {
super.delete(oALeave);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.activiti.entity.TestAudit;
import com.jeeplus.modules.test.activiti.mapper.TestAuditMapper;
/**
* 薪酬调整申请Service
* @author 刘高峰
* @version 2018-06-16
*/
@Service
@Transactional(readOnly = true)
public class TestAuditService extends CrudService<TestAuditMapper, TestAudit> {
public TestAudit get(String id) {
return super.get(id);
}
public List<TestAudit> findList(TestAudit testAudit) {
return super.findList(testAudit);
}
public Page<TestAudit> findPage(Page<TestAudit> page, TestAudit testAudit) {
return super.findPage(page, testAudit);
}
@Transactional(readOnly = false)
public void save(TestAudit testAudit) {
super.save(testAudit);
}
@Transactional(readOnly = false)
public void delete(TestAudit testAudit) {
super.delete(testAudit);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.activiti.entity.TestExpense;
import com.jeeplus.modules.test.activiti.mapper.TestExpenseMapper;
/**
* 报销申请Service
* @author 刘高峰
* @version 2018-06-16
*/
@Service
@Transactional(readOnly = true)
public class TestExpenseService extends CrudService<TestExpenseMapper, TestExpense> {
public TestExpense get(String id) {
return super.get(id);
}
public List<TestExpense> findList(TestExpense testExpense) {
return super.findList(testExpense);
}
public Page<TestExpense> findPage(Page<TestExpense> page, TestExpense testExpense) {
return super.findPage(page, testExpense);
}
@Transactional(readOnly = false)
public void save(TestExpense testExpense) {
super.save(testExpense);
}
@Transactional(readOnly = false)
public void delete(TestExpense testExpense) {
super.delete(testExpense);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.web;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Maps;
import org.activiti.engine.repository.ProcessDefinition;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.act.service.ActProcessService;
import com.jeeplus.modules.act.service.ActTaskService;
import com.jeeplus.modules.test.activiti.entity.OALeave;
import com.jeeplus.modules.test.activiti.service.OALeaveService;
/**
* 请假申请Controller
* @author 刘高峰
* @version 2018-06-16
*/
@Controller
@RequestMapping(value = "${adminPath}/test/activiti/oALeave")
public class OALeaveController extends BaseController {
@Autowired
private OALeaveService oALeaveService;
@Autowired
private ActProcessService actProcessService;
@Autowired
private ActTaskService actTaskService;
@ModelAttribute
public OALeave get(@RequestParam(required=false) String id) {
OALeave entity = null;
if (StringUtils.isNotBlank(id)){
entity = oALeaveService.get(id);
}
if (entity == null){
entity = new OALeave();
}
return entity;
}
/**
* 查看,增加,编辑请假申请表单页面
*/
@RequestMapping(value = "form/{mode}")
public String form(@PathVariable String mode, OALeave oALeave, Model model) {
model.addAttribute("oALeave", oALeave);
if("add".equals(mode) || "edit".equals(mode)){
return "modules/test/activiti/oALeaveForm";
}else{//audit
return "modules/test/activiti/oALeaveAudit";
}
}
/**
* 保存请假申请
*/
@ResponseBody
@RequestMapping(value = "save")
public AjaxJson save(OALeave oALeave, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(oALeave);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
/**
* 流程审批
*/
if (StringUtils.isBlank(oALeave.getId())){
//新增或编辑表单保存
oALeaveService.save(oALeave);//保存
// 启动流程
ProcessDefinition p = actProcessService.getProcessDefinition(oALeave.getAct().getProcDefId());
String title = oALeave.getCurrentUser().getName()+"在"+ DateUtils.getDateTime()+"发起"+p.getName();
actTaskService.startProcess(p.getKey(), "test_activiti_leave", oALeave.getId(), title);
j.setMsg("发起流程审批成功!");
j.getBody().put("targetUrl", "/act/task/process/");
}else{
//新增或编辑表单保存
oALeaveService.save(oALeave);//保存
oALeave.getAct().setComment(("yes".equals(oALeave.getAct().getFlag())?"[重新申请] ":"[销毁申请] "));
// 完成流程任务
Map<String, Object> vars = Maps.newHashMap();
vars.put("reapply", "yes".equals(oALeave.getAct().getFlag())? true : false);
actTaskService.complete(oALeave.getAct().getTaskId(), oALeave.getAct().getProcInsId(), oALeave.getAct().getComment(), oALeave.getContent(), vars);
j.setMsg("提交成功!");
j.getBody().put("targetUrl", "/act/task/todo/");
}
return j;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.web;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Maps;
import org.activiti.engine.repository.ProcessDefinition;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.act.service.ActProcessService;
import com.jeeplus.modules.act.service.ActTaskService;
import com.jeeplus.modules.test.activiti.entity.TestAudit;
import com.jeeplus.modules.test.activiti.service.TestAuditService;
/**
* 薪酬调整申请Controller
* @author 刘高峰
* @version 2018-06-16
*/
@Controller
@RequestMapping(value = "${adminPath}/test/activiti/testAudit")
public class TestAuditController extends BaseController {
@Autowired
private TestAuditService testAuditService;
@Autowired
private ActProcessService actProcessService;
@Autowired
private ActTaskService actTaskService;
@ModelAttribute
public TestAudit get(@RequestParam(required=false) String id) {
TestAudit entity = null;
if (StringUtils.isNotBlank(id)){
entity = testAuditService.get(id);
}
if (entity == null){
entity = new TestAudit();
}
return entity;
}
/**
* 查看,增加,编辑薪酬调整申请表单页面
*/
@RequestMapping(value = "form/{mode}")
public String form(@PathVariable String mode, TestAudit testAudit, Model model) {
model.addAttribute("testAudit", testAudit);
if("add".equals(mode) || "edit".equals(mode)){
return "modules/test/activiti/testAuditForm";
}else{//audit
return "modules/test/activiti/testAuditAudit";
}
}
/**
* 保存薪酬调整申请
*/
@ResponseBody
@RequestMapping(value = "save")
public AjaxJson save(TestAudit testAudit, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(testAudit);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
/**
* 流程审批
*/
if (StringUtils.isBlank(testAudit.getId())){
//新增或编辑表单保存
testAuditService.save(testAudit);//保存
// 启动流程
ProcessDefinition p = actProcessService.getProcessDefinition(testAudit.getAct().getProcDefId());
String title = testAudit.getCurrentUser().getName()+"在"+ DateUtils.getDateTime()+"发起"+p.getName();
actTaskService.startProcess(p.getKey(), "test_activiti_audit", testAudit.getId(), title);
j.setMsg("发起流程审批成功!");
j.getBody().put("targetUrl", "/act/task/process/");
}else{
//新增或编辑表单保存
testAuditService.save(testAudit);//保存
testAudit.getAct().setComment(("yes".equals(testAudit.getAct().getFlag())?"[重新申请] ":"[销毁申请] "));
// 完成流程任务
Map<String, Object> vars = Maps.newHashMap();
vars.put("reapply", "yes".equals(testAudit.getAct().getFlag())? true : false);
actTaskService.complete(testAudit.getAct().getTaskId(), testAudit.getAct().getProcInsId(), testAudit.getAct().getComment(), testAudit.getContent(), vars);
j.setMsg("提交成功!");
j.getBody().put("targetUrl", "/act/task/todo/");
}
return j;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.activiti.web;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Maps;
import org.activiti.engine.repository.ProcessDefinition;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.act.service.ActProcessService;
import com.jeeplus.modules.act.service.ActTaskService;
import com.jeeplus.modules.test.activiti.entity.TestExpense;
import com.jeeplus.modules.test.activiti.service.TestExpenseService;
/**
* 报销申请Controller
* @author 刘高峰
* @version 2018-06-16
*/
@Controller
@RequestMapping(value = "${adminPath}/test/activiti/testExpense")
public class TestExpenseController extends BaseController {
@Autowired
private TestExpenseService testExpenseService;
@Autowired
private ActProcessService actProcessService;
@Autowired
private ActTaskService actTaskService;
@ModelAttribute
public TestExpense get(@RequestParam(required=false) String id) {
TestExpense entity = null;
if (StringUtils.isNotBlank(id)){
entity = testExpenseService.get(id);
}
if (entity == null){
entity = new TestExpense();
}
return entity;
}
/**
* 查看,增加,编辑报销申请表单页面
*/
@RequestMapping(value = "form/{mode}")
public String form(@PathVariable String mode, TestExpense testExpense, Model model) {
model.addAttribute("testExpense", testExpense);
if("add".equals(mode) || "edit".equals(mode)){
return "modules/test/activiti/testExpenseForm";
}else{//audit
return "modules/test/activiti/testExpenseAudit";
}
}
/**
* 保存报销申请
*/
@ResponseBody
@RequestMapping(value = "save")
public AjaxJson save(TestExpense testExpense, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(testExpense);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
/**
* 流程审批
*/
if (StringUtils.isBlank(testExpense.getId())){
//新增或编辑表单保存
testExpenseService.save(testExpense);//保存
// 启动流程
ProcessDefinition p = actProcessService.getProcessDefinition(testExpense.getAct().getProcDefId());
String title = testExpense.getCurrentUser().getName()+"在"+ DateUtils.getDateTime()+"发起"+p.getName();
actTaskService.startProcess(p.getKey(), "test_activiti_expense", testExpense.getId(), title);
j.setMsg("发起流程审批成功!");
j.getBody().put("targetUrl", "/act/task/process/");
}else{
//新增或编辑表单保存
testExpenseService.save(testExpense);//保存
testExpense.getAct().setComment(("yes".equals(testExpense.getAct().getFlag())?"[重新申请] ":"[销毁申请] "));
// 完成流程任务
Map<String, Object> vars = Maps.newHashMap();
vars.put("reapply", "yes".equals(testExpense.getAct().getFlag())? true : false);
actTaskService.complete(testExpense.getAct().getTaskId(), testExpense.getAct().getProcInsId(), testExpense.getAct().getComment(), testExpense.getContent(), vars);
j.setMsg("提交成功!");
j.getBody().put("targetUrl", "/act/task/todo/");
}
return j;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.grid.entity;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 洲Entity
* @author lgf
* @version 2018-06-12
*/
public class TestContinent extends DataEntity<TestContinent> {
private static final long serialVersionUID = 1L;
private String name; // 洲名
public TestContinent() {
super();
}
public TestContinent(String id){
super(id);
}
@ExcelField(title="洲名", align=2, sort=1)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.grid.entity;
import com.jeeplus.modules.test.grid.entity.TestContinent;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 国家Entity
* @author lgf
* @version 2018-04-10
*/
public class TestCountry extends DataEntity<TestCountry> {
private static final long serialVersionUID = 1L;
private String name; // 国名
private String sum; // 人口
private TestContinent continent; // 所属洲
public TestCountry() {
super();
}
public TestCountry(String id){
super(id);
}
@ExcelField(title="国名", align=2, sort=1)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@ExcelField(title="人口", align=2, sort=2)
public String getSum() {
return sum;
}
public void setSum(String sum) {
this.sum = sum;
}
@ExcelField(title="所属洲", fieldType=TestContinent.class, value="continent.name", align=2, sort=3)
public TestContinent getContinent() {
return continent;
}
public void setContinent(TestContinent continent) {
this.continent = continent;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.grid.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.test.grid.entity.TestContinent;
/**
* 洲MAPPER接口
* @author lgf
* @version 2018-06-12
*/
@MyBatisMapper
public interface TestContinentMapper extends BaseMapper<TestContinent> {
}
\ No newline at end of file
<?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.jeeplus.modules.test.grid.mapper.TestContinentMapper">
<sql id="testContinentColumns">
a.id AS "id",
a.name AS "name",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag"
</sql>
<sql id="testContinentJoins">
</sql>
<select id="get" resultType="TestContinent" >
SELECT
<include refid="testContinentColumns"/>
FROM test_continent a
<include refid="testContinentJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="TestContinent" >
SELECT
<include refid="testContinentColumns"/>
FROM test_continent a
<include refid="testContinentJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="name != null and name != ''">
AND a.name LIKE
<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="TestContinent" >
SELECT
<include refid="testContinentColumns"/>
FROM test_continent a
<include refid="testContinentJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO test_continent(
id,
name,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{name},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE test_continent SET
name = #{name},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM test_continent
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE test_continent SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="TestContinent" statementType="STATEMENT">
select * FROM test_continent where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
<?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.jeeplus.modules.test.grid.mapper.TestCountryMapper">
<sql id="testCountryColumns">
a.id AS "id",
a.name AS "name",
a.sum AS "sum",
a.continent_id AS "continent.id",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag",
continent.name AS "continent.name"
</sql>
<sql id="testCountryJoins">
LEFT JOIN test_continent continent ON continent.id = a.continent_id
</sql>
<select id="get" resultType="TestCountry" >
SELECT
<include refid="testCountryColumns"/>
FROM test_country a
<include refid="testCountryJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="TestCountry" >
SELECT
<include refid="testCountryColumns"/>
FROM test_country a
<include refid="testCountryJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="continent != null and continent.id != null and continent.id != ''">
AND a.continent_id = #{continent.id}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="TestCountry" >
SELECT
<include refid="testCountryColumns"/>
FROM test_country a
<include refid="testCountryJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO test_country(
id,
name,
sum,
continent_id,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{name},
#{sum},
#{continent.id},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE test_country SET
name = #{name},
sum = #{sum},
continent_id = #{continent.id},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM test_country
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE test_country SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="TestCountry" statementType="STATEMENT">
select * FROM test_country where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.grid.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.grid.entity.TestContinent;
import com.jeeplus.modules.test.grid.mapper.TestContinentMapper;
/**
* 洲Service
* @author lgf
* @version 2018-06-12
*/
@Service
@Transactional(readOnly = true)
public class TestContinentService extends CrudService<TestContinentMapper, TestContinent> {
public TestContinent get(String id) {
return super.get(id);
}
public List<TestContinent> findList(TestContinent testContinent) {
return super.findList(testContinent);
}
public Page<TestContinent> findPage(Page<TestContinent> page, TestContinent testContinent) {
return super.findPage(page, testContinent);
}
@Transactional(readOnly = false)
public void save(TestContinent testContinent) {
super.save(testContinent);
}
@Transactional(readOnly = false)
public void delete(TestContinent testContinent) {
super.delete(testContinent);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.grid.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.grid.entity.TestCountry;
import com.jeeplus.modules.test.grid.mapper.TestCountryMapper;
/**
* 国家Service
* @author lgf
* @version 2018-04-10
*/
@Service
@Transactional(readOnly = true)
public class TestCountryService extends CrudService<TestCountryMapper, TestCountry> {
public TestCountry get(String id) {
return super.get(id);
}
public List<TestCountry> findList(TestCountry testCountry) {
return super.findList(testCountry);
}
public Page<TestCountry> findPage(Page<TestCountry> page, TestCountry testCountry) {
return super.findPage(page, testCountry);
}
@Transactional(readOnly = false)
public void save(TestCountry testCountry) {
super.save(testCountry);
}
@Transactional(readOnly = false)
public void delete(TestCountry testCountry) {
super.delete(testCountry);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.grid.web;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.modules.test.grid.entity.TestContinent;
import com.jeeplus.modules.test.grid.service.TestContinentService;
/**
* 洲Controller
* @author lgf
* @version 2018-06-12
*/
@Controller
@RequestMapping(value = "${adminPath}/test/grid/testContinent")
public class TestContinentController extends BaseController {
@Autowired
private TestContinentService testContinentService;
@ModelAttribute
public TestContinent get(@RequestParam(required=false) String id) {
TestContinent entity = null;
if (StringUtils.isNotBlank(id)){
entity = testContinentService.get(id);
}
if (entity == null){
entity = new TestContinent();
}
return entity;
}
/**
* 洲列表页面
*/
@RequiresPermissions("test:grid:testContinent:list")
@RequestMapping(value = {"list", ""})
public String list(TestContinent testContinent, Model model) {
model.addAttribute("testContinent", testContinent);
return "modules/test/grid/testContinentList";
}
/**
* 洲列表数据
*/
@ResponseBody
@RequiresPermissions("test:grid:testContinent:list")
@RequestMapping(value = "data")
public Map<String, Object> data(TestContinent testContinent, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<TestContinent> page = testContinentService.findPage(new Page<TestContinent>(request, response), testContinent);
return getBootstrapData(page);
}
/**
* 查看,增加,编辑洲表单页面
*/
@RequiresPermissions(value={"test:grid:testContinent:view","test:grid:testContinent:add","test:grid:testContinent:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(TestContinent testContinent, Model model) {
model.addAttribute("testContinent", testContinent);
return "modules/test/grid/testContinentForm";
}
/**
* 保存洲
*/
@ResponseBody
@RequiresPermissions(value={"test:grid:testContinent:add","test:grid:testContinent:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public AjaxJson save(TestContinent testContinent, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(testContinent);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
//新增或编辑表单保存
testContinentService.save(testContinent);//保存
j.setSuccess(true);
j.setMsg("保存洲成功");
return j;
}
/**
* 删除洲
*/
@ResponseBody
@RequiresPermissions("test:grid:testContinent:del")
@RequestMapping(value = "delete")
public AjaxJson delete(TestContinent testContinent) {
AjaxJson j = new AjaxJson();
testContinentService.delete(testContinent);
j.setMsg("删除洲成功");
return j;
}
/**
* 批量删除洲
*/
@ResponseBody
@RequiresPermissions("test:grid:testContinent:del")
@RequestMapping(value = "deleteAll")
public AjaxJson deleteAll(String ids) {
AjaxJson j = new AjaxJson();
String idArray[] =ids.split(",");
for(String id : idArray){
testContinentService.delete(testContinentService.get(id));
}
j.setMsg("删除洲成功");
return j;
}
/**
* 导出excel文件
*/
@ResponseBody
@RequiresPermissions("test:grid:testContinent:export")
@RequestMapping(value = "export")
public AjaxJson exportFile(TestContinent testContinent, HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "洲"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<TestContinent> page = testContinentService.findPage(new Page<TestContinent>(request, response, -1), testContinent);
new ExportExcel("洲", TestContinent.class).setDataList(page.getList()).write(response, fileName).dispose();
j.setSuccess(true);
j.setMsg("导出成功!");
return j;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导出洲记录失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 导入Excel数据
*/
@ResponseBody
@RequiresPermissions("test:grid:testContinent:import")
@RequestMapping(value = "import")
public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<TestContinent> list = ei.getDataList(TestContinent.class);
for (TestContinent testContinent : list){
try{
testContinentService.save(testContinent);
successNum++;
}catch(ConstraintViolationException ex){
failureNum++;
}catch (Exception ex) {
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条洲记录。");
}
j.setMsg( "已成功导入 "+successNum+" 条洲记录"+failureMsg);
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导入洲失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 下载导入洲数据模板
*/
@ResponseBody
@RequiresPermissions("test:grid:testContinent:import")
@RequestMapping(value = "import/template")
public AjaxJson importFileTemplate(HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "洲数据导入模板.xlsx";
List<TestContinent> list = Lists.newArrayList();
new ExportExcel("洲数据", TestContinent.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg( "导入模板下载失败!失败信息:"+e.getMessage());
}
return j;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.grid.web;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.modules.test.grid.entity.TestCountry;
import com.jeeplus.modules.test.grid.service.TestCountryService;
/**
* 国家Controller
* @author lgf
* @version 2018-04-10
*/
@Controller
@RequestMapping(value = "${adminPath}/test/grid/testCountry")
public class TestCountryController extends BaseController {
@Autowired
private TestCountryService testCountryService;
@ModelAttribute
public TestCountry get(@RequestParam(required=false) String id) {
TestCountry entity = null;
if (StringUtils.isNotBlank(id)){
entity = testCountryService.get(id);
}
if (entity == null){
entity = new TestCountry();
}
return entity;
}
/**
* 国家列表页面
*/
@RequiresPermissions("test:grid:testCountry:list")
@RequestMapping(value = {"list", ""})
public String list(TestCountry testCountry, Model model) {
model.addAttribute("testCountry", testCountry);
return "modules/test/grid/testCountryList";
}
/**
* 国家列表数据
*/
@ResponseBody
@RequiresPermissions("test:grid:testCountry:list")
@RequestMapping(value = "data")
public Map<String, Object> data(TestCountry testCountry, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<TestCountry> page = testCountryService.findPage(new Page<TestCountry>(request, response), testCountry);
return getBootstrapData(page);
}
/**
* 查看,增加,编辑国家表单页面
*/
@RequiresPermissions(value={"test:grid:testCountry:view","test:grid:testCountry:add","test:grid:testCountry:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(TestCountry testCountry, Model model) {
model.addAttribute("testCountry", testCountry);
return "modules/test/grid/testCountryForm";
}
/**
* 保存国家
*/
@ResponseBody
@RequiresPermissions(value={"test:grid:testCountry:add","test:grid:testCountry:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public AjaxJson save(TestCountry testCountry, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(testCountry);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
//新增或编辑表单保存
testCountryService.save(testCountry);//保存
j.setSuccess(true);
j.setMsg("保存国家成功");
return j;
}
/**
* 删除国家
*/
@ResponseBody
@RequiresPermissions("test:grid:testCountry:del")
@RequestMapping(value = "delete")
public AjaxJson delete(TestCountry testCountry) {
AjaxJson j = new AjaxJson();
testCountryService.delete(testCountry);
j.setMsg("删除国家成功");
return j;
}
/**
* 批量删除国家
*/
@ResponseBody
@RequiresPermissions("test:grid:testCountry:del")
@RequestMapping(value = "deleteAll")
public AjaxJson deleteAll(String ids) {
AjaxJson j = new AjaxJson();
String idArray[] =ids.split(",");
for(String id : idArray){
testCountryService.delete(testCountryService.get(id));
}
j.setMsg("删除国家成功");
return j;
}
/**
* 导出excel文件
*/
@ResponseBody
@RequiresPermissions("test:grid:testCountry:export")
@RequestMapping(value = "export")
public AjaxJson exportFile(TestCountry testCountry, HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "国家"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<TestCountry> page = testCountryService.findPage(new Page<TestCountry>(request, response, -1), testCountry);
new ExportExcel("国家", TestCountry.class).setDataList(page.getList()).write(response, fileName).dispose();
j.setSuccess(true);
j.setMsg("导出成功!");
return j;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导出国家记录失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 导入Excel数据
*/
@ResponseBody
@RequiresPermissions("test:grid:testCountry:import")
@RequestMapping(value = "import")
public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<TestCountry> list = ei.getDataList(TestCountry.class);
for (TestCountry testCountry : list){
try{
testCountryService.save(testCountry);
successNum++;
}catch(ConstraintViolationException ex){
failureNum++;
}catch (Exception ex) {
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条国家记录。");
}
j.setMsg( "已成功导入 "+successNum+" 条国家记录"+failureMsg);
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导入国家失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 下载导入国家数据模板
*/
@ResponseBody
@RequiresPermissions("test:grid:testCountry:import")
@RequestMapping(value = "import/template")
public AjaxJson importFileTemplate(HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "国家数据导入模板.xlsx";
List<TestCountry> list = Lists.newArrayList();
new ExportExcel("国家数据", TestCountry.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg( "导入模板下载失败!失败信息:"+e.getMessage());
}
return j;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytomany.entity;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 课程Entity
* @author lgf
* @version 2018-06-12
*/
public class Course extends DataEntity<Course> {
private static final long serialVersionUID = 1L;
private String name; // 课程名
public Course() {
super();
}
public Course(String id){
super(id);
}
@ExcelField(title="课程名", align=2, sort=1)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytomany.entity;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 学生Entity
* @author lgf
* @version 2018-06-12
*/
public class Student extends DataEntity<Student> {
private static final long serialVersionUID = 1L;
private String name; // 姓名
public Student() {
super();
}
public Student(String id){
super(id);
}
@ExcelField(title="姓名", align=2, sort=1)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytomany.entity;
import com.jeeplus.modules.test.manytomany.entity.Student;
import javax.validation.constraints.NotNull;
import com.jeeplus.modules.test.manytomany.entity.Course;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 学生课程记录Entity
* @author lgf
* @version 2018-06-12
*/
public class StudentCourse extends DataEntity<StudentCourse> {
private static final long serialVersionUID = 1L;
private Student student; // 学生
private Course course; // 课程
private Double score; // 分数
public StudentCourse() {
super();
}
public StudentCourse(String id){
super(id);
}
@NotNull(message="学生不能为空")
@ExcelField(title="学生", fieldType=Student.class, value="student.name", align=2, sort=1)
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
@NotNull(message="课程不能为空")
@ExcelField(title="课程", fieldType=Course.class, value="course.name", align=2, sort=2)
public Course getCourse() {
return course;
}
public void setCourse(Course course) {
this.course = course;
}
@NotNull(message="分数不能为空")
@ExcelField(title="分数", align=2, sort=3)
public Double getScore() {
return score;
}
public void setScore(Double score) {
this.score = score;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytomany.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.test.manytomany.entity.StudentCourse;
/**
* 学生课程记录MAPPER接口
* @author lgf
* @version 2018-06-12
*/
@MyBatisMapper
public interface StudentCourseMapper extends BaseMapper<StudentCourse> {
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytomany.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.test.manytomany.entity.Student;
/**
* 学生MAPPER接口
* @author lgf
* @version 2018-06-12
*/
@MyBatisMapper
public interface StudentMapper extends BaseMapper<Student> {
}
\ No newline at end of file
<?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.jeeplus.modules.test.manytomany.mapper.StudentCourseMapper">
<sql id="studentCourseColumns">
a.id AS "id",
a.student_id AS "student.id",
a.course_id AS "course.id",
a.score AS "score",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag",
student.name AS "student.name",
course.name AS "course.name"
</sql>
<sql id="studentCourseJoins">
LEFT JOIN test_student student ON student.id = a.student_id
LEFT JOIN test_course course ON course.id = a.course_id
</sql>
<select id="get" resultType="StudentCourse" >
SELECT
<include refid="studentCourseColumns"/>
FROM test_student_course a
<include refid="studentCourseJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="StudentCourse" >
SELECT
<include refid="studentCourseColumns"/>
FROM test_student_course a
<include refid="studentCourseJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="student != null and student.id != null and student.id != ''">
AND a.student_id = #{student.id}
</if>
<if test="course != null and course.id != null and course.id != ''">
AND a.course_id = #{course.id}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="StudentCourse" >
SELECT
<include refid="studentCourseColumns"/>
FROM test_student_course a
<include refid="studentCourseJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO test_student_course(
id,
student_id,
course_id,
score,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{student.id},
#{course.id},
#{score},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE test_student_course SET
student_id = #{student.id},
course_id = #{course.id},
score = #{score},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM test_student_course
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE test_student_course SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="StudentCourse" statementType="STATEMENT">
select * FROM test_student_course where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
<?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.jeeplus.modules.test.manytomany.mapper.StudentMapper">
<sql id="studentColumns">
a.id AS "id",
a.name AS "name",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag"
</sql>
<sql id="studentJoins">
</sql>
<select id="get" resultType="Student" >
SELECT
<include refid="studentColumns"/>
FROM test_student a
<include refid="studentJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="Student" >
SELECT
<include refid="studentColumns"/>
FROM test_student a
<include refid="studentJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="name != null and name != ''">
AND a.name = #{name}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="Student" >
SELECT
<include refid="studentColumns"/>
FROM test_student a
<include refid="studentJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO test_student(
id,
name,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{name},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE test_student SET
name = #{name},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM test_student
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE test_student SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="Student" statementType="STATEMENT">
select * FROM test_student where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytomany.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.manytomany.entity.Course;
import com.jeeplus.modules.test.manytomany.mapper.CourseMapper;
/**
* 课程Service
* @author lgf
* @version 2018-06-12
*/
@Service
@Transactional(readOnly = true)
public class CourseService extends CrudService<CourseMapper, Course> {
public Course get(String id) {
return super.get(id);
}
public List<Course> findList(Course course) {
return super.findList(course);
}
public Page<Course> findPage(Page<Course> page, Course course) {
return super.findPage(page, course);
}
@Transactional(readOnly = false)
public void save(Course course) {
super.save(course);
}
@Transactional(readOnly = false)
public void delete(Course course) {
super.delete(course);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytomany.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.manytomany.entity.StudentCourse;
import com.jeeplus.modules.test.manytomany.mapper.StudentCourseMapper;
/**
* 学生课程记录Service
* @author lgf
* @version 2018-06-12
*/
@Service
@Transactional(readOnly = true)
public class StudentCourseService extends CrudService<StudentCourseMapper, StudentCourse> {
public StudentCourse get(String id) {
return super.get(id);
}
public List<StudentCourse> findList(StudentCourse studentCourse) {
return super.findList(studentCourse);
}
public Page<StudentCourse> findPage(Page<StudentCourse> page, StudentCourse studentCourse) {
return super.findPage(page, studentCourse);
}
@Transactional(readOnly = false)
public void save(StudentCourse studentCourse) {
super.save(studentCourse);
}
@Transactional(readOnly = false)
public void delete(StudentCourse studentCourse) {
super.delete(studentCourse);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytomany.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.manytomany.entity.Student;
import com.jeeplus.modules.test.manytomany.mapper.StudentMapper;
/**
* 学生Service
* @author lgf
* @version 2018-06-12
*/
@Service
@Transactional(readOnly = true)
public class StudentService extends CrudService<StudentMapper, Student> {
public Student get(String id) {
return super.get(id);
}
public List<Student> findList(Student student) {
return super.findList(student);
}
public Page<Student> findPage(Page<Student> page, Student student) {
return super.findPage(page, student);
}
@Transactional(readOnly = false)
public void save(Student student) {
super.save(student);
}
@Transactional(readOnly = false)
public void delete(Student student) {
super.delete(student);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytomany.web;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.modules.test.manytomany.entity.Student;
import com.jeeplus.modules.test.manytomany.service.StudentService;
/**
* 学生Controller
* @author lgf
* @version 2018-06-12
*/
@Controller
@RequestMapping(value = "${adminPath}/test/manytomany/student")
public class StudentController extends BaseController {
@Autowired
private StudentService studentService;
@ModelAttribute
public Student get(@RequestParam(required=false) String id) {
Student entity = null;
if (StringUtils.isNotBlank(id)){
entity = studentService.get(id);
}
if (entity == null){
entity = new Student();
}
return entity;
}
/**
* 学生列表页面
*/
@RequiresPermissions("test:manytomany:student:list")
@RequestMapping(value = {"list", ""})
public String list(Student student, Model model) {
model.addAttribute("student", student);
return "modules/test/manytomany/studentList";
}
/**
* 学生列表数据
*/
@ResponseBody
@RequiresPermissions("test:manytomany:student:list")
@RequestMapping(value = "data")
public Map<String, Object> data(Student student, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<Student> page = studentService.findPage(new Page<Student>(request, response), student);
return getBootstrapData(page);
}
/**
* 查看,增加,编辑学生表单页面
*/
@RequiresPermissions(value={"test:manytomany:student:view","test:manytomany:student:add","test:manytomany:student:edit"},logical=Logical.OR)
@RequestMapping(value = "form/{mode}")
public String form(@PathVariable String mode, Student student, Model model) {
model.addAttribute("student", student);
model.addAttribute("mode", mode);
return "modules/test/manytomany/studentForm";
}
/**
* 保存学生
*/
@ResponseBody
@RequiresPermissions(value={"test:manytomany:student:add","test:manytomany:student:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public AjaxJson save(Student student, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(student);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
//新增或编辑表单保存
studentService.save(student);//保存
j.setSuccess(true);
j.setMsg("保存学生成功");
return j;
}
/**
* 删除学生
*/
@ResponseBody
@RequiresPermissions("test:manytomany:student:del")
@RequestMapping(value = "delete")
public AjaxJson delete(Student student) {
AjaxJson j = new AjaxJson();
studentService.delete(student);
j.setMsg("删除学生成功");
return j;
}
/**
* 批量删除学生
*/
@ResponseBody
@RequiresPermissions("test:manytomany:student:del")
@RequestMapping(value = "deleteAll")
public AjaxJson deleteAll(String ids) {
AjaxJson j = new AjaxJson();
String idArray[] =ids.split(",");
for(String id : idArray){
studentService.delete(studentService.get(id));
}
j.setMsg("删除学生成功");
return j;
}
/**
* 导出excel文件
*/
@ResponseBody
@RequiresPermissions("test:manytomany:student:export")
@RequestMapping(value = "export")
public AjaxJson exportFile(Student student, HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "学生"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<Student> page = studentService.findPage(new Page<Student>(request, response, -1), student);
new ExportExcel("学生", Student.class).setDataList(page.getList()).write(response, fileName).dispose();
j.setSuccess(true);
j.setMsg("导出成功!");
return j;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导出学生记录失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 导入Excel数据
*/
@ResponseBody
@RequiresPermissions("test:manytomany:student:import")
@RequestMapping(value = "import")
public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<Student> list = ei.getDataList(Student.class);
for (Student student : list){
try{
studentService.save(student);
successNum++;
}catch(ConstraintViolationException ex){
failureNum++;
}catch (Exception ex) {
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条学生记录。");
}
j.setMsg( "已成功导入 "+successNum+" 条学生记录"+failureMsg);
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导入学生失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 下载导入学生数据模板
*/
@ResponseBody
@RequiresPermissions("test:manytomany:student:import")
@RequestMapping(value = "import/template")
public AjaxJson importFileTemplate(HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "学生数据导入模板.xlsx";
List<Student> list = Lists.newArrayList();
new ExportExcel("学生数据", Student.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg( "导入模板下载失败!失败信息:"+e.getMessage());
}
return j;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytomany.web;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.modules.test.manytomany.entity.StudentCourse;
import com.jeeplus.modules.test.manytomany.service.StudentCourseService;
/**
* 学生课程记录Controller
* @author lgf
* @version 2018-06-12
*/
@Controller
@RequestMapping(value = "${adminPath}/test/manytomany/studentCourse")
public class StudentCourseController extends BaseController {
@Autowired
private StudentCourseService studentCourseService;
@ModelAttribute
public StudentCourse get(@RequestParam(required=false) String id) {
StudentCourse entity = null;
if (StringUtils.isNotBlank(id)){
entity = studentCourseService.get(id);
}
if (entity == null){
entity = new StudentCourse();
}
return entity;
}
/**
* 学生课程记录列表页面
*/
@RequiresPermissions("test:manytomany:studentCourse:list")
@RequestMapping(value = {"list", ""})
public String list(StudentCourse studentCourse, Model model) {
model.addAttribute("studentCourse", studentCourse);
return "modules/test/manytomany/studentCourseList";
}
/**
* 学生课程记录列表数据
*/
@ResponseBody
@RequiresPermissions("test:manytomany:studentCourse:list")
@RequestMapping(value = "data")
public Map<String, Object> data(StudentCourse studentCourse, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<StudentCourse> page = studentCourseService.findPage(new Page<StudentCourse>(request, response), studentCourse);
return getBootstrapData(page);
}
/**
* 查看,增加,编辑学生课程记录表单页面
*/
@RequiresPermissions(value={"test:manytomany:studentCourse:view","test:manytomany:studentCourse:add","test:manytomany:studentCourse:edit"},logical=Logical.OR)
@RequestMapping(value = "form/{mode}")
public String form(@PathVariable String mode, StudentCourse studentCourse, Model model) {
model.addAttribute("studentCourse", studentCourse);
model.addAttribute("mode", mode);
return "modules/test/manytomany/studentCourseForm";
}
/**
* 保存学生课程记录
*/
@ResponseBody
@RequiresPermissions(value={"test:manytomany:studentCourse:add","test:manytomany:studentCourse:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public AjaxJson save(StudentCourse studentCourse, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(studentCourse);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
//新增或编辑表单保存
studentCourseService.save(studentCourse);//保存
j.setSuccess(true);
j.setMsg("保存学生课程记录成功");
return j;
}
/**
* 删除学生课程记录
*/
@ResponseBody
@RequiresPermissions("test:manytomany:studentCourse:del")
@RequestMapping(value = "delete")
public AjaxJson delete(StudentCourse studentCourse) {
AjaxJson j = new AjaxJson();
studentCourseService.delete(studentCourse);
j.setMsg("删除学生课程记录成功");
return j;
}
/**
* 批量删除学生课程记录
*/
@ResponseBody
@RequiresPermissions("test:manytomany:studentCourse:del")
@RequestMapping(value = "deleteAll")
public AjaxJson deleteAll(String ids) {
AjaxJson j = new AjaxJson();
String idArray[] =ids.split(",");
for(String id : idArray){
studentCourseService.delete(studentCourseService.get(id));
}
j.setMsg("删除学生课程记录成功");
return j;
}
/**
* 导出excel文件
*/
@ResponseBody
@RequiresPermissions("test:manytomany:studentCourse:export")
@RequestMapping(value = "export")
public AjaxJson exportFile(StudentCourse studentCourse, HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "学生课程记录"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<StudentCourse> page = studentCourseService.findPage(new Page<StudentCourse>(request, response, -1), studentCourse);
new ExportExcel("学生课程记录", StudentCourse.class).setDataList(page.getList()).write(response, fileName).dispose();
j.setSuccess(true);
j.setMsg("导出成功!");
return j;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导出学生课程记录记录失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 导入Excel数据
*/
@ResponseBody
@RequiresPermissions("test:manytomany:studentCourse:import")
@RequestMapping(value = "import")
public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<StudentCourse> list = ei.getDataList(StudentCourse.class);
for (StudentCourse studentCourse : list){
try{
studentCourseService.save(studentCourse);
successNum++;
}catch(ConstraintViolationException ex){
failureNum++;
}catch (Exception ex) {
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条学生课程记录记录。");
}
j.setMsg( "已成功导入 "+successNum+" 条学生课程记录记录"+failureMsg);
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导入学生课程记录失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 下载导入学生课程记录数据模板
*/
@ResponseBody
@RequiresPermissions("test:manytomany:studentCourse:import")
@RequestMapping(value = "import/template")
public AjaxJson importFileTemplate(HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "学生课程记录数据导入模板.xlsx";
List<StudentCourse> list = Lists.newArrayList();
new ExportExcel("学生课程记录数据", StudentCourse.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg( "导入模板下载失败!失败信息:"+e.getMessage());
}
return j;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytoone.entity;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.jeeplus.core.persistence.TreeEntity;
/**
* 商品类型Entity
* @author liugf
* @version 2018-06-12
*/
public class Category extends TreeEntity<Category> {
private static final long serialVersionUID = 1L;
public Category() {
super();
}
public Category(String id){
super(id);
}
public Category getParent() {
return parent;
}
@Override
public void setParent(Category parent) {
this.parent = parent;
}
public String getParentId() {
return parent != null && parent.getId() != null ? parent.getId() : "0";
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytoone.entity;
import com.jeeplus.modules.test.manytoone.entity.Category;
import javax.validation.constraints.NotNull;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 商品Entity
* @author liugf
* @version 2018-06-12
*/
public class Goods extends DataEntity<Goods> {
private static final long serialVersionUID = 1L;
private String name; // 商品名称
private Category category; // 所属类型
private String price; // 价格
public Goods() {
super();
}
public Goods(String id){
super(id);
}
@ExcelField(title="商品名称", align=2, sort=1)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@NotNull(message="所属类型不能为空")
@ExcelField(title="所属类型", fieldType=Category.class, value="category.name", align=2, sort=2)
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
@ExcelField(title="价格", align=2, sort=3)
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytoone.mapper;
import com.jeeplus.core.persistence.TreeMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.test.manytoone.entity.Category;
/**
* 商品类型MAPPER接口
* @author liugf
* @version 2018-06-12
*/
@MyBatisMapper
public interface CategoryMapper extends TreeMapper<Category> {
}
\ No newline at end of file
<?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.jeeplus.modules.test.manytoone.mapper.CategoryMapper">
<resultMap id="categoryResult" type="Category">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="sort" column="sort" />
<result property="parentIds" column="parentIds" />
<association property="hasChildren" column="id" select="hasChildren" />
</resultMap>
<sql id="categoryColumns">
a.id AS "id",
a.name AS "name",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag",
a.parent_id AS "parent.id",
a.parent_ids AS "parentIds",
a.sort AS "sort"
</sql>
<sql id="categoryJoins">
</sql>
<select id="get" resultType="Category">
SELECT
<include refid="categoryColumns"/>
FROM test_category a
<include refid="categoryJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="Category">
SELECT
<include refid="categoryColumns"/>
FROM test_category a
<include refid="categoryJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="name != null and name != ''">
AND a.name LIKE
<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
</if>
<if test="parent != null and parent.id != null and parent.id != ''">
AND a.parent_id = #{parent.id}
</if>
<if test="parentIds != null and parentIds != ''">
AND a.parent_ids LIKE
<if test="dbName == 'oracle'">'%'||#{parentIds}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{parentIds}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{parentIds},'%')</if>
</if>
</where>
ORDER BY a.sort ASC
</select>
<select id="findAllList" resultType="Category">
SELECT
<include refid="categoryColumns"/>
FROM test_category a
<include refid="categoryJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
ORDER BY a.sort ASC
</select>
<select id="getChildren" parameterType="String" resultMap="categoryResult">
select * from test_category where parent_id = #{id} ORDER BY sort
</select>
<select id="hasChildren" parameterType="String" resultType="Boolean">
select case when exists(select 1 from test_category where parent_id = #{id}) then 1 else 0 end ${dual}
</select>
<select id="findByParentIdsLike" resultType="Category">
SELECT
a.id,
a.parent_id AS "parent.id",
a.parent_ids
FROM test_category a
<include refid="categoryJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
AND a.parent_ids LIKE #{parentIds}
</where>
ORDER BY a.sort ASC
</select>
<insert id="insert">
INSERT INTO test_category(
id,
name,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag,
parent_id,
parent_ids,
sort
) VALUES (
#{id},
#{name},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag},
#{parent.id},
#{parentIds},
#{sort}
)
</insert>
<update id="update">
UPDATE test_category SET
name = #{name},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks},
parent_id = #{parent.id},
parent_ids = #{parentIds},
sort = #{sort}
WHERE id = #{id}
</update>
<update id="updateParentIds">
UPDATE test_category SET
parent_id = #{parent.id},
parent_ids = #{parentIds}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM test_category
WHERE id = #{id} OR parent_ids LIKE
<if test="dbName == 'oracle'">'%,'||#{id}||',%'</if>
<if test="dbName == 'mssql'">'%,'+#{id}+',%'</if>
<if test="dbName == 'mysql'">CONCAT('%,', #{id}, ',%')</if>
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE test_category SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id} OR parent_ids LIKE
<if test="dbName == 'oracle'">'%,'||#{id}||',%'</if>
<if test="dbName == 'mssql'">'%,'+#{id}+',%'</if>
<if test="dbName == 'mysql'">CONCAT('%,', #{id}, ',%')</if>
</update>
</mapper>
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytoone.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.service.TreeService;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.test.manytoone.entity.Category;
import com.jeeplus.modules.test.manytoone.mapper.CategoryMapper;
/**
* 商品类型Service
* @author liugf
* @version 2018-06-12
*/
@Service
@Transactional(readOnly = true)
public class CategoryService extends TreeService<CategoryMapper, Category> {
public Category get(String id) {
return super.get(id);
}
public List<Category> findList(Category category) {
if (StringUtils.isNotBlank(category.getParentIds())){
category.setParentIds(","+category.getParentIds()+",");
}
return super.findList(category);
}
@Transactional(readOnly = false)
public void save(Category category) {
super.save(category);
}
@Transactional(readOnly = false)
public void delete(Category category) {
super.delete(category);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytoone.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.manytoone.entity.Goods;
import com.jeeplus.modules.test.manytoone.mapper.GoodsMapper;
/**
* 商品Service
* @author liugf
* @version 2018-06-12
*/
@Service
@Transactional(readOnly = true)
public class GoodsService extends CrudService<GoodsMapper, Goods> {
public Goods get(String id) {
return super.get(id);
}
public List<Goods> findList(Goods goods) {
return super.findList(goods);
}
public Page<Goods> findPage(Page<Goods> page, Goods goods) {
return super.findPage(page, goods);
}
@Transactional(readOnly = false)
public void save(Goods goods) {
super.save(goods);
}
@Transactional(readOnly = false)
public void delete(Goods goods) {
super.delete(goods);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.manytoone.web;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.common.config.Global;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.test.manytoone.entity.Category;
import com.jeeplus.modules.test.manytoone.service.CategoryService;
/**
* 商品类型Controller
* @author liugf
* @version 2018-06-12
*/
@Controller
@RequestMapping(value = "${adminPath}/test/manytoone/category")
public class CategoryController extends BaseController {
@Autowired
private CategoryService categoryService;
@ModelAttribute
public Category get(@RequestParam(required=false) String id) {
Category entity = null;
if (StringUtils.isNotBlank(id)){
entity = categoryService.get(id);
}
if (entity == null){
entity = new Category();
}
return entity;
}
/**
* 商品类型列表页面
*/
@RequiresPermissions("test:manytoone:category:list")
@RequestMapping(value = {"list", ""})
public String list(Category category, HttpServletRequest request, HttpServletResponse response, Model model) {
model.addAttribute("category", category);
return "modules/test/manytoone/categoryList";
}
/**
* 查看,增加,编辑商品类型表单页面
*/
@RequiresPermissions(value={"test:manytoone:category:view","test:manytoone:category:add","test:manytoone:category:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(Category category, Model model) {
if (category.getParent()!=null && StringUtils.isNotBlank(category.getParent().getId())){
category.setParent(categoryService.get(category.getParent().getId()));
// 获取排序号,最末节点排序号+30
if (StringUtils.isBlank(category.getId())){
Category categoryChild = new Category();
categoryChild.setParent(new Category(category.getParent().getId()));
List<Category> list = categoryService.findList(category);
if (list.size() > 0){
category.setSort(list.get(list.size()-1).getSort());
if (category.getSort() != null){
category.setSort(category.getSort() + 30);
}
}
}
}
if (category.getSort() == null){
category.setSort(30);
}
model.addAttribute("category", category);
return "modules/test/manytoone/categoryForm";
}
/**
* 保存商品类型
*/
@ResponseBody
@RequiresPermissions(value={"test:manytoone:category:add","test:manytoone:category:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public AjaxJson save(Category category, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(category);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
//新增或编辑表单保存
categoryService.save(category);//保存
j.setSuccess(true);
j.put("category", category);
j.setMsg("保存商品类型成功");
return j;
}
@ResponseBody
@RequestMapping(value = "getChildren")
public List<Category> getChildren(String parentId){
if("-1".equals(parentId)){//如果是-1,没指定任何父节点,就从根节点开始查找
parentId = "0";
}
return categoryService.getChildren(parentId);
}
/**
* 删除商品类型
*/
@ResponseBody
@RequiresPermissions("test:manytoone:category:del")
@RequestMapping(value = "delete")
public AjaxJson delete(Category category) {
AjaxJson j = new AjaxJson();
categoryService.delete(category);
j.setSuccess(true);
j.setMsg("删除商品类型成功");
return j;
}
@RequiresPermissions("user")
@ResponseBody
@RequestMapping(value = "treeData")
public List<Map<String, Object>> treeData(@RequestParam(required=false) String extId, HttpServletResponse response) {
List<Map<String, Object>> mapList = Lists.newArrayList();
List<Category> list = categoryService.findList(new Category());
for (int i=0; i<list.size(); i++){
Category e = list.get(i);
if (StringUtils.isBlank(extId) || (extId!=null && !extId.equals(e.getId()) && e.getParentIds().indexOf(","+extId+",")==-1)){
Map<String, Object> map = Maps.newHashMap();
map.put("id", e.getId());
map.put("text", e.getName());
if(StringUtils.isBlank(e.getParentId()) || "0".equals(e.getParentId())){
map.put("parent", "#");
Map<String, Object> state = Maps.newHashMap();
state.put("opened", true);
map.put("state", state);
}else{
map.put("parent", e.getParentId());
}
mapList.add(map);
}
}
return mapList;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.note.entity;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 富文本测试Entity
* @author liugf
* @version 2018-06-12
*/
public class TestNote extends DataEntity<TestNote> {
private static final long serialVersionUID = 1L;
private String title; // 标题
private String contents; // 内容
public TestNote() {
super();
}
public TestNote(String id){
super(id);
}
@ExcelField(title="标题", align=2, sort=7)
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@ExcelField(title="内容", align=2, sort=8)
public String getContents() {
return contents;
}
public void setContents(String contents) {
this.contents = contents;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.note.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.test.note.entity.TestNote;
/**
* 富文本测试MAPPER接口
* @author liugf
* @version 2018-06-12
*/
@MyBatisMapper
public interface TestNoteMapper extends BaseMapper<TestNote> {
}
\ No newline at end of file
<?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.jeeplus.modules.test.note.mapper.TestNoteMapper">
<sql id="testNoteColumns">
a.id AS "id",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag",
a.title AS "title",
a.contents AS "contents"
</sql>
<sql id="testNoteJoins">
</sql>
<resultMap type="TestNote" id="TestNoteResult" autoMapping="true">
<result column="contents" property="contents" typeHandler="com.jeeplus.core.mapper.ConvertBlobTypeHandler"/>
</resultMap>
<select id="get" resultMap="TestNoteResult" >
SELECT
<include refid="testNoteColumns"/>
FROM test_note a
<include refid="testNoteJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultMap="TestNoteResult" >
SELECT
<include refid="testNoteColumns"/>
FROM test_note a
<include refid="testNoteJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="title != null and title != ''">
AND a.title = #{title}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultMap="TestNoteResult" >
SELECT
<include refid="testNoteColumns"/>
FROM test_note a
<include refid="testNoteJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO test_note(
id,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag,
title,
contents
) VALUES (
#{id},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag},
#{title},
#{contents}
)
</insert>
<update id="update">
UPDATE test_note SET
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks},
title = #{title},
contents = #{contents}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM test_note
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE test_note SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="TestNote" statementType="STATEMENT">
select * FROM test_note where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.note.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.note.entity.TestNote;
import com.jeeplus.modules.test.note.mapper.TestNoteMapper;
/**
* 富文本测试Service
* @author liugf
* @version 2018-06-12
*/
@Service
@Transactional(readOnly = true)
public class TestNoteService extends CrudService<TestNoteMapper, TestNote> {
public TestNote get(String id) {
return super.get(id);
}
public List<TestNote> findList(TestNote testNote) {
return super.findList(testNote);
}
public Page<TestNote> findPage(Page<TestNote> page, TestNote testNote) {
return super.findPage(page, testNote);
}
@Transactional(readOnly = false)
public void save(TestNote testNote) {
super.save(testNote);
}
@Transactional(readOnly = false)
public void delete(TestNote testNote) {
super.delete(testNote);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.note.web;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.modules.test.note.entity.TestNote;
import com.jeeplus.modules.test.note.service.TestNoteService;
/**
* 富文本测试Controller
* @author liugf
* @version 2018-06-12
*/
@Controller
@RequestMapping(value = "${adminPath}/test/note/testNote")
public class TestNoteController extends BaseController {
@Autowired
private TestNoteService testNoteService;
@ModelAttribute
public TestNote get(@RequestParam(required=false) String id) {
TestNote entity = null;
if (StringUtils.isNotBlank(id)){
entity = testNoteService.get(id);
}
if (entity == null){
entity = new TestNote();
}
return entity;
}
/**
* 富文本测试列表页面
*/
@RequiresPermissions("test:note:testNote:list")
@RequestMapping(value = {"list", ""})
public String list(TestNote testNote, Model model) {
model.addAttribute("testNote", testNote);
return "modules/test/note/testNoteList";
}
/**
* 富文本测试列表数据
*/
@ResponseBody
@RequiresPermissions("test:note:testNote:list")
@RequestMapping(value = "data")
public Map<String, Object> data(TestNote testNote, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<TestNote> page = testNoteService.findPage(new Page<TestNote>(request, response), testNote);
return getBootstrapData(page);
}
/**
* 查看,增加,编辑富文本测试表单页面
*/
@RequiresPermissions(value={"test:note:testNote:view","test:note:testNote:add","test:note:testNote:edit"},logical=Logical.OR)
@RequestMapping(value = "form/{mode}")
public String form(@PathVariable String mode, TestNote testNote, Model model) {
model.addAttribute("testNote", testNote);
model.addAttribute("mode", mode);
return "modules/test/note/testNoteForm";
}
/**
* 保存富文本测试
*/
@ResponseBody
@RequiresPermissions(value={"test:note:testNote:add","test:note:testNote:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public AjaxJson save(TestNote testNote, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(testNote);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
//新增或编辑表单保存
testNoteService.save(testNote);//保存
j.setSuccess(true);
j.setMsg("保存富文本测试成功");
return j;
}
/**
* 删除富文本测试
*/
@ResponseBody
@RequiresPermissions("test:note:testNote:del")
@RequestMapping(value = "delete")
public AjaxJson delete(TestNote testNote) {
AjaxJson j = new AjaxJson();
testNoteService.delete(testNote);
j.setMsg("删除富文本测试成功");
return j;
}
/**
* 批量删除富文本测试
*/
@ResponseBody
@RequiresPermissions("test:note:testNote:del")
@RequestMapping(value = "deleteAll")
public AjaxJson deleteAll(String ids) {
AjaxJson j = new AjaxJson();
String idArray[] =ids.split(",");
for(String id : idArray){
testNoteService.delete(testNoteService.get(id));
}
j.setMsg("删除富文本测试成功");
return j;
}
/**
* 导出excel文件
*/
@ResponseBody
@RequiresPermissions("test:note:testNote:export")
@RequestMapping(value = "export")
public AjaxJson exportFile(TestNote testNote, HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "富文本测试"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<TestNote> page = testNoteService.findPage(new Page<TestNote>(request, response, -1), testNote);
new ExportExcel("富文本测试", TestNote.class).setDataList(page.getList()).write(response, fileName).dispose();
j.setSuccess(true);
j.setMsg("导出成功!");
return j;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导出富文本测试记录失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 导入Excel数据
*/
@ResponseBody
@RequiresPermissions("test:note:testNote:import")
@RequestMapping(value = "import")
public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<TestNote> list = ei.getDataList(TestNote.class);
for (TestNote testNote : list){
try{
testNoteService.save(testNote);
successNum++;
}catch(ConstraintViolationException ex){
failureNum++;
}catch (Exception ex) {
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条富文本测试记录。");
}
j.setMsg( "已成功导入 "+successNum+" 条富文本测试记录"+failureMsg);
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导入富文本测试失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 下载导入富文本测试数据模板
*/
@ResponseBody
@RequiresPermissions("test:note:testNote:import")
@RequestMapping(value = "import/template")
public AjaxJson importFileTemplate(HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "富文本测试数据导入模板.xlsx";
List<TestNote> list = Lists.newArrayList();
new ExportExcel("富文本测试数据", TestNote.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg( "导入模板下载失败!失败信息:"+e.getMessage());
}
return j;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.one.dialog.entity;
import com.jeeplus.modules.sys.entity.Office;
import javax.validation.constraints.NotNull;
import com.jeeplus.modules.sys.entity.User;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 请假表单Entity
* @author lgf
* @version 2018-06-12
*/
public class Leave1 extends DataEntity<Leave1> {
private static final long serialVersionUID = 1L;
private Office office; // 归属部门
private User tuser; // 员工
private String area; // 归属区域
private Date beginDate; // 请假开始日期
private Date endDate; // 请假结束日期
private Date beginBeginDate; // 开始 请假开始日期
private Date endBeginDate; // 结束 请假开始日期
public Leave1() {
super();
}
public Leave1(String id){
super(id);
}
@NotNull(message="归属部门不能为空")
@ExcelField(title="归属部门", fieldType=Office.class, value="office.name", align=2, sort=1)
public Office getOffice() {
return office;
}
public void setOffice(Office office) {
this.office = office;
}
@NotNull(message="员工不能为空")
@ExcelField(title="员工", fieldType=User.class, value="tuser.name", align=2, sort=2)
public User getTuser() {
return tuser;
}
public void setTuser(User tuser) {
this.tuser = tuser;
}
@ExcelField(title="归属区域", align=2, sort=3)
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message="请假开始日期不能为空")
@ExcelField(title="请假开始日期", align=2, sort=4)
public Date getBeginDate() {
return beginDate;
}
public void setBeginDate(Date beginDate) {
this.beginDate = beginDate;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message="请假结束日期不能为空")
@ExcelField(title="请假结束日期", align=2, sort=5)
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public Date getBeginBeginDate() {
return beginBeginDate;
}
public void setBeginBeginDate(Date beginBeginDate) {
this.beginBeginDate = beginBeginDate;
}
public Date getEndBeginDate() {
return endBeginDate;
}
public void setEndBeginDate(Date endBeginDate) {
this.endBeginDate = endBeginDate;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.one.dialog.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.test.one.dialog.entity.Leave1;
/**
* 请假表单MAPPER接口
* @author lgf
* @version 2018-06-12
*/
@MyBatisMapper
public interface Leave1Mapper extends BaseMapper<Leave1> {
}
\ No newline at end of file
<?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.jeeplus.modules.test.one.dialog.mapper.Leave1Mapper">
<sql id="leave1Columns">
a.id AS "id",
a.office_id AS "office.id",
a.user_id AS "tuser.id",
a.area_id AS "area",
a.begin_date AS "beginDate",
a.end_date AS "endDate",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag",
office.name AS "office.name",
tuser.name AS "tuser.name"
</sql>
<sql id="leave1Joins">
LEFT JOIN sys_office office ON office.id = a.office_id
LEFT JOIN sys_user tuser ON tuser.id = a.user_id
</sql>
<select id="get" resultType="Leave1" >
SELECT
<include refid="leave1Columns"/>
FROM test_leave a
<include refid="leave1Joins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="Leave1" >
SELECT
<include refid="leave1Columns"/>
FROM test_leave a
<include refid="leave1Joins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="office != null and office.id != null and office.id != ''">
AND a.office_id = #{office.id}
</if>
<if test="tuser != null and tuser.id != null and tuser.id != ''">
AND a.user_id = #{tuser.id}
</if>
<if test="area != null and area != ''">
AND a.area_id LIKE
<if test="dbName == 'oracle'">'%'||#{area}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{area}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{area},'%')</if>
</if>
<if test="beginBeginDate != null and endBeginDate != null ">
AND a.begin_date BETWEEN #{beginBeginDate} AND #{endBeginDate}
</if>
<if test="endDate != null and endDate != ''">
AND a.end_date = #{endDate}
</if>
<if test="remarks != null and remarks != ''">
AND a.remarks = #{remarks}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="Leave1" >
SELECT
<include refid="leave1Columns"/>
FROM test_leave a
<include refid="leave1Joins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO test_leave(
id,
office_id,
user_id,
area_id,
begin_date,
end_date,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{office.id},
#{tuser.id},
#{area},
#{beginDate},
#{endDate},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE test_leave SET
office_id = #{office.id},
user_id = #{tuser.id},
area_id = #{area},
begin_date = #{beginDate},
end_date = #{endDate},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM test_leave
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE test_leave SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="Leave1" statementType="STATEMENT">
select * FROM test_leave where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.one.dialog.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.test.one.dialog.entity.Leave1;
import com.jeeplus.modules.test.one.dialog.mapper.Leave1Mapper;
/**
* 请假表单Service
* @author lgf
* @version 2018-06-12
*/
@Service
@Transactional(readOnly = true)
public class Leave1Service extends CrudService<Leave1Mapper, Leave1> {
public Leave1 get(String id) {
return super.get(id);
}
public List<Leave1> findList(Leave1 leave1) {
return super.findList(leave1);
}
public Page<Leave1> findPage(Page<Leave1> page, Leave1 leave1) {
return super.findPage(page, leave1);
}
@Transactional(readOnly = false)
public void save(Leave1 leave1) {
super.save(leave1);
}
@Transactional(readOnly = false)
public void delete(Leave1 leave1) {
super.delete(leave1);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.test.one.dialog.web;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.modules.test.one.dialog.entity.Leave1;
import com.jeeplus.modules.test.one.dialog.service.Leave1Service;
/**
* 请假表单Controller
* @author lgf
* @version 2018-06-12
*/
@Controller
@RequestMapping(value = "${adminPath}/test/one/dialog/leave1")
public class Leave1Controller extends BaseController {
@Autowired
private Leave1Service leave1Service;
@ModelAttribute
public Leave1 get(@RequestParam(required=false) String id) {
Leave1 entity = null;
if (StringUtils.isNotBlank(id)){
entity = leave1Service.get(id);
}
if (entity == null){
entity = new Leave1();
}
return entity;
}
/**
* 请假表单列表页面
*/
@RequiresPermissions("test:one:dialog:leave1:list")
@RequestMapping(value = {"list", ""})
public String list(Leave1 leave1, Model model) {
model.addAttribute("leave1", leave1);
return "modules/test/one/dialog/leave1List";
}
/**
* 请假表单列表数据
*/
@ResponseBody
@RequiresPermissions("test:one:dialog:leave1:list")
@RequestMapping(value = "data")
public Map<String, Object> data(Leave1 leave1, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<Leave1> page = leave1Service.findPage(new Page<Leave1>(request, response), leave1);
return getBootstrapData(page);
}
/**
* 查看,增加,编辑请假表单表单页面
*/
@RequiresPermissions(value={"test:one:dialog:leave1:view","test:one:dialog:leave1:add","test:one:dialog:leave1:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(Leave1 leave1, Model model) {
model.addAttribute("leave1", leave1);
return "modules/test/one/dialog/leave1Form";
}
/**
* 保存请假表单
*/
@ResponseBody
@RequiresPermissions(value={"test:one:dialog:leave1:add","test:one:dialog:leave1:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public AjaxJson save(Leave1 leave1, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(leave1);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
//新增或编辑表单保存
leave1Service.save(leave1);//保存
j.setSuccess(true);
j.setMsg("保存请假表单成功");
return j;
}
/**
* 删除请假表单
*/
@ResponseBody
@RequiresPermissions("test:one:dialog:leave1:del")
@RequestMapping(value = "delete")
public AjaxJson delete(Leave1 leave1) {
AjaxJson j = new AjaxJson();
leave1Service.delete(leave1);
j.setMsg("删除请假表单成功");
return j;
}
/**
* 批量删除请假表单
*/
@ResponseBody
@RequiresPermissions("test:one:dialog:leave1:del")
@RequestMapping(value = "deleteAll")
public AjaxJson deleteAll(String ids) {
AjaxJson j = new AjaxJson();
String idArray[] =ids.split(",");
for(String id : idArray){
leave1Service.delete(leave1Service.get(id));
}
j.setMsg("删除请假表单成功");
return j;
}
/**
* 导出excel文件
*/
@ResponseBody
@RequiresPermissions("test:one:dialog:leave1:export")
@RequestMapping(value = "export")
public AjaxJson exportFile(Leave1 leave1, HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "请假表单"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<Leave1> page = leave1Service.findPage(new Page<Leave1>(request, response, -1), leave1);
new ExportExcel("请假表单", Leave1.class).setDataList(page.getList()).write(response, fileName).dispose();
j.setSuccess(true);
j.setMsg("导出成功!");
return j;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导出请假表单记录失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 导入Excel数据
*/
@ResponseBody
@RequiresPermissions("test:one:dialog:leave1:import")
@RequestMapping(value = "import")
public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<Leave1> list = ei.getDataList(Leave1.class);
for (Leave1 leave1 : list){
try{
leave1Service.save(leave1);
successNum++;
}catch(ConstraintViolationException ex){
failureNum++;
}catch (Exception ex) {
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条请假表单记录。");
}
j.setMsg( "已成功导入 "+successNum+" 条请假表单记录"+failureMsg);
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导入请假表单失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 下载导入请假表单数据模板
*/
@ResponseBody
@RequiresPermissions("test:one:dialog:leave1:import")
@RequestMapping(value = "import/template")
public AjaxJson importFileTemplate(HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "请假表单数据导入模板.xlsx";
List<Leave1> list = Lists.newArrayList();
new ExportExcel("请假表单数据", Leave1.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg( "导入模板下载失败!失败信息:"+e.getMessage());
}
return j;
}
}
\ 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