Commit e9be6e2a by zhengxj

finish 将代码移至usercenter on 20190122 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@16910 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent e1e4ef44
/**
*
*/
package com.glsx.usercenter.constants;
/**
* @ClassName: Constants
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月3日
*
*/
public interface Constants {
final static byte BUTTON = 1;
final static byte MENU = 2;
final static byte CATALOG = 3;
}
package com.glsx.usercenter.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
/**
*
* @Title BaseController.java
* @Package com.glsx.manager.controller
* @Description TODO
* @author zhanghj
* @date 2019年1月3日 下午4:51:03
* @version 1.0.0
*/
public class BaseController {
public Logger logger = LoggerFactory.getLogger(getClass());
/**
* hibernate-validator参数校验返回错误方法
* @param result
* @return
*/
public Map<String, String> getErrors(BindingResult result) {
Map<String, String> map = new HashMap<String, String>();
List<FieldError> list = result.getFieldErrors();
for (FieldError error : list) {
map.put(error.getField(), error.getDefaultMessage());
}
return map;
}
/**
* hibernate-validator对于特殊参数格式的校验方式
* @param object
* @return
*/
public Map<String, String> getErrors(Object object) {
Map<String, String> map = new HashMap<String, String>();
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object);
for (ConstraintViolation<Object> constraintViolation : constraintViolations) {
String key = constraintViolation.getPropertyPath().toString();
String value = constraintViolation.getMessage();
map.put(key, value);
}
return map;
}
}
/*
* Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved.
* GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.glsx.usercenter.controller;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.StringUtils;
import com.glsx.usercenter.constants.ResultCodeEnum;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.service.ISysOrganizationService;
/**
* @ClassName: OrganizationController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月22日
*
*/
@RestController
@RequestMapping("/organization")
public class OrganizationController extends BaseController{
@Autowired
private ISysOrganizationService organizationService;
@RequestMapping(value = "/getByParams", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getByParams(Integer id, String name, Byte menuStatus) {
if (!StringUtils.isNull(name)) {
name = name.replaceAll(" ", "");
}
Map map = new HashMap();
if (StringUtils.isNull(name) && menuStatus == null && id == null) {
// 菜单状态:1,正常、0.停用、2.注销
// 只查询一级菜单
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.selectByExample(null, null));
} else {
if (StringUtils.isNull(name) && (menuStatus != null || id != null)) {
if (menuStatus == null) {
// 根据id递归查询子菜单
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.findAllRecursion(id));
} else if (id != null) {
// // 根据id和状态递归查询子菜单
map.put("menu_status", menuStatus);
map.put("id", id);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.findMenuByParams(map));
}
}
// 根据名字和状态搜索
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.selectByExample(name, menuStatus));
}
}
@RequestMapping(value = "/add", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject add(@RequestParam(value = "SysOrganization", required = true) SysOrganization sysOrganization) {
int i = organizationService.insertSelective(sysOrganization);
String msg = i == 0 ? ResultCodeEnum.FAIL.getMsg() : ResultCodeEnum.SUCCESS.getMsg();
int code = i == 0 ? ResultCodeEnum.FAIL.getCode() : ResultCodeEnum.SUCCESS.getCode();
return new ResultObject(code, msg);
}
@RequestMapping(value = "/deleteById", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject deleteById(@RequestParam(value = "id", required = false) Integer id) {
if (id == null) {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.PARAM_ERROR);
}
int i = organizationService.deleteByPrimaryKey(id);
String msg = i == 0 ? ResultCodeEnum.FAIL.getMsg() : ResultCodeEnum.SUCCESS.getMsg();
int code = i == 0 ? ResultCodeEnum.FAIL.getCode() : ResultCodeEnum.SUCCESS.getCode();
return new ResultObject(code, msg);
}
@RequestMapping(value = "/update", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject update(@RequestParam(value = "sysOrganization", required = false) SysOrganization sysOrganization) {
organizationService.updateByPrimaryKeySelective(sysOrganization);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
}
/**
*
*/
package com.glsx.usercenter.controller;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.StringUtils;
import com.glsx.usercenter.constants.ResultCodeEnum;
import com.glsx.usercenter.pojo.menu.SysMenu;
import com.glsx.usercenter.service.ISysMenuService;
/**
* @ClassName: SysMenuController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月4日
*
*/
@RestController
@RequestMapping(value="/sysMenu")
public class SysMenuController extends BaseController {
@Autowired
private ISysMenuService menuService;
@SuppressWarnings({ "unchecked", "rawtypes" })
@RequestMapping(value = "/getByParams", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getByParams(Integer id, String name, Byte menuStatus) {
if (!StringUtils.isNull(name)) {
name = name.replaceAll(" ", "");
}
Map map = new HashMap();
if (StringUtils.isNull(name) && menuStatus == null && id == null) {
// 菜单状态:1,正常、0.停用、2.注销
// 只查询一级菜单
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
menuService.selectByExample(null, null));
} else {
if (StringUtils.isNull(name) && (menuStatus != null || id != null)) {
if (menuStatus == null) {
// 根据id递归查询子菜单
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
menuService.findAllRecursion(id));
} else if (id != null) {
// // 根据id和状态递归查询子菜单
map.put("menu_status", menuStatus);
map.put("id", id);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
menuService.findMenuByParams(map));
}
}
// 根据名字和状态搜索
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
menuService.selectByExample(name, menuStatus));
}
}
@RequestMapping(value = "/add", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject add(@RequestParam(value = "sysMenu", required = true) SysMenu sysMenu) {
int i = menuService.insertSelective(sysMenu);
String msg = i == 0 ? ResultCodeEnum.FAIL.getMsg() : ResultCodeEnum.SUCCESS.getMsg();
int code = i == 0 ? ResultCodeEnum.FAIL.getCode() : ResultCodeEnum.SUCCESS.getCode();
return new ResultObject(code, msg);
}
@RequestMapping(value = "/deleteById", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject deleteById(@RequestParam(value = "id", required = false) Integer id) {
if (id == null) {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.PARAM_ERROR);
}
int i = menuService.deleteByPrimaryKey(id);
String msg = i == 0 ? ResultCodeEnum.FAIL.getMsg() : ResultCodeEnum.SUCCESS.getMsg();
int code = i == 0 ? ResultCodeEnum.FAIL.getCode() : ResultCodeEnum.SUCCESS.getCode();
return new ResultObject(code, msg);
}
@RequestMapping(value = "/update", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject update(@RequestParam(value = "sysMenu", required = false) SysMenu sysMenu) {
menuService.updateByPrimaryKey(sysMenu);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
}
package com.glsx.usercenter.mapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.glsx.usercenter.pojo.menu.SysMenu;
import com.glsx.usercenter.pojo.menu.SysMenuExample;
public interface SysMenuMapper {
long countByExample(SysMenuExample example);
int deleteByExample(SysMenuExample example);
int deleteByPrimaryKey(Integer id);
int insert(SysMenu record);
int insertSelective(SysMenu record);
List<SysMenu> selectByExample(SysMenuExample example);
SysMenu selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") SysMenu record, @Param("example") SysMenuExample example);
int updateByExample(@Param("record") SysMenu record, @Param("example") SysMenuExample example);
int updateByPrimaryKeySelective(SysMenu record);
int updateByPrimaryKey(SysMenu record);
List<SysMenu> findMenuByParams(Map map);
SysMenu findMenuByParentId(@Param("id")Integer id);
}
\ No newline at end of file \ No newline at end of file
package com.glsx.usercenter.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample;
public interface SysOrganizationMapper {
long countByExample(SysOrganizationExample example);
int deleteByExample(SysOrganizationExample example);
int deleteByPrimaryKey(Integer id);
int insertSelective(SysOrganization record);
List<SysOrganization> selectByExample(SysOrganizationExample example);
SysOrganization selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") SysOrganization record, @Param("example") SysOrganizationExample example);
int updateByExample(@Param("record") SysOrganization record, @Param("example") SysOrganizationExample example);
int updateByPrimaryKeySelective(SysOrganization record);
int updateByPrimaryKey(SysOrganization record);
}
\ No newline at end of file \ No newline at end of file
package com.glsx.usercenter.pojo.menu;
import java.util.Date;
import java.util.List;
public class SysMenu {
private Integer id;
private String name;
private Integer parentId;
private Integer sort;
private String rightDes;
private String requestAdd;
private Byte menuStatus;
private Byte menuType;
private String menuIcon;
private Byte isShow;
private Date createTime;
private Date updateTime;
private String remark;
private String updateBy;
private String createBy;
private Byte label;
private String menuGroup;
private String funcType;
private List<SysMenu> children;
public List<SysMenu> getChildren() {
return children;
}
public void setChildren(List<SysMenu> children) {
this.children = children;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public String getRightDes() {
return rightDes;
}
public void setRightDes(String rightDes) {
this.rightDes = rightDes == null ? null : rightDes.trim();
}
public String getRequestAdd() {
return requestAdd;
}
public void setRequestAdd(String requestAdd) {
this.requestAdd = requestAdd == null ? null : requestAdd.trim();
}
public Byte getMenuStatus() {
return menuStatus;
}
public void setMenuStatus(Byte menuStatus) {
this.menuStatus = menuStatus;
}
public Byte getMenuType() {
return menuType;
}
public void setMenuType(Byte menuType) {
this.menuType = menuType;
}
public String getMenuIcon() {
return menuIcon;
}
public void setMenuIcon(String menuIcon) {
this.menuIcon = menuIcon == null ? null : menuIcon.trim();
}
public Byte getIsShow() {
return isShow;
}
public void setIsShow(Byte isShow) {
this.isShow = isShow;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy == null ? null : updateBy.trim();
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy == null ? null : createBy.trim();
}
public Byte getLabel() {
return label;
}
public void setLabel(Byte label) {
this.label = label;
}
public String getMenuGroup() {
return menuGroup;
}
public void setMenuGroup(String menuGroup) {
this.menuGroup = menuGroup == null ? null : menuGroup.trim();
}
public String getFuncType() {
return funcType;
}
public void setFuncType(String funcType) {
this.funcType = funcType == null ? null : funcType.trim();
}
}
\ No newline at end of file \ No newline at end of file
package com.glsx.usercenter.pojo.menu;
import java.util.Date;
public class SysOrganization {
private Integer id;
private Integer parentId;
private String name;
private Byte orgStatus;
private Byte orgType;
private Integer sort;
private Date createTime;
private Date updateTime;
private String remark;
private String updateBy;
private String createBy;
private Byte label;
private String orgGroup;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public Byte getOrgStatus() {
return orgStatus;
}
public void setOrgStatus(Byte orgStatus) {
this.orgStatus = orgStatus;
}
public Byte getOrgType() {
return orgType;
}
public void setOrgType(Byte orgType) {
this.orgType = orgType;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy == null ? null : updateBy.trim();
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy == null ? null : createBy.trim();
}
public Byte getLabel() {
return label;
}
public void setLabel(Byte label) {
this.label = label;
}
public String getOrgGroup() {
return orgGroup;
}
public void setOrgGroup(String orgGroup) {
this.orgGroup = orgGroup == null ? null : orgGroup.trim();
}
}
\ No newline at end of file \ No newline at end of file
/**
*
*/
package com.glsx.usercenter.service;
import java.util.List;
import java.util.Map;
import com.glsx.usercenter.pojo.menu.SysMenu;
import com.glsx.usercenter.pojo.menu.SysMenuExample;
/**
* @ClassName: SysMenuService
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月2日
*
*/
public interface ISysMenuService {
long countByExample(SysMenuExample example);
int deleteByPrimaryKey(Integer id);
int insertSelective(SysMenu sysMenu);
List<SysMenu> selectByExample(String name,Byte menuStatus);
SysMenu selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SysMenu sysMenu);
int updateByPrimaryKey(SysMenu sysMenu);
List<SysMenu> findMenuByParams(Map map);
SysMenu findAllRecursion(Integer id);
}
/**
*
*/
package com.glsx.usercenter.service;
import java.util.List;
import java.util.Map;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample;
/**
* @ClassName: ISysOrganizationServic
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月21日
*
*/
public interface ISysOrganizationService {
long countByExample(SysOrganizationExample example);
int deleteByPrimaryKey(Integer id);
int insertSelective(SysOrganization record);
List<SysOrganization> selectByExample(String orgName,Byte orgStatus);
SysOrganization selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SysOrganization record);
List<SysOrganization> findMenuByParams(Map map);
SysOrganization findAllRecursion(Integer id);
}
/**
*
*/
package com.glsx.usercenter.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.glsx.usercenter.mapper.SysOrganizationMapper;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample;
import com.glsx.usercenter.service.ISysOrganizationService;
/**
*
* @ClassName: SysOrganizationServiceImpl
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月22日
*
*/
@Service
public class SysOrganizationServiceImpl implements ISysOrganizationService{
@Autowired
private SysOrganizationMapper orgDao;
/**
*
*/
@Override
public long countByExample(SysOrganizationExample example) {
return orgDao.countByExample(example);
}
@Override
public int deleteByPrimaryKey(Integer id) {
return orgDao.deleteByPrimaryKey(id);
}
/**
*
*/
@Override
public int insertSelective(SysOrganization record) {
return orgDao.insertSelective(record);
}
/**
*
*/
@Override
public List<SysOrganization> selectByExample(String orgName,Byte orgStatus) {
SysOrganizationExample example=new SysOrganizationExample();
return orgDao.selectByExample(example);
}
/**
*
*/
@Override
public SysOrganization selectByPrimaryKey(Integer id) {
return orgDao.selectByPrimaryKey(id);
}
/**
*
*/
@Override
public int updateByPrimaryKeySelective(SysOrganization record) {
return orgDao.updateByPrimaryKeySelective(record);
}
/* (non-Javadoc)
* @see com.glsx.usercenter.service.ISysOrganizationService#findMenuByParams(java.util.Map)
*/
@Override
public List<SysOrganization> findMenuByParams(Map map) {
return null;
}
/* (non-Javadoc)
* @see com.glsx.usercenter.service.ISysOrganizationService#findAllRecursion(java.lang.Integer)
*/
@Override
public SysOrganization findAllRecursion(Integer id) {
return null;
}
}
<?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.glsx.usercenter.mapper.SysOrganizationMapper">
<resultMap id="BaseResultMap" type="com.glsx.usercenter.pojo.menu.SysOrganization">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="parent_id" jdbcType="INTEGER" property="parentId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="org_status" jdbcType="TINYINT" property="orgStatus" />
<result column="org_type" jdbcType="TINYINT" property="orgType" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="label" jdbcType="TINYINT" property="label" />
<result column="org_group" jdbcType="VARCHAR" property="orgGroup" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, parent_id, name, org_status, org_type, sort, create_time, update_time, remark,
update_by, create_by, label, org_group
</sql>
<select id="selectByExample" parameterType="com.glsx.usercenter.pojo.menu.SysOrganizationExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
'false' as QUERYID,
<include refid="Base_Column_List" />
from sys_organization
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_organization
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_organization
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.glsx.usercenter.pojo.menu.SysOrganization">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_organization (parent_id, name, org_status,
org_type, sort, create_time,
update_time, remark, update_by,
create_by, label, org_group
)
values (#{parentId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{orgStatus,jdbcType=TINYINT},
#{orgType,jdbcType=TINYINT}, #{sort,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, #{label,jdbcType=TINYINT}, #{orgGroup,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.glsx.usercenter.pojo.menu.SysOrganization">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_organization
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">
parent_id,
</if>
<if test="name != null">
name,
</if>
<if test="orgStatus != null">
org_status,
</if>
<if test="orgType != null">
org_type,
</if>
<if test="sort != null">
sort,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="remark != null">
remark,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="label != null">
label,
</if>
<if test="orgGroup != null">
org_group,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">
#{parentId,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="orgStatus != null">
#{orgStatus,jdbcType=TINYINT},
</if>
<if test="orgType != null">
#{orgType,jdbcType=TINYINT},
</if>
<if test="sort != null">
#{sort,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="label != null">
#{label,jdbcType=TINYINT},
</if>
<if test="orgGroup != null">
#{orgGroup,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.usercenter.pojo.menu.SysOrganization">
update sys_organization
<set>
<if test="parentId != null">
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="orgStatus != null">
org_status = #{orgStatus,jdbcType=TINYINT},
</if>
<if test="orgType != null">
org_type = #{orgType,jdbcType=TINYINT},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="label != null">
label = #{label,jdbcType=TINYINT},
</if>
<if test="orgGroup != null">
org_group = #{orgGroup,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.glsx.usercenter.pojo.menu.SysOrganization">
update sys_organization
set parent_id = #{parentId,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR},
org_status = #{orgStatus,jdbcType=TINYINT},
org_type = #{orgType,jdbcType=TINYINT},
sort = #{sort,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
remark = #{remark,jdbcType=VARCHAR},
update_by = #{updateBy,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
label = #{label,jdbcType=TINYINT},
org_group = #{orgGroup,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<resultMap id="recursionOrgMap" type="com.glsx.usercenter.pojo.menu.SysOrganization" extends="BaseResultMap" >
<collection property="children" ofType="com.glsx.usercenter.pojo.menu.SysOrganization" column="{id=id,org_status=,org_status}"
select="findOrgByParams" />
</resultMap>
<select id="findOrgByParams" resultMap="recursionOrgMap" parameterType="java.util.Map" >
SELECT
<include refid="Base_Column_List" />
from sys_organization WHERE 1=1
<if test="id != null">
and parent_id = #{id}
</if>
<if test="orgStatus != null">
and org_status = #{orgStatus}
</if>
ORDER BY
`sort` ASC
</select>
<resultMap id="recursionOrgResultMap" type="com.glsx.usercenter.pojo.menu.SysOrganization" extends="BaseResultMap" >
<collection property="children" ofType="com.glsx.usercenter.pojo.menu.SysOrganization" column="{id=id,org_status=org_status}"
select="findOrgByParentId" />
</resultMap>
<select id="findOrgByParentId" resultMap="recursionOrgResultMap">
SELECT
<include refid="Base_Column_List" />
from sys_organization WHERE parent_id = #{id}
and org_status in (0,1)
ORDER BY
`sort` ASC
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!