mirror of
https://github.com/WeiYe-Jing/datax-web.git
synced 2026-06-30 21:17:37 +08:00
This commit is contained in:
parent
56ca50a6e1
commit
4e2e035e21
@ -28,7 +28,7 @@ public class DataXAdminApplication {
|
||||
"Access URLs:\n----------------------------------------------------------\n\t"
|
||||
+ "Local-API: \t\thttp://127.0.0.1:{}\n\t"
|
||||
+ "External-API: \thttp://{}:{}\n\t"
|
||||
+ "web-URL: \t\thttp://127.0.0.1:{}\n\t----------------------------------------------------------",
|
||||
+ "web-URL: \t\thttp://127.0.0.1:{}/index.html\n\t----------------------------------------------------------",
|
||||
path, externalAPI, path, port);
|
||||
}
|
||||
|
||||
|
||||
@ -1,108 +0,0 @@
|
||||
package com.wugui.datax.admin.config;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by water on 2020.03.13.
|
||||
*/
|
||||
@Slf4j
|
||||
@Aspect
|
||||
@Component
|
||||
public class ControllerAspect {
|
||||
|
||||
private String clsPath = "com.wugui.datax.admin.controller.";
|
||||
|
||||
/**
|
||||
* ~ 第一个 * 代表任意修饰符及任意返回值. ~ 第二个 * 定义在web包或者子包 ~ 第三个 * 任意方法 ~ .. 匹配任意数量的参数.
|
||||
*/
|
||||
@Pointcut("execution(* com.wugui.datax.admin.controller..*.*(..))")
|
||||
public void logPointcut() {
|
||||
}
|
||||
|
||||
@Around("logPointcut()")
|
||||
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
String method = signature.getDeclaringTypeName().replace(clsPath, "") + "." + signature.getName();
|
||||
long start = System.currentTimeMillis();
|
||||
String input = Arrays.toString(joinPoint.getArgs());
|
||||
if (!method.contains("JobApiController")) {
|
||||
log.info("controller:{},input:{}", method, input);
|
||||
}
|
||||
try {
|
||||
Object resObj = joinPoint.proceed();
|
||||
return resObj;
|
||||
} catch (Throwable e) {
|
||||
long exceptCost = System.currentTimeMillis() - start;
|
||||
log.error(
|
||||
"controller request failed {} costTime is {}ms with exception {}",
|
||||
method, exceptCost, e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// private Object changeRestReturn(Object obj) {
|
||||
////反射获取object的data属性值(subEvent中的eventId)
|
||||
// String eventId = null;
|
||||
// Class jsonClass = obj.getClass();//通过entitySave的Object对象,获取运行时类的对象
|
||||
// Field dataField = null;
|
||||
// try {
|
||||
// //获取object中的data属性
|
||||
// dataField = jsonClass.getDeclaredField("data");
|
||||
// dataField.setAccessible(true);//设置data属性为可访问的
|
||||
// SubEvent tempSubEvent = new SubEvent();
|
||||
// try {
|
||||
// //通过Field.get(Object)获取object的data(SubEvent)中的eventId属性
|
||||
// tempSubEvent = (SubEvent) dataField.get(entitySave);
|
||||
// eventId = tempSubEvent.getEventId();
|
||||
// } catch (IllegalAccessException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// } catch (NoSuchFieldException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return obj;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 根据属性名获取属性值
|
||||
*/
|
||||
private String getFieldValueByName(String fieldName, Object o) {
|
||||
try {
|
||||
String firstLetter = fieldName.substring(0, 1).toUpperCase();
|
||||
String getter = "get" + firstLetter + fieldName.substring(1);
|
||||
Method method = o.getClass().getMethod(getter);
|
||||
Object value = method.invoke(o);
|
||||
return ((value != null) ? value.toString() : null);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性类型(type),属性名(name),属性值(value)的map组成的list
|
||||
*/
|
||||
private Map<String, String> getFileds(Object o) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
Field[] fields = o.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
map.put(field.getName(), getFieldValueByName(field.getName(), o));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@ -38,12 +38,13 @@ public class JobInfoController {
|
||||
private JobService jobService;
|
||||
|
||||
|
||||
public static void validPermission(HttpServletRequest request, int jobGroup) {
|
||||
JobUser loginUser = (JobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
||||
if (!loginUser.validPermission(jobGroup)) {
|
||||
throw new RuntimeException(I18nUtil.getString("system_permission_limit") + "[username=" + loginUser.getUsername() + "]");
|
||||
}
|
||||
}
|
||||
// public static void validPermission(HttpServletRequest request, int jobGroup) {
|
||||
// JobUser loginUser = (JobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY);
|
||||
//
|
||||
// if (!loginUser.validPermission(jobGroup)) {
|
||||
// throw new RuntimeException(I18nUtil.getString("system_permission_limit") + "[username=" + loginUser.getUsername() + "]");
|
||||
// }
|
||||
// }
|
||||
|
||||
@GetMapping("/pageList")
|
||||
@ApiOperation("任务列表")
|
||||
|
||||
@ -3,12 +3,15 @@ package com.wugui.datax.admin.core.handler;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 通用的字段填充,如createBy createDate这些字段的自动填充
|
||||
*
|
||||
* @author huzekang
|
||||
*/
|
||||
@Component
|
||||
@ -17,18 +20,17 @@ public class MybatisMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
log.debug("start insert fill ....");
|
||||
//todo createBy
|
||||
Date date = new Date();
|
||||
this.setInsertFieldValByName("createDate", date, metaObject);
|
||||
this.setInsertFieldValByName("updateDate", date, metaObject);
|
||||
setFieldValByName("createDate", new Date(), metaObject);
|
||||
setFieldValByName("createBy", getCurrentUser(), metaObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
//todo updateBY
|
||||
log.debug("start update fill ....");
|
||||
Date date = new Date();
|
||||
this.setUpdateFieldValByName("updateDate", date, metaObject);
|
||||
setFieldValByName("updateDate", new Date(), metaObject);
|
||||
setFieldValByName("updateBy", getCurrentUser(), metaObject);
|
||||
}
|
||||
|
||||
private String getCurrentUser() {
|
||||
return SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||
}
|
||||
}
|
||||
@ -87,6 +87,7 @@ public class JobJdbcDatasource extends Model<JobJdbcDatasource> {
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "创建人", hidden = true)
|
||||
private String createBy;
|
||||
|
||||
@ -101,6 +102,7 @@ public class JobJdbcDatasource extends Model<JobJdbcDatasource> {
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@ApiModelProperty(value = "更新人", hidden = true)
|
||||
private String updateBy;
|
||||
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package com.wugui.datax.admin.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @author xuxueli 2019-05-04 16:43:12
|
||||
*/
|
||||
public class JobRole {
|
||||
|
||||
private int id;
|
||||
@ApiModelProperty("账号")
|
||||
private String name;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@ -1,78 +1,41 @@
|
||||
package com.wugui.datax.admin.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author xuxueli 2019-05-04 16:43:12
|
||||
*/
|
||||
public class JobUser {
|
||||
|
||||
private int id;
|
||||
@ApiModelProperty("账号")
|
||||
private String username;
|
||||
@ApiModelProperty("密码")
|
||||
private String password;
|
||||
@ApiModelProperty("角色:0-普通用户、1-管理员")
|
||||
private String role;
|
||||
@ApiModelProperty("权限:执行器ID列表,多个逗号分割")
|
||||
private String permission;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
private int id;
|
||||
@ApiModelProperty("账号")
|
||||
private String username;
|
||||
@ApiModelProperty("密码")
|
||||
private String password;
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public void setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
// plugin
|
||||
public boolean validPermission(int jobGroup){
|
||||
if ("1".equals(this.role)) {
|
||||
return true;
|
||||
} else {
|
||||
if (StringUtils.hasText(this.permission)) {
|
||||
for (String permissionItem : this.permission.split(",")) {
|
||||
if (String.valueOf(jobGroup).equals(permissionItem)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,11 +21,11 @@ public class JwtUser implements UserDetails {
|
||||
}
|
||||
|
||||
// 写一个能直接使用user创建jwtUser的构造器
|
||||
public JwtUser(JobUser user) {
|
||||
public JwtUser(JobUser user, JobRole role) {
|
||||
id = user.getId();
|
||||
username = user.getUsername();
|
||||
password = user.getPassword();
|
||||
authorities = Collections.singleton(new SimpleGrantedAuthority(user.getRole()));
|
||||
authorities = Collections.singleton(new SimpleGrantedAuthority(role.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -18,7 +18,7 @@ public class JWTAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
||||
@Override
|
||||
public void commence(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
AuthenticationException authException) throws IOException, ServletException {
|
||||
AuthenticationException authException) throws IOException {
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json; charset=utf-8");
|
||||
|
||||
@ -19,7 +19,6 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -61,7 +60,7 @@ public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilte
|
||||
protected void successfulAuthentication(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
FilterChain chain,
|
||||
Authentication authResult) throws IOException, ServletException {
|
||||
Authentication authResult) throws IOException {
|
||||
|
||||
JwtUser jwtUser = (JwtUser) authResult.getPrincipal();
|
||||
boolean isRemember = rememberMe.get() == 1;
|
||||
@ -78,7 +77,7 @@ public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilte
|
||||
// 按照jwt的规定,最后请求的时候应该是 `Bearer token`
|
||||
response.setHeader("token", JwtTokenUtils.TOKEN_PREFIX + token);
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
Map<String, Object> maps = new HashMap<String, Object>();
|
||||
Map<String, Object> maps = new HashMap<>();
|
||||
maps.put("data", JwtTokenUtils.TOKEN_PREFIX + token);
|
||||
maps.put("roles", role.split(","));
|
||||
response.getWriter().write(JSON.toJSON(new ReturnT<>(maps)).toString());
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.wugui.datax.admin.mapper;
|
||||
|
||||
import com.wugui.datax.admin.entity.JobRole;
|
||||
import com.wugui.datax.admin.entity.JobUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -24,6 +25,9 @@ public interface JobUserMapper {
|
||||
|
||||
JobUser loadByUserName(@Param("username") String username);
|
||||
|
||||
JobRole getRoleByUserId(@Param("userId") int userId);
|
||||
|
||||
|
||||
JobUser getUserById(@Param("id") int id);
|
||||
|
||||
int save(JobUser xxlJobUser);
|
||||
|
||||
@ -210,7 +210,7 @@ public class JobServiceImpl implements JobService {
|
||||
// stage job info
|
||||
JobInfo exists_jobInfo = jobInfoMapper.loadById(jobInfo.getId());
|
||||
if (exists_jobInfo == null) {
|
||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id") + I18nUtil.getString("system_not_found")));
|
||||
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id") + I18nUtil.getString("system_not_found")));
|
||||
}
|
||||
|
||||
// next trigger time (5s后生效,避开预读周期)
|
||||
@ -386,7 +386,7 @@ public class JobServiceImpl implements JobService {
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("triggerDayList", triggerDayList);
|
||||
result.put("triggerDayCountRunningList", triggerDayCountRunningList);
|
||||
result.put("triggerDayCountSucList", triggerDayCountSucList);
|
||||
@ -396,7 +396,7 @@ public class JobServiceImpl implements JobService {
|
||||
result.put("triggerCountSucTotal", triggerCountSucTotal);
|
||||
result.put("triggerCountFailTotal", triggerCountFailTotal);
|
||||
|
||||
return new ReturnT<Map<String, Object>>(result);
|
||||
return new ReturnT<>(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.wugui.datax.admin.service.impl;
|
||||
|
||||
import com.wugui.datatx.core.biz.model.ReturnT;
|
||||
import com.wugui.datax.admin.entity.JobRole;
|
||||
import com.wugui.datax.admin.entity.JwtUser;
|
||||
import com.wugui.datax.admin.entity.JobUser;
|
||||
import com.wugui.datax.admin.core.util.CookieUtil;
|
||||
@ -30,12 +31,13 @@ public class LoginService implements UserDetailsService {
|
||||
private JobUserMapper jobUserMapper;
|
||||
|
||||
|
||||
private String makeToken(JobUser xxlJobUser){
|
||||
private String makeToken(JobUser xxlJobUser) {
|
||||
String tokenJson = JacksonUtil.writeValueAsString(xxlJobUser);
|
||||
String tokenHex = new BigInteger(tokenJson.getBytes()).toString(16);
|
||||
return tokenHex;
|
||||
}
|
||||
private JobUser parseToken(String tokenHex){
|
||||
|
||||
private JobUser parseToken(String tokenHex) {
|
||||
JobUser xxlJobUser = null;
|
||||
if (tokenHex != null) {
|
||||
String tokenJson = new String(new BigInteger(tokenHex, 16).toByteArray()); // username_password(md5)
|
||||
@ -45,21 +47,21 @@ public class LoginService implements UserDetailsService {
|
||||
}
|
||||
|
||||
|
||||
public ReturnT<String> login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean ifRemember){
|
||||
public ReturnT<String> login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean ifRemember) {
|
||||
|
||||
// param
|
||||
if (username==null || username.trim().length()==0 || password==null || password.trim().length()==0){
|
||||
return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
|
||||
if (username == null || username.trim().length() == 0 || password == null || password.trim().length() == 0) {
|
||||
return new ReturnT<>(500, I18nUtil.getString("login_param_empty"));
|
||||
}
|
||||
|
||||
// valid passowrd
|
||||
JobUser xxlJobUser = jobUserMapper.loadByUserName(username);
|
||||
if (xxlJobUser == null) {
|
||||
return new ReturnT<String>(500, I18nUtil.getString("login_param_unvalid"));
|
||||
return new ReturnT<>(500, I18nUtil.getString("login_param_unvalid"));
|
||||
}
|
||||
String passwordMd5 = DigestUtils.md5DigestAsHex(password.getBytes());
|
||||
if (!passwordMd5.equals(xxlJobUser.getPassword())) {
|
||||
return new ReturnT<String>(500, I18nUtil.getString("login_param_unvalid"));
|
||||
return new ReturnT<>(500, I18nUtil.getString("login_param_unvalid"));
|
||||
}
|
||||
|
||||
String loginToken = makeToken(xxlJobUser);
|
||||
@ -75,7 +77,7 @@ public class LoginService implements UserDetailsService {
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response){
|
||||
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response) {
|
||||
CookieUtil.remove(request, response, LOGIN_IDENTITY_KEY);
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
@ -86,7 +88,7 @@ public class LoginService implements UserDetailsService {
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public JobUser ifLogin(HttpServletRequest request, HttpServletResponse response){
|
||||
public JobUser ifLogin(HttpServletRequest request, HttpServletResponse response) {
|
||||
String cookieToken = CookieUtil.getValue(request, LOGIN_IDENTITY_KEY);
|
||||
if (cookieToken != null) {
|
||||
JobUser cookieUser = null;
|
||||
@ -111,6 +113,7 @@ public class LoginService implements UserDetailsService {
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
|
||||
JobUser user = jobUserMapper.loadByUserName(s);
|
||||
return new JwtUser(user);
|
||||
JobRole role = jobUserMapper.getRoleByUserId(user.getId());
|
||||
return new JwtUser(user, role);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.wugui.datax.admin.service.impl;
|
||||
|
||||
import com.wugui.datax.admin.entity.JobRole;
|
||||
import com.wugui.datax.admin.entity.JwtUser;
|
||||
import com.wugui.datax.admin.entity.JobUser;
|
||||
import com.wugui.datax.admin.mapper.JobUserMapper;
|
||||
@ -21,7 +22,8 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
|
||||
JobUser user = jobUserMapper.loadByUserName(s);
|
||||
return new JwtUser(user);
|
||||
JobRole role = jobUserMapper.getRoleByUserId(user.getId());
|
||||
return new JwtUser(user, role);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,25 +7,24 @@
|
||||
<result column="id" property="id"/>
|
||||
<result column="username" property="username"/>
|
||||
<result column="password" property="password"/>
|
||||
<result column="role" property="role"/>
|
||||
<result column="permission" property="permission"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="JobRole" type="com.wugui.datax.admin.entity.JobRole">
|
||||
<result column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
t.id,
|
||||
t.username,
|
||||
t.password,
|
||||
t.role,
|
||||
t.permission
|
||||
t.password
|
||||
</sql>
|
||||
|
||||
<select id="pageList" parameterType="java.util.HashMap" resultMap="JobUser">
|
||||
<!--SELECT <include refid="Base_Column_List" />--> /*不返回密码(前端密码置空)*/
|
||||
SELECT
|
||||
t.id,
|
||||
t.username,
|
||||
t.role,
|
||||
t.permission
|
||||
t.username
|
||||
FROM job_user AS t
|
||||
<trim prefix="WHERE" prefixOverrides="AND | OR">
|
||||
<if test="username != null and username != ''">
|
||||
@ -53,27 +52,33 @@
|
||||
WHERE t.username = #{username}
|
||||
</select>
|
||||
|
||||
<select id="getRoleByUserId" parameterType="java.util.HashMap" resultMap="JobRole">
|
||||
SELECT
|
||||
a.id,
|
||||
a.NAME
|
||||
FROM
|
||||
job_role a
|
||||
LEFT JOIN role_user b ON a.id = b.role_id
|
||||
LEFT JOIN job_user c ON b.user_id = c.id
|
||||
WHERE
|
||||
b.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="getUserById" parameterType="java.util.HashMap" resultMap="JobUser">
|
||||
SELECT
|
||||
t.id,
|
||||
t.username,
|
||||
t.role,
|
||||
t.permission
|
||||
t.username
|
||||
FROM job_user AS t
|
||||
WHERE t.id = #{id}
|
||||
WHERE t.id = #{userId}
|
||||
</select>
|
||||
|
||||
<insert id="save" parameterType="com.wugui.datax.admin.entity.JobUser" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO job_user (
|
||||
username,
|
||||
password,
|
||||
role,
|
||||
permission
|
||||
password
|
||||
) VALUES (
|
||||
#{username},
|
||||
#{password},
|
||||
#{role},
|
||||
#{permission}
|
||||
#{password}
|
||||
);
|
||||
</insert>
|
||||
|
||||
@ -83,8 +88,6 @@
|
||||
<if test="password != null and password != ''">
|
||||
password = #{password},
|
||||
</if>
|
||||
role = #{role},
|
||||
permission = #{permission}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user